use of org.apache.ignite.internal.util.typedef.CA in project ignite by apache.
the class IpcSharedMemoryCrashDetectionSelfTest method startSharedMemoryTestClient.
/**
* Starts {@code IgfsSharedMemoryTestClient}. The method doesn't wait while client being started.
*
* @return Start result of the {@code IgfsSharedMemoryTestClient}.
* @throws Exception In case of any exception happen.
*/
private ProcessStartResult startSharedMemoryTestClient() throws Exception {
/**
*/
final CountDownLatch killedLatch = new CountDownLatch(1);
/**
*/
final CountDownLatch readyLatch = new CountDownLatch(1);
/**
*/
final ProcessStartResult res = new ProcessStartResult();
/**
* Process.
*/
GridJavaProcess proc = GridJavaProcess.exec(IgfsSharedMemoryTestClient.class, null, log, new CI1<String>() {
@Override
public void apply(String s) {
info("Client process prints: " + s);
if (s.startsWith(IgfsSharedMemoryTestClient.SHMEM_IDS_MSG_PREFIX)) {
res.shmemIds(s.substring(IgfsSharedMemoryTestClient.SHMEM_IDS_MSG_PREFIX.length()));
readyLatch.countDown();
}
}
}, new CA() {
@Override
public void apply() {
info("Client is killed");
killedLatch.countDown();
}
}, null, System.getProperty("surefire.test.class.path"));
res.proc(proc);
res.isKilledLatch(killedLatch);
res.isReadyLatch(readyLatch);
return res;
}
use of org.apache.ignite.internal.util.typedef.CA in project ignite by apache.
the class GridCacheAbstractFullApiMultithreadedSelfTest method runTest.
/**
* @param c Test closure.
* @throws Exception In case of error.
*/
private void runTest(final IgniteInClosure<IgniteCache<String, Integer>> c) throws Exception {
final IgniteInternalFuture<?> fut1 = GridTestUtils.runMultiThreadedAsync(new CAX() {
@Override
public void applyx() {
while (true) {
int i = cnt.getAndIncrement();
if (i >= PUT_CNT)
break;
jcache().put("key" + i, i);
set.add(i);
if (i > 10)
guard.compareAndSet(false, true);
}
}
}, WRITE_THREAD_CNT, WRITE_THREAD_NAME);
IgniteInternalFuture<?> fut2 = GridTestUtils.runMultiThreadedAsync(new CA() {
@Override
public void apply() {
IgniteCache<String, Integer> cache = jcache();
while (!fut1.isDone()) if (guard.get())
c.apply(cache);
}
}, READ_THREAD_CNT, READ_THREAD_NAME);
fut1.get();
fut2.get();
checkConsistency();
}
use of org.apache.ignite.internal.util.typedef.CA in project ignite by apache.
the class CacheGetFromJobTest method testTopologyChange.
/**
* @throws Exception If failed.
*/
public void testTopologyChange() throws Exception {
final AtomicReference<Exception> err = new AtomicReference<>();
final AtomicInteger id = new AtomicInteger(1);
IgniteInternalFuture<?> fut = GridTestUtils.runMultiThreadedAsync(new CA() {
@Override
public void apply() {
info("Run topology change.");
try {
for (int i = 0; i < 5; i++) {
info("Topology change: " + i);
startGrid(id.getAndIncrement());
}
} catch (Exception e) {
err.set(e);
log.error("Unexpected exception in topology-change-thread: " + e, e);
}
}
}, 3, "topology-change-thread");
int cntr = 0;
while (!fut.isDone()) {
grid(0).compute().broadcast(new TestJob());
cntr++;
}
log.info("Job execution count: " + cntr);
Exception err0 = err.get();
if (err0 != null)
throw err0;
}
use of org.apache.ignite.internal.util.typedef.CA in project ignite by apache.
the class GridCacheDeploymentManager method unwind.
/**
* Undeploy all queued up closures.
*
* @param ctx Cache context.
*/
public void unwind(GridCacheContext ctx) {
List<CA> q;
synchronized (undeploys) {
q = undeploys.remove(ctx.name());
}
if (q == null)
return;
int cnt = 0;
for (CA c : q) {
c.apply();
cnt++;
}
if (log.isDebugEnabled())
log.debug("Unwound undeploys count: " + cnt);
}
Aggregations