Package org.cliffc.high_scale_lib

Examples of org.cliffc.high_scale_lib.Counter


    private final AtomicReference<HashMap<String, Counter>> currentStreamThroughput;


    public ThroughputStats() {
        this.currentThroughput = 0;
        this.throughputCounter = new Counter();
        this.benchmarkCounter = new Counter();
        this.streamThroughput = new AtomicReference<ConcurrentHashMap<String, Counter>>(new ConcurrentHashMap<String, Counter>());
        this.currentStreamThroughput =  new AtomicReference<HashMap<String, Counter>>();

    }
View Full Code Here


        return streamThroughput.getAndSet(new ConcurrentHashMap<String, Counter>());
    }

    public void incrementStreamThroughput(String streamId) {
        final ConcurrentHashMap<String, Counter> counterMap = streamThroughput.get();
        Counter counter;
        synchronized (counterMap) {
            counter = counterMap.get(streamId);
            if (counter == null) {
                counter = new Counter();
                counterMap.put(streamId, counter);
            }
        }
        counter.increment();
    }
View Full Code Here

        final Map<String, Long> result = Maps.newHashMap();
        result.put("throughput", 0L);

        final HashMap<String,Counter> currentStreamThroughput = throughputStats.getCurrentStreamThroughput();
        if (currentStreamThroughput != null) {
            final Counter counter = currentStreamThroughput.get(streamId);
            if (counter != null && isPermitted(RestPermissions.STREAMS_READ, streamId))
                result.put("throughput", counter.get());
        }
        return Response.ok().entity(json(result)).build();
    }
View Full Code Here

    this.counts = new MapMaker().makeComputingMap(
        new Function<String, Counter>() {
          @Override
          public Counter apply(String input) {
            return new Counter();
          }   
        });

    this.lock = new ReentrantReadWriteLock();
    this.topN = topN;
View Full Code Here

  /**
   * Relies on an external lock on {@link #lock} for thread safety.
   */
  private Counter getOrCreateCounter(String type){
    Counter cnt = counts.get(type);
    if (cnt == null){
      cnt = new Counter();
      counts.put(type, cnt);
    }
    return cnt;
  }
View Full Code Here

    this.counts = new MapMaker().makeComputingMap(
        new Function<String, Counter>() {
          @Override
          public Counter apply(String input) {
            return new Counter();
          }   
        });

    this.lock = new ReentrantReadWriteLock();
    this.topN = topN;
View Full Code Here

TOP

Related Classes of org.cliffc.high_scale_lib.Counter

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.