org.apache.bookkeeper.stats.Counter Java Examples
The following examples show how to use
org.apache.bookkeeper.stats.Counter.
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: BKExceptionStatsLogger.java From distributedlog with Apache License 2.0 | 6 votes |
public Counter getExceptionCounter(int rc) { Counter counter = exceptionCounters.get(rc); if (null != counter) { return counter; } // TODO: it would be better to have BKException.Code.get(rc) synchronized (exceptionCounters) { counter = exceptionCounters.get(rc); if (null != counter) { return counter; } counter = parentLogger.getCounter(getMessage(rc)); exceptionCounters.put(rc, counter); } return counter; }
Example #2
Source File: PrometheusTextFormatUtil.java From pulsar with Apache License 2.0 | 5 votes |
static void writeCounter(Writer w, String name, String cluster, Counter counter) { // Example: // # TYPE jvm_threads_started_total counter // jvm_threads_started_total{cluster="test"} 59 try { w.append("# TYPE ").append(name).append(" counter\n"); w.append(name).append("{cluster=\"").append(cluster).append("\"}") .append(' ').append(counter.get().toString()).append('\n'); } catch (IOException e) { throw new RuntimeException(e); } }
Example #3
Source File: DistributedLogServiceImpl.java From distributedlog with Apache License 2.0 | 5 votes |
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 #4
Source File: StreamImpl.java From distributedlog with Apache License 2.0 | 5 votes |
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 #5
Source File: StreamImpl.java From distributedlog with Apache License 2.0 | 5 votes |
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 |
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 #7
Source File: BroadCastStatsLogger.java From distributedlog with Apache License 2.0 | 5 votes |
@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 #8
Source File: BroadCastStatsLogger.java From distributedlog with Apache License 2.0 | 5 votes |
@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 #9
Source File: BKExceptionStatsLogger.java From distributedlog with Apache License 2.0 | 4 votes |
public BKExceptionStatsLogger(StatsLogger parentLogger) { this.parentLogger = parentLogger; this.exceptionCounters = new HashMap<Integer, Counter>(); }
Example #10
Source File: PrometheusStatsLogger.java From pulsar with Apache License 2.0 | 4 votes |
@Override public Counter getCounter(String name) { return provider.counters.computeIfAbsent(completeName(name), x -> new LongAdderCounter()); }
Example #11
Source File: StreamOpStats.java From distributedlog with Apache License 2.0 | 4 votes |
public Counter streamRequestCounter(String streamName, String opName, String counterName) { return streamRequestScope(streamName, opName).getCounter(counterName); }
Example #12
Source File: StreamOpStats.java From distributedlog with Apache License 2.0 | 4 votes |
public Counter recordsCounter(String counterName) { return recordsStatsLogger.getCounter(counterName); }
Example #13
Source File: StreamOpStats.java From distributedlog with Apache License 2.0 | 4 votes |
public Counter requestDeniedCounter(String counterName) { return requestDeniedStatsLogger.getCounter(counterName); }
Example #14
Source File: StreamOpStats.java From distributedlog with Apache License 2.0 | 4 votes |
public Counter requestPendingCounter(String counterName) { return requestCounter(counterName); }
Example #15
Source File: StreamOpStats.java From distributedlog with Apache License 2.0 | 4 votes |
public Counter requestCounter(String counterName) { return requestStatsLogger.getCounter(counterName); }
Example #16
Source File: StreamOpStats.java From distributedlog with Apache License 2.0 | 4 votes |
public Counter scopedRequestCounter(String opName, String counterName) { return requestScope(opName).getCounter(counterName); }
Example #17
Source File: StreamOpStats.java From distributedlog with Apache License 2.0 | 4 votes |
public Counter baseCounter(String opName) { return baseStatsLogger.getCounter(opName); }
Example #18
Source File: CounterAdaptor.java From openmessaging-benchmark with Apache License 2.0 | 4 votes |
CounterAdaptor(Counter counter) { this.counter = counter; }
Example #19
Source File: StreamOpStats.java From distributedlog with Apache License 2.0 | 4 votes |
public Counter streamRequestCounter(Partition partition, String opName, String counterName) { return streamRequestScope(partition, opName).getCounter(counterName); }
Example #20
Source File: StreamOpStats.java From distributedlog with Apache License 2.0 | 4 votes |
public Counter recordsCounter(String counterName) { return recordsStatsLogger.getCounter(counterName); }
Example #21
Source File: StreamOpStats.java From distributedlog with Apache License 2.0 | 4 votes |
public Counter requestDeniedCounter(String counterName) { return requestDeniedStatsLogger.getCounter(counterName); }
Example #22
Source File: StreamOpStats.java From distributedlog with Apache License 2.0 | 4 votes |
public Counter requestPendingCounter(String counterName) { return requestCounter(counterName); }
Example #23
Source File: StreamOpStats.java From distributedlog with Apache License 2.0 | 4 votes |
public Counter requestCounter(String counterName) { return requestStatsLogger.getCounter(counterName); }
Example #24
Source File: StreamOpStats.java From distributedlog with Apache License 2.0 | 4 votes |
public Counter scopedRequestCounter(String opName, String counterName) { return requestScope(opName).getCounter(counterName); }
Example #25
Source File: StreamOpStats.java From distributedlog with Apache License 2.0 | 4 votes |
public Counter baseCounter(String opName) { return baseStatsLogger.getCounter(opName); }