use of org.apache.ignite.internal.util.GridAtomicInteger in project ignite by apache.
the class CacheDiscoveryDataConcurrentJoinTest method testConcurrentJoin.
/**
* @throws Exception If failed.
*/
public void testConcurrentJoin() throws Exception {
for (int iter = 0; iter < ITERATIONS; iter++) {
log.info("Iteration: " + iter);
final int NODES = 6;
final int MAX_CACHES = 10;
final GridAtomicInteger caches = new GridAtomicInteger();
startGrid(0);
final AtomicInteger idx = new AtomicInteger(1);
GridTestUtils.runMultiThreaded(new Callable<Void>() {
@Override
public Void call() throws Exception {
int c = ThreadLocalRandom.current().nextInt(MAX_CACHES) + 1;
staticCaches.set(c);
startGrid(idx.getAndIncrement());
caches.setIfGreater(c);
return null;
}
}, NODES - 1, "start-node");
assertTrue(caches.get() > 0);
for (int i = 0; i < NODES; i++) {
Ignite node = ignite(i);
for (int c = 0; c < caches.get(); c++) {
Collection<ClusterNode> nodes = node.cluster().forCacheNodes("cache-" + c).nodes();
assertEquals(NODES, nodes.size());
checkCache(node, "cache-" + c);
}
}
stopAllGrids();
}
}
use of org.apache.ignite.internal.util.GridAtomicInteger in project ignite by apache.
the class GridCacheAsyncOperationsLimitSelfTest method testAsyncOps.
/**
* @throws Exception If failed.
*/
public void testAsyncOps() throws Exception {
final AtomicInteger cnt = new AtomicInteger();
final GridAtomicInteger max = new GridAtomicInteger();
for (int i = 0; i < 5000; i++) {
final int i0 = i;
cnt.incrementAndGet();
jcache().putAsync("key" + i, i).listen(new CI1<IgniteFuture<?>>() {
@Override
public void apply(IgniteFuture<?> t) {
cnt.decrementAndGet();
max.setIfGreater(cnt.get());
if (i0 > 0 && i0 % 100 == 0)
info("cnt: " + cnt.get());
}
});
assertTrue("Maximum number of permits exceeded: " + max.get(), max.get() <= 51);
}
}
Aggregations