Search in sources :

Example 81 with LongAdder

use of java.util.concurrent.atomic.LongAdder in project XRTB by benmfaul.

the class CreativeProbe method process.

public void process(StringBuilder br) {
    String key = br.toString();
    LongAdder ad = probes.get(key);
    if (ad == null) {
        ad = new LongAdder();
        probes.put(key, ad);
    }
    ad.increment();
    total.increment();
}
Also used : LongAdder(java.util.concurrent.atomic.LongAdder)

Example 82 with LongAdder

use of java.util.concurrent.atomic.LongAdder in project XRTB by benmfaul.

the class CreativeProbe method reportCsv.

public void reportCsv(StringBuilder sb, String pre) {
    pre = pre + creative + "," + total.sum() + ", " + bid.sum();
    for (Map.Entry<String, LongAdder> entry : probes.entrySet()) {
        String key = "\"" + entry.getKey().trim() + "\"";
        LongAdder ad = entry.getValue();
        sb.append(pre + "," + key + "," + total.sum() + "," + ad.sum() + "\n");
    }
}
Also used : LongAdder(java.util.concurrent.atomic.LongAdder) Map(java.util.Map) HashMap(java.util.HashMap)

Example 83 with LongAdder

use of java.util.concurrent.atomic.LongAdder in project XRTB by benmfaul.

the class ExchangeProbe method reset.

/**
	 * Reset the probe for the exchange. Sets total and bids to 0 and then resets the campaign probes.
	 */
public void reset() {
    for (Map.Entry<String, CampaignProbe> entry : probes.entrySet()) {
        entry.getValue().reset();
    }
    total = new LongAdder();
    bids = new LongAdder();
}
Also used : LongAdder(java.util.concurrent.atomic.LongAdder) Map(java.util.Map) HashMap(java.util.HashMap)

Example 84 with LongAdder

use of java.util.concurrent.atomic.LongAdder 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 = ((LongAdder) U.field(store, "opened")).sum();
        long closed = ((LongAdder) U.field(store, "closed")).sum();
        assert opened > 0;
        assert closed > 0;
        assertEquals(opened, closed);
    }
}
Also used : GridCacheContext(org.apache.ignite.internal.processors.cache.GridCacheContext) LongAdder(java.util.concurrent.atomic.LongAdder) Ignite(org.apache.ignite.Ignite) CacheStore(org.apache.ignite.cache.store.CacheStore)

Example 85 with LongAdder

use of java.util.concurrent.atomic.LongAdder 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 LongAdder cnt = new LongAdder();
    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) LongAdder(java.util.concurrent.atomic.LongAdder) ThreadLocalRandom(java.util.concurrent.ThreadLocalRandom) BinaryObjectException(org.apache.ignite.binary.BinaryObjectException)

Aggregations

LongAdder (java.util.concurrent.atomic.LongAdder)92 ThreadLocalRandom (java.util.concurrent.ThreadLocalRandom)16 AtomicBoolean (java.util.concurrent.atomic.AtomicBoolean)16 Random (java.util.Random)13 ExecutorService (java.util.concurrent.ExecutorService)10 SplittableRandom (java.util.SplittableRandom)9 HashMap (java.util.HashMap)7 Map (java.util.Map)6 IgniteCheckedException (org.apache.ignite.IgniteCheckedException)6 Theory (org.junit.experimental.theories.Theory)6 UUID (java.util.UUID)5 ArrayList (java.util.ArrayList)4 ConcurrentHashMap (java.util.concurrent.ConcurrentHashMap)4 Ignite (org.apache.ignite.Ignite)4 IgniteUuid (org.apache.ignite.lang.IgniteUuid)4 Metric (org.springframework.boot.actuate.metrics.Metric)4 Date (java.util.Date)3 HashSet (java.util.HashSet)3 Callable (java.util.concurrent.Callable)3 CountDownLatch (java.util.concurrent.CountDownLatch)3