Search in sources :

Example 6 with CA

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");
}
Also used : CAX(org.apache.ignite.internal.util.typedef.CAX) CA(org.apache.ignite.internal.util.typedef.CA)

Example 7 with CA

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");
}
Also used : CAX(org.apache.ignite.internal.util.typedef.CAX) CA(org.apache.ignite.internal.util.typedef.CA)

Example 8 with CA

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());
            }
        });
    }
}
Also used : WeakReference(java.lang.ref.WeakReference) CA(org.apache.ignite.internal.util.typedef.CA)

Example 9 with CA

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());
            }
        }
    });
}
Also used : IgfsImpl(org.apache.ignite.internal.processors.igfs.IgfsImpl) GridCacheAdapter(org.apache.ignite.internal.processors.cache.GridCacheAdapter) IgniteEx(org.apache.ignite.internal.IgniteEx) CA(org.apache.ignite.internal.util.typedef.CA)

Example 10 with CA

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;
}
Also used : GridJavaProcess(org.apache.ignite.internal.util.GridJavaProcess) CountDownLatch(java.util.concurrent.CountDownLatch) CA(org.apache.ignite.internal.util.typedef.CA)

Aggregations

CA (org.apache.ignite.internal.util.typedef.CA)14 Ignite (org.apache.ignite.Ignite)3 CAX (org.apache.ignite.internal.util.typedef.CAX)3 CountDownLatch (java.util.concurrent.CountDownLatch)2 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)2 AtomicReference (java.util.concurrent.atomic.AtomicReference)2 IgniteCache (org.apache.ignite.IgniteCache)2 GridJavaProcess (org.apache.ignite.internal.util.GridJavaProcess)2 IOException (java.io.IOException)1 WeakReference (java.lang.ref.WeakReference)1 Collection (java.util.Collection)1 BrokenBarrierException (java.util.concurrent.BrokenBarrierException)1 CacheException (javax.cache.CacheException)1 IgniteAtomicSequence (org.apache.ignite.IgniteAtomicSequence)1 IgniteCheckedException (org.apache.ignite.IgniteCheckedException)1 IgniteException (org.apache.ignite.IgniteException)1 IgniteInterruptedException (org.apache.ignite.IgniteInterruptedException)1 CachePartialUpdateException (org.apache.ignite.cache.CachePartialUpdateException)1 IgniteEx (org.apache.ignite.internal.IgniteEx)1 IgniteKernal (org.apache.ignite.internal.IgniteKernal)1