use of org.apache.ignite.internal.util.GridLongList in project ignite by apache.
the class GridLongListSelfTest method testSerializationConstructorWithZeroSize.
/**
*/
@Ignore("https://issues.apache.org/jira/browse/IGNITE-12678")
@Test
public void testSerializationConstructorWithZeroSize() {
MessageWriter writer = new DirectMessageWriter(GridIoManager.DIRECT_PROTO_VER);
ByteBuffer buf = ByteBuffer.allocate(4096);
GridLongList ll = new GridLongList(0);
{
Assert.assertTrue(ll.writeTo(buf, writer));
Assert.assertEquals(HEADER_SIZE + 1 + /* array */
1, /* index */
buf.position());
}
{
writer.reset();
buf.clear();
ll.add(2L);
ll.add(4L);
Assert.assertTrue(ll.writeTo(buf, writer));
Assert.assertEquals(HEADER_SIZE + 17 + /* array */
1, /* index */
buf.position());
}
{
writer.reset();
buf.clear();
ll.remove();
Assert.assertTrue(ll.writeTo(buf, writer));
Assert.assertEquals(HEADER_SIZE + 9 + /* array */
1, /* index */
buf.position());
}
{
writer.reset();
buf.clear();
ll.remove();
Assert.assertTrue(ll.writeTo(buf, writer));
Assert.assertEquals(HEADER_SIZE + 1 + /* array */
1, /* index */
buf.position());
}
{
writer.reset();
buf.clear();
for (int i = 0; i < 300; i++) ll.add(i);
Assert.assertTrue(ll.writeTo(buf, writer));
Assert.assertEquals(300, ll.size());
Assert.assertEquals(HEADER_SIZE + 2402 + /* array */
2, /* index */
buf.position());
}
{
writer.reset();
buf.clear();
ll.clear();
Assert.assertTrue(ll.writeTo(buf, writer));
Assert.assertEquals(HEADER_SIZE + 1 + /* array */
1, /* index */
buf.position());
}
}
use of org.apache.ignite.internal.util.GridLongList in project ignite by apache.
the class GridLongListSelfTest method testSort.
/**
*/
@Test
public void testSort() {
assertEquals(new GridLongList(), new GridLongList().sort());
assertEquals(asList(1), asList(1).sort());
assertEquals(asList(1, 2), asList(2, 1).sort());
assertEquals(asList(1, 2, 3), asList(2, 1, 3).sort());
GridLongList list = new GridLongList();
list.add(4);
list.add(3);
list.add(5);
list.add(1);
assertEquals(asList(1, 3, 4, 5), list.sort());
list.add(0);
assertEquals(asList(1, 3, 4, 5, 0), list);
assertEquals(asList(0, 1, 3, 4, 5), list.sort());
}
use of org.apache.ignite.internal.util.GridLongList in project ignite by apache.
the class GridLongListSelfTest method testRemove.
/**
*/
@Test
public void testRemove() {
GridLongList list = asList(1, 2, 3, 4, 5, 6);
assertEquals(2, list.removeValue(0, 3));
assertEquals(asList(1, 2, 4, 5, 6), list);
assertEquals(-1, list.removeValue(1, 1));
assertEquals(-1, list.removeValue(0, 3));
assertEquals(4, list.removeValue(0, 6));
assertEquals(asList(1, 2, 4, 5), list);
assertEquals(2, list.removeIndex(1));
assertEquals(asList(1, 4, 5), list);
assertEquals(1, list.removeIndex(0));
assertEquals(asList(4, 5), list);
}
use of org.apache.ignite.internal.util.GridLongList in project ignite by apache.
the class GridLongListSelfTest method testSerializationConstructorWithSize.
/**
*/
@Test
public void testSerializationConstructorWithSize() {
MessageWriter writer = new DirectMessageWriter(GridIoManager.DIRECT_PROTO_VER);
ByteBuffer buf = ByteBuffer.allocate(4096);
GridLongList ll = new GridLongList(5);
{
Assert.assertTrue(ll.writeTo(buf, writer));
Assert.assertEquals(HEADER_SIZE + 1 + /* array */
1, /* index */
buf.position());
}
{
writer.reset();
buf.clear();
ll.add(2L);
ll.add(4L);
Assert.assertTrue(ll.writeTo(buf, writer));
Assert.assertEquals(HEADER_SIZE + 17 + /* array */
1, /* index */
buf.position());
}
{
writer.reset();
buf.clear();
ll.remove();
Assert.assertTrue(ll.writeTo(buf, writer));
Assert.assertEquals(HEADER_SIZE + 9 + /* array */
1, /* index */
buf.position());
}
{
writer.reset();
buf.clear();
ll.remove();
Assert.assertTrue(ll.writeTo(buf, writer));
Assert.assertEquals(HEADER_SIZE + 1 + /* array */
1, /* index */
buf.position());
}
{
writer.reset();
buf.clear();
for (int i = 0; i < 300; i++) ll.add(i);
Assert.assertTrue(ll.writeTo(buf, writer));
Assert.assertEquals(300, ll.size());
Assert.assertEquals(HEADER_SIZE + 2402 + /* array */
2, /* index */
buf.position());
}
{
writer.reset();
buf.clear();
ll.clear();
Assert.assertTrue(ll.writeTo(buf, writer));
Assert.assertEquals(HEADER_SIZE + 1 + /* array */
1, /* index */
buf.position());
}
}
use of org.apache.ignite.internal.util.GridLongList in project ignite by apache.
the class IgnitePdsPageReplacementDuringPartitionClearTest method testPageEvictionOnNodeStart.
/**
* @throws Exception if failed.
*/
@Test
@WithSystemProperty(key = GridCacheDatabaseSharedManager.IGNITE_PDS_CHECKPOINT_TEST_SKIP_SYNC, value = "true")
public void testPageEvictionOnNodeStart() throws Exception {
cleanPersistenceDir();
startGrids(2);
AtomicBoolean stop = new AtomicBoolean(false);
try {
Ignite ig = ignite(0);
ig.cluster().active(true);
ig.cluster().baselineAutoAdjustEnabled(false);
int last = loadDataUntilPageReplacement(ignite(0), ignite(1));
IgniteInternalFuture<?> fut = loadAsync(ig, stop, last);
EvictionListener evictLsnr = new EvictionListener();
ignite(0).events().localListen(evictLsnr, EVT_CACHE_REBALANCE_PART_UNLOADED);
ignite(1).events().localListen(evictLsnr, EVT_CACHE_REBALANCE_PART_UNLOADED);
IgniteEx igNew = startGrid(2);
info(">>>>>>>>>>>");
info(">>>>>>>>>>>");
info(">>>>>>>>>>>");
igNew.cluster().setBaselineTopology(3);
awaitPartitionMapExchange();
Map<ClusterNode, GridLongList> affinityAfter = allPartitions(igNew);
evictLsnr.waitPartitionsEvicted(igNew.cluster().localNode(), affinityAfter);
stop.set(true);
fut.get();
} finally {
stop.set(true);
stopAllGrids();
cleanPersistenceDir();
}
}
Aggregations