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());
}
});
}
}
use of org.apache.ignite.internal.util.typedef.CA in project ignite by apache.
the class IgfsFragmentizerSelfTest method testDeleteFragmentizing.
/**
* @throws Exception If failed.
*/
public void testDeleteFragmentizing() throws Exception {
IgfsImpl igfs = (IgfsImpl) grid(0).fileSystem("igfs");
for (int i = 0; i < 30; i++) {
IgfsPath path = new IgfsPath("/someFile" + i);
try (IgfsOutputStream out = igfs.create(path, true)) {
for (int j = 0; j < 5 * IGFS_GROUP_SIZE; j++) out.write(new byte[IGFS_BLOCK_SIZE]);
}
U.sleep(200);
}
igfs.clear();
GridTestUtils.retryAssert(log, 50, 100, new CA() {
@Override
public void apply() {
for (int i = 0; i < NODE_CNT; i++) {
IgniteEx g = grid(i);
GridCacheAdapter<Object, Object> cache = ((IgniteKernal) g).internalCache(g.igfsx("igfs").configuration().getDataCacheConfiguration().getName());
assertTrue("Data cache is not empty [keys=" + cache.keySet() + ", node=" + g.localNode().id() + ']', cache.isEmpty());
}
}
});
}
use of org.apache.ignite.internal.util.typedef.CA in project ignite by apache.
the class IpcSharedMemoryCrashDetectionSelfTest method startSharedMemoryTestServer.
/**
* Starts {@code IgfsSharedMemoryTestServer}. The method waits while server being started.
*
* @return Start result of the {@code IgfsSharedMemoryTestServer}.
* @throws Exception In case of any exception happen.
*/
private ProcessStartResult startSharedMemoryTestServer() throws Exception {
final CountDownLatch srvReady = new CountDownLatch(1);
final CountDownLatch isKilledLatch = new CountDownLatch(1);
GridJavaProcess proc = GridJavaProcess.exec(IgfsSharedMemoryTestServer.class, null, log, new CI1<String>() {
@Override
public void apply(String str) {
info("Server process prints: " + str);
if (str.contains("IPC shared memory server endpoint started"))
srvReady.countDown();
}
}, new CA() {
@Override
public void apply() {
info("Server is killed");
isKilledLatch.countDown();
}
}, null, System.getProperty("surefire.test.class.path"));
srvReady.await();
ProcessStartResult res = new ProcessStartResult();
res.proc(proc);
res.isKilledLatch(isKilledLatch);
return res;
}
Aggregations