Search in sources :

Example 21 with LongAdder8

use of org.jsr166.LongAdder8 in project ignite by apache.

the class GridCircularBufferPerformanceTest method testAdderThroughput.

/**
     * @throws Exception If failed.
     */
public void testAdderThroughput() throws Exception {
    final int size = 256 * 1024;
    final ArrayBlockingQueue<Integer> buf = new ArrayBlockingQueue<>(size);
    final LongAdder8 cnt = new LongAdder8();
    final AtomicBoolean finished = new AtomicBoolean();
    multithreadedAsync(new Callable<Object>() {

        @Override
        public Object call() throws Exception {
            while (!finished.get()) {
                U.sleep(5000);
                info("Ops/sec: " + cnt.sumThenReset() / 5);
            }
            return null;
        }
    }, 1);
    multithreaded(new Callable<Object>() {

        @Override
        public Object call() throws Exception {
            while (!finished.get()) cnt.increment();
            return null;
        }
    }, 8);
    info("Buffer: " + buf);
}
Also used : AtomicBoolean(java.util.concurrent.atomic.AtomicBoolean) ArrayBlockingQueue(java.util.concurrent.ArrayBlockingQueue) LongAdder8(org.jsr166.LongAdder8)

Example 22 with LongAdder8

use of org.jsr166.LongAdder8 in project ignite by apache.

the class GridCacheQuerySimpleBenchmark method testPerformance.

/**
     * @throws Exception If failed.
     */
public void testPerformance() throws Exception {
    Random rnd = new GridRandom();
    final IgniteCache<Long, Person> c = ignite.cache("offheap-cache");
    X.println("___ PUT start");
    final int cnt = 100_000;
    final int maxSalary = cnt / 10;
    for (long i = 0; i < cnt; i++) c.put(i, new Person(rnd.nextInt(maxSalary), "Vasya " + i));
    X.println("___ PUT end");
    final AtomicBoolean end = new AtomicBoolean();
    final LongAdder8 puts = new LongAdder8();
    IgniteInternalFuture<?> fut0 = multithreadedAsync(new Callable<Void>() {

        @Override
        public Void call() throws Exception {
            Random rnd = new GridRandom();
            while (!end.get()) {
                long i = rnd.nextInt(cnt);
                c.put(i, new Person(rnd.nextInt(maxSalary), "Vasya " + i));
                puts.increment();
            }
            return null;
        }
    }, 10);
    final LongAdder8 qrys = new LongAdder8();
    IgniteInternalFuture<?> fut1 = multithreadedAsync(new Callable<Void>() {

        @Override
        public Void call() throws Exception {
            Random rnd = new GridRandom();
            while (!end.get()) {
                int salary = rnd.nextInt(maxSalary);
                c.query(new SqlFieldsQuery("select name from Person where salary = ?").setArgs(salary)).getAll();
                qrys.increment();
            }
            return null;
        }
    }, 10);
    int runTimeSec = 600;
    for (int s = 0; s < runTimeSec; s++) {
        Thread.sleep(1000);
        long puts0 = puts.sum();
        long qrys0 = qrys.sum();
        puts.add(-puts0);
        qrys.add(-qrys0);
        X.println("___ puts: " + puts0 + " qrys: " + qrys0);
    }
    end.set(true);
    fut0.get();
    fut1.get();
    X.println("___ STOP");
}
Also used : IOException(java.io.IOException) SqlFieldsQuery(org.apache.ignite.cache.query.SqlFieldsQuery) AtomicBoolean(java.util.concurrent.atomic.AtomicBoolean) GridRandom(org.apache.ignite.internal.util.GridRandom) Random(java.util.Random) GridRandom(org.apache.ignite.internal.util.GridRandom) LongAdder8(org.jsr166.LongAdder8)

Example 23 with LongAdder8

use of org.jsr166.LongAdder8 in project ignite by apache.

the class GridCacheJdbcBlobStoreMultithreadedSelfTest method checkOpenedClosedCount.

/**
     *
     */
private void checkOpenedClosedCount() {
    assertEquals(GRID_CNT, Ignition.allGrids().size());
    for (Ignite ignite : Ignition.allGrids()) {
        GridCacheContext cctx = ((IgniteKernal) ignite).internalCache(DEFAULT_CACHE_NAME).context();
        CacheStore store = cctx.store().configuredStore();
        long opened = ((LongAdder8) U.field(store, "opened")).sum();
        long closed = ((LongAdder8) U.field(store, "closed")).sum();
        assert opened > 0;
        assert closed > 0;
        assertEquals(opened, closed);
    }
}
Also used : GridCacheContext(org.apache.ignite.internal.processors.cache.GridCacheContext) Ignite(org.apache.ignite.Ignite) CacheStore(org.apache.ignite.cache.store.CacheStore) LongAdder8(org.jsr166.LongAdder8)

Example 24 with LongAdder8

use of org.jsr166.LongAdder8 in project ignite by apache.

the class GridCacheBinaryObjectsAbstractDataStreamerSelfTest method testGetPut.

/**
     * @throws Exception If failed.
     */
@SuppressWarnings("BusyWait")
public void testGetPut() throws Exception {
    final AtomicBoolean flag = new AtomicBoolean();
    final LongAdder8 cnt = new LongAdder8();
    try (IgniteDataStreamer<Object, Object> ldr = grid(0).dataStreamer(DEFAULT_CACHE_NAME)) {
        IgniteInternalFuture<?> f = multithreadedAsync(new Callable<Object>() {

            @Override
            public Object call() throws Exception {
                ThreadLocalRandom rnd = ThreadLocalRandom.current();
                while (!flag.get()) {
                    ldr.addData(rnd.nextInt(10000), new TestObject(rnd.nextInt(10000)));
                    cnt.add(1);
                }
                return null;
            }
        }, THREAD_CNT);
        for (int i = 0; i < 30 && !f.isDone(); i++) Thread.sleep(1000);
        flag.set(true);
        f.get();
    }
    info("Operations in 30 sec: " + cnt.sum());
}
Also used : AtomicBoolean(java.util.concurrent.atomic.AtomicBoolean) ThreadLocalRandom(java.util.concurrent.ThreadLocalRandom) LongAdder8(org.jsr166.LongAdder8) BinaryObjectException(org.apache.ignite.binary.BinaryObjectException)

Aggregations

LongAdder8 (org.jsr166.LongAdder8)24 AtomicBoolean (java.util.concurrent.atomic.AtomicBoolean)15 IgniteCheckedException (org.apache.ignite.IgniteCheckedException)6 UUID (java.util.UUID)5 ExecutorService (java.util.concurrent.ExecutorService)5 Random (java.util.Random)4 ThreadLocalRandom (java.util.concurrent.ThreadLocalRandom)4 ClusterNode (org.apache.ignite.cluster.ClusterNode)4 IgniteUuid (org.apache.ignite.lang.IgniteUuid)4 ArrayList (java.util.ArrayList)3 Date (java.util.Date)3 Callable (java.util.concurrent.Callable)3 Ignite (org.apache.ignite.Ignite)3 IgniteKernal (org.apache.ignite.internal.IgniteKernal)3 GridIoManager (org.apache.ignite.internal.managers.communication.GridIoManager)3 GridMessageListener (org.apache.ignite.internal.managers.communication.GridMessageListener)3 Message (org.apache.ignite.plugin.extensions.communication.Message)3 ConcurrentLinkedDeque8 (org.jsr166.ConcurrentLinkedDeque8)3 IOException (java.io.IOException)2 Timer (java.util.Timer)2