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();
}
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");
}
}
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();
}
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);
}
}
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());
}
Aggregations