Java Code Examples for org.apache.bookkeeper.stats.Counter#inc()

The following examples show how to use org.apache.bookkeeper.stats.Counter#inc() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: StreamImpl.java    From distributedlog with Apache License 2.0 5 votes vote down vote up
void countException(Throwable t, StatsLogger streamExceptionLogger) {
    String exceptionName = null == t ? "null" : t.getClass().getName();
    Counter counter = exceptionCounters.get(exceptionName);
    if (null == counter) {
        counter = exceptionStatLogger.getCounter(exceptionName);
        Counter oldCounter = exceptionCounters.putIfAbsent(exceptionName, counter);
        if (null != oldCounter) {
            counter = oldCounter;
        }
    }
    counter.inc();
    streamExceptionLogger.getCounter(exceptionName).inc();
}
 
Example 2
Source File: DistributedLogServiceImpl.java    From distributedlog with Apache License 2.0 5 votes vote down vote up
private void countStatusCode(StatusCode code) {
    Counter counter = statusCodeCounters.get(code);
    if (null == counter) {
        counter = statusCodeStatLogger.getCounter(code.name());
        Counter oldCounter = statusCodeCounters.putIfAbsent(code, counter);
        if (null != oldCounter) {
            counter = oldCounter;
        }
    }
    counter.inc();
    statusCodeTotal.inc();
}
 
Example 3
Source File: BroadCastStatsLogger.java    From distributedlog with Apache License 2.0 5 votes vote down vote up
@Override
public Counter getCounter(final String statName) {
    final Counter firstCounter = first.getCounter(statName);
    final Counter secondCounter = second.getCounter(statName);
    return new Counter() {
        @Override
        public void clear() {
            firstCounter.clear();
            secondCounter.clear();
        }

        @Override
        public void inc() {
            firstCounter.inc();
            secondCounter.inc();
        }

        @Override
        public void dec() {
            firstCounter.dec();
            secondCounter.dec();
        }

        @Override
        public void add(long l) {
            firstCounter.add(l);
            secondCounter.add(l);
        }

        @Override
        public Long get() {
            // Eventually consistent.
            return firstCounter.get();
        }
    };
}
 
Example 4
Source File: BroadCastStatsLogger.java    From distributedlog with Apache License 2.0 5 votes vote down vote up
@Override
public Counter getCounter(final String statName) {
    final Counter firstCounter = first.getCounter(statName);
    final Counter secondCounter = second.getCounter(statName);
    return new Counter() {
        @Override
        public void clear() {
            firstCounter.clear();
            secondCounter.clear();
        }

        @Override
        public void inc() {
            firstCounter.inc();
            secondCounter.inc();
        }

        @Override
        public void dec() {
            firstCounter.dec();
            secondCounter.dec();
        }

        @Override
        public void add(long l) {
            firstCounter.add(l);
            secondCounter.add(l);
        }

        @Override
        public Long get() {
            // Eventually consistent.
            return firstCounter.get();
        }
    };
}
 
Example 5
Source File: StreamImpl.java    From distributedlog with Apache License 2.0 5 votes vote down vote up
void countException(Throwable t, StatsLogger streamExceptionLogger) {
    String exceptionName = null == t ? "null" : t.getClass().getName();
    Counter counter = exceptionCounters.get(exceptionName);
    if (null == counter) {
        counter = exceptionStatLogger.getCounter(exceptionName);
        Counter oldCounter = exceptionCounters.putIfAbsent(exceptionName, counter);
        if (null != oldCounter) {
            counter = oldCounter;
        }
    }
    counter.inc();
    streamExceptionLogger.getCounter(exceptionName).inc();
}
 
Example 6
Source File: DistributedLogServiceImpl.java    From distributedlog with Apache License 2.0 5 votes vote down vote up
private void countStatusCode(StatusCode code) {
    Counter counter = statusCodeCounters.get(code);
    if (null == counter) {
        counter = statusCodeStatLogger.getCounter(code.name());
        Counter oldCounter = statusCodeCounters.putIfAbsent(code, counter);
        if (null != oldCounter) {
            counter = oldCounter;
        }
    }
    counter.inc();
    statusCodeTotal.inc();
}