use of org.apache.ignite.internal.processors.cache.PartitionUpdateCounterVolatileImpl 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.PartitionUpdateCounterVolatileImpl in project ignite by apache.
the class PartitionUpdateCounterTest method testAtomicUpdateCounterMultithreaded.
/**
*/
@Test
public void testAtomicUpdateCounterMultithreaded() throws Exception {
PartitionUpdateCounter cntr = new PartitionUpdateCounterVolatileImpl(null);
AtomicInteger id = new AtomicInteger();
final int max = 1000;
IgniteInternalFuture<?> fut = multithreadedAsync(new Runnable() {
@Override
public void run() {
int val;
while ((val = id.incrementAndGet()) <= max) {
try {
cntr.update(val);
} catch (IgniteCheckedException e) {
fail(X.getFullStackTrace(e));
}
}
}
}, Runtime.getRuntime().availableProcessors() * 2, "updater");
fut.get();
assertEquals(max, cntr.get());
}
Aggregations