Search in sources :

Example 61 with LongAdder

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

the class CreativeProbe method getMap.

public List getMap() {
    Map x = new HashMap();
    List list = new ArrayList();
    for (Map.Entry<String, LongAdder> entry : probes.entrySet()) {
        String key = entry.getKey();
        x = new HashMap();
        x.put("name", key);
        x.put("count", entry.getValue().sum());
        list.add(x);
    }
    return list;
}
Also used : LongAdder(java.util.concurrent.atomic.LongAdder) HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) List(java.util.List) ArrayList(java.util.ArrayList) Map(java.util.Map) HashMap(java.util.HashMap)

Example 62 with LongAdder

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

the class CreativeProbe method reset.

public void reset() {
    probes = new HashMap();
    total = new LongAdder();
    bid = new LongAdder();
}
Also used : LongAdder(java.util.concurrent.atomic.LongAdder) HashMap(java.util.HashMap)

Example 63 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 64 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 65 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)

Aggregations

LongAdder (java.util.concurrent.atomic.LongAdder)65 Random (java.util.Random)9 SplittableRandom (java.util.SplittableRandom)9 ThreadLocalRandom (java.util.concurrent.ThreadLocalRandom)9 HashMap (java.util.HashMap)6 Theory (org.junit.experimental.theories.Theory)6 Map (java.util.Map)5 Metric (org.springframework.boot.actuate.metrics.Metric)5 HashSet (java.util.HashSet)3 ExecutorService (java.util.concurrent.ExecutorService)3 Future (java.util.concurrent.Future)3 ConcurrentModificationException (java.util.ConcurrentModificationException)2 NoSuchElementException (java.util.NoSuchElementException)2 Set (java.util.Set)2 AtomicLong (java.util.concurrent.atomic.AtomicLong)2 Deferred (org.osgi.util.promise.Deferred)2 ArrayList (java.util.ArrayList)1 List (java.util.List)1 ConcurrentHashMap (java.util.concurrent.ConcurrentHashMap)1 ConcurrentMap (java.util.concurrent.ConcurrentMap)1