use of org.apache.ignite.internal.util.typedef.CA in project ignite by apache.
the class GridCacheDeploymentManager method onUndeploy.
/**
* Undeploys given class loader.
*
* @param ldr Class loader to undeploy.
* @param ctx Grid cache context.
*/
public void onUndeploy(final ClassLoader ldr, final GridCacheContext<K, V> ctx) {
assert ldr != null;
if (log.isDebugEnabled())
log.debug("Received onUndeploy() request [ldr=" + ldr + ", cctx=" + cctx + ']');
synchronized (undeploys) {
List<CA> queue = undeploys.get(ctx.name());
if (queue == null)
undeploys.put(ctx.name(), queue = new ArrayList<>());
queue.add(new CA() {
@Override
public void apply() {
onUndeploy0(ldr, ctx);
}
});
}
// We go through preloader for proper synchronization.
if (ctx.isLocal())
ctx.preloader().unwindUndeploys();
}
use of org.apache.ignite.internal.util.typedef.CA in project ignite by apache.
the class GridCacheAbstractDataStructuresFailoverSelfTest method testAtomicSequenceInitialization.
/**
* @throws Exception If failed.
*/
public void testAtomicSequenceInitialization() throws Exception {
int threadCnt = 3;
final AtomicInteger idx = new AtomicInteger(gridCount());
IgniteInternalFuture<?> fut = GridTestUtils.runMultiThreadedAsync(new CA() {
@Override
public void apply() {
int id = idx.getAndIncrement();
try {
log.info("Start node: " + id);
startGrid(id);
Thread.sleep(1000);
} catch (Exception e) {
throw F.wrap(e);
} finally {
stopGrid(id);
info("Thread finished.");
}
}
}, threadCnt, "test-thread");
while (!fut.isDone()) {
grid(0).compute().call(new IgniteCallable<Object>() {
/** */
@IgniteInstanceResource
private Ignite g;
@Override
public Object call() throws Exception {
IgniteAtomicSequence seq = g.atomicSequence(STRUCTURE_NAME, 1, true);
assert seq != null;
for (int i = 0; i < 1000; i++) seq.getAndIncrement();
return null;
}
});
}
fut.get();
}
use of org.apache.ignite.internal.util.typedef.CA in project ignite by apache.
the class GridCacheAbstractIteratorsSelfTest method testEntrySetIteratorMultithreaded.
/**
* @throws Exception If failed.
*/
public void testEntrySetIteratorMultithreaded() throws Exception {
for (int i = 0; i < gridCount(); i++) jcache(i).removeAll();
final IgniteInternalFuture<?> putFut = GridTestUtils.runMultiThreadedAsync(new CAX() {
@Override
public void applyx() {
for (int i = 0; i < entryCount(); i++) jcache().put(KEY_PREFIX + i, i);
}
}, 1, "put-thread");
GridTestUtils.runMultiThreaded(new CA() {
@Override
public void apply() {
while (!putFut.isDone()) {
for (Cache.Entry<String, Integer> entry : jcache()) {
assert entry != null;
assert entry.getKey() != null;
assert entry.getKey().contains(KEY_PREFIX);
}
}
}
}, 3, "iterator-thread");
}
use of org.apache.ignite.internal.util.typedef.CA in project ignite by apache.
the class GridCacheAbstractIteratorsSelfTest method testCacheIteratorMultithreaded.
/**
* @throws Exception If failed.
*/
public void testCacheIteratorMultithreaded() throws Exception {
for (int i = 0; i < gridCount(); i++) jcache(i).removeAll();
final IgniteInternalFuture<?> putFut = GridTestUtils.runMultiThreadedAsync(new CAX() {
@Override
public void applyx() {
for (int i = 0; i < entryCount(); i++) jcache().put(KEY_PREFIX + i, i);
}
}, 1, "put-thread");
GridTestUtils.runMultiThreaded(new CA() {
@Override
public void apply() {
while (!putFut.isDone()) {
for (Cache.Entry<String, Integer> entry : jcache()) {
assert entry != null;
assert entry.getKey() != null;
assert entry.getKey().contains(KEY_PREFIX);
}
}
}
}, 3, "iterator-thread");
}
use of org.apache.ignite.internal.util.typedef.CA in project ignite by apache.
the class GridCacheReferenceCleanupSelfTest method checkReferenceCleanup.
/**
* @param call Callable.
* @throws Exception If failed.
*/
public void checkReferenceCleanup(Callable<Collection<WeakReference<Object>>> call) throws Exception {
for (boolean cancel : new boolean[] { true, false }) {
this.cancel = cancel;
final Collection<WeakReference<Object>> refs = call.call();
GridTestUtils.retryAssert(log, 10, 1000, new CA() {
@Override
public void apply() {
System.gc();
System.gc();
System.gc();
for (WeakReference<?> ref : refs) assertNull("" + ref.get(), ref.get());
}
});
}
}
Aggregations