use of org.apache.ignite.internal.processors.cache.PartitionUpdateCounterTrackingImpl in project ignite by apache.
the class PartitionUpdateCounterTest method testWithPersistentNode.
/**
* @param mode Mode.
*/
private void testWithPersistentNode(CacheAtomicityMode mode) throws Exception {
this.mode = mode;
try {
IgniteEx grid0 = startGrid(0);
grid0.cluster().baselineAutoAdjustEnabled(false);
grid0.cluster().active(true);
grid0.cluster().baselineAutoAdjustEnabled(false);
grid0.cache(DEFAULT_CACHE_NAME).put(0, 0);
startGrid(1);
grid0.cluster().setBaselineTopology(2);
awaitPartitionMapExchange();
grid0.cache(DEFAULT_CACHE_NAME).put(1, 1);
assertPartitionsSame(idleVerify(grid0, DEFAULT_CACHE_NAME));
printPartitionState(DEFAULT_CACHE_NAME, 0);
stopGrid(grid0.name(), false);
grid0 = startGrid(grid0.name());
awaitPartitionMapExchange();
PartitionUpdateCounter cntr = counter(0, grid0.name());
assertTrue(cntr instanceof PartitionUpdateCounterErrorWrapper);
PartitionUpdateCounter delegate = U.field(cntr, "delegate");
if (mode == CacheAtomicityMode.TRANSACTIONAL)
assertTrue(delegate instanceof PartitionUpdateCounterTrackingImpl);
else if (mode == CacheAtomicityMode.ATOMIC)
assertTrue(delegate instanceof PartitionUpdateCounterVolatileImpl);
assertEquals(cntr.initial(), cntr.get());
} finally {
stopAllGrids();
}
}
use of org.apache.ignite.internal.processors.cache.PartitionUpdateCounterTrackingImpl in project ignite by apache.
the class PartitionUpdateCounterTest method testOutOfOrderUpdatesIterator.
/**
*/
@Test
public void testOutOfOrderUpdatesIterator() {
PartitionUpdateCounter pc = new PartitionUpdateCounterTrackingImpl(null);
pc.update(67, 3);
pc.update(1, 58);
pc.update(60, 5);
Iterator<long[]> iter = pc.iterator();
long[] upd = iter.next();
assertEquals(1, upd[0]);
assertEquals(58, upd[1]);
upd = iter.next();
assertEquals(60, upd[0]);
assertEquals(5, upd[1]);
upd = iter.next();
assertEquals(67, upd[0]);
assertEquals(3, upd[1]);
assertFalse(iter.hasNext());
}
use of org.apache.ignite.internal.processors.cache.PartitionUpdateCounterTrackingImpl in project ignite by apache.
the class PartitionUpdateCounterTest method testRandomUpdates.
/**
* Test applying update multiple times in random order.
*/
@Test
public void testRandomUpdates() {
List<int[]> tmp = generateUpdates(1000, 5);
long expTotal = tmp.stream().mapToInt(pair -> pair[1]).sum();
PartitionUpdateCounter pc = null;
for (int i = 0; i < 100; i++) {
Collections.shuffle(tmp);
PartitionUpdateCounter pc0 = new PartitionUpdateCounterTrackingImpl(null);
for (int[] pair : tmp) pc0.update(pair[0], pair[1]);
if (pc == null)
pc = pc0;
else {
assertEquals(pc, pc0);
assertEquals(expTotal, pc0.get());
assertTrue(pc0.sequential());
pc = pc0;
}
}
}
use of org.apache.ignite.internal.processors.cache.PartitionUpdateCounterTrackingImpl in project ignite by apache.
the class PartitionUpdateCounterTest method testFoldIntermediateUpdates.
/**
*/
@Test
public void testFoldIntermediateUpdates() {
PartitionUpdateCounter pc = new PartitionUpdateCounterTrackingImpl(null);
pc.update(0, 59);
pc.update(60, 5);
pc.update(67, 3);
pc.update(65, 2);
Iterator<long[]> it = pc.iterator();
it.next();
assertFalse(it.hasNext());
pc.update(59, 1);
assertTrue(pc.sequential());
}
use of org.apache.ignite.internal.processors.cache.PartitionUpdateCounterTrackingImpl in project ignite by apache.
the class PartitionUpdateCounterTest method testMaxGaps.
/**
* Test logic for handling gaps limit.
*/
@Test
public void testMaxGaps() {
PartitionUpdateCounter pc = new PartitionUpdateCounterTrackingImpl(null);
int i;
for (i = 1; i <= PartitionUpdateCounterTrackingImpl.MAX_MISSED_UPDATES; i++) pc.update(i * 3, i * 3 + 1);
i++;
try {
pc.update(i * 3, i * 3 + 1);
fail();
} catch (Exception e) {
// Expected.
}
}
Aggregations