本文整理了Java中com.codahale.metrics.Counter.getCount()
方法的一些代码示例,展示了Counter.getCount()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Counter.getCount()
方法的具体详情如下:
包路径:com.codahale.metrics.Counter
类名称:Counter
方法名:getCount
[英]Returns the counter's current value.
[中]返回计数器的当前值。
代码示例来源:origin: Graylog2/graylog2-server
public long getSize() {
return sizeCounter.getCount();
}
代码示例来源:origin: resilience4j/resilience4j
@Override
public long getNumberOfFailedCalls() {
return failedCallsCounter.getCount();
}
代码示例来源:origin: resilience4j/resilience4j
@Override
public long getNumberOfTotalCalls() {
return totalCallsCounter.getCount();
}
代码示例来源:origin: alibaba/jstorm
/**
* {@inheritDoc}
*/
@VisibleForTesting
public Object getValue(Integer win) {
synchronized (this) {
return unFlushed.getCount() + counterMap.get(win).getCount();
}
}
代码示例来源:origin: apache/kylin
@Override
public Long incrementCounter(String name, long increment) {
String key = name;
try {
countersLock.lock();
counters.get(key).inc(increment);
return counters.get(key).getCount();
} catch (ExecutionException ee) {
throw new IllegalStateException("Error retrieving counter from the metric registry ", ee);
} finally {
countersLock.unlock();
}
}
代码示例来源:origin: thinkaurelius/titan
public void verifyStoreMetrics(String storeName, String prefix, Map<String, Long> operationCounts) {
for (String operation : OPERATION_NAMES) {
Long count = operationCounts.get(operation);
if (count==null) count = 0l;
assertEquals(Joiner.on(".").join(prefix, storeName, operation, MetricInstrumentedStore.M_CALLS),count.longValue(), metric.getCounter(prefix, storeName, operation, MetricInstrumentedStore.M_CALLS).getCount());
}
}
代码示例来源:origin: apache/hive
@Override
public Long decrementCounter(String name, long decrement) {
String key = name;
try {
countersLock.lock();
counters.get(key).dec(decrement);
return counters.get(key).getCount();
} catch(ExecutionException ee) {
throw new IllegalStateException("Error retrieving counter from the metric registry ", ee);
} finally {
countersLock.unlock();
}
}
代码示例来源:origin: Alluxio/alluxio
/**
* Resets all the counters to 0 for testing.
*/
public static void resetAllCounters() {
for (Map.Entry<String, Counter> entry : METRIC_REGISTRY.getCounters().entrySet()) {
entry.getValue().dec(entry.getValue().getCount());
}
}
代码示例来源:origin: Graylog2/graylog2-server
/**
* Assign the given stream to this message.
*
* @param stream the stream to route this message into
*/
public void addStream(Stream stream) {
indexSets.add(stream.getIndexSet());
if (streams.add(stream)) {
sizeCounter.inc(8);
if (LOG.isTraceEnabled()) {
LOG.trace("[Message size update][{}] stream added: {}", getId(), sizeCounter.getCount());
}
}
}
代码示例来源:origin: JanusGraph/janusgraph
public void verifyStoreMetrics(String storeName, String prefix, Map<String, Long> operationCounts) {
for (String operation : OPERATION_NAMES) {
Long count = operationCounts.get(operation);
if (count==null) count = 0L;
assertEquals(Joiner.on(".").join(prefix, storeName, operation, MetricInstrumentedStore.M_CALLS),count.longValue(), metric.getCounter(prefix, storeName, operation, MetricInstrumentedStore.M_CALLS).getCount());
}
}
代码示例来源:origin: thinkaurelius/titan
private long getEdgeCacheRetrievals() {
return metric.getCounter(metricsPrefix, EDGESTORE_NAME + METRICS_CACHE_SUFFIX, CacheMetricsAction.RETRIEVAL.getName()).getCount();
}
代码示例来源:origin: thinkaurelius/titan
private long getEdgeCacheMisses() {
return metric.getCounter(metricsPrefix, EDGESTORE_NAME + METRICS_CACHE_SUFFIX, CacheMetricsAction.MISS.getName()).getCount();
}
代码示例来源:origin: alibaba/jstorm
@Override
protected void updateSnapshot(int window) {
Counter counter = counterMap.get(window);
if (counter != null) {
AsmSnapshot snapshot = new AsmCounterSnapshot().setValue(counter.getCount())
.setTs(System.currentTimeMillis()).setMetricId(metricId);
snapshots.put(window, snapshot);
}
}
代码示例来源:origin: thinkaurelius/titan
private void resetEdgeCacheCounts() {
Counter counter = metric.getCounter(metricsPrefix, EDGESTORE_NAME + METRICS_CACHE_SUFFIX, CacheMetricsAction.RETRIEVAL.getName());
counter.dec(counter.getCount());
counter = metric.getCounter(metricsPrefix, EDGESTORE_NAME + METRICS_CACHE_SUFFIX, CacheMetricsAction.MISS.getName());
counter.dec(counter.getCount());
}
代码示例来源:origin: thinkaurelius/titan
public void verifyTypeCacheMetrics(String prefix, int nameMisses, int relationMisses) {
// assertEquals("On type cache name retrievals",nameRetrievals, metric.getCounter(GraphDatabaseConfiguration.METRICS_SYSTEM_PREFIX_DEFAULT, METRICS_NAME, METRICS_TYPENAME, CacheMetricsAction.RETRIEVAL.getName()).getCount());
assertEquals("On type cache name misses",nameMisses, metric.getCounter(GraphDatabaseConfiguration.METRICS_SYSTEM_PREFIX_DEFAULT, METRICS_NAME, METRICS_TYPENAME, CacheMetricsAction.MISS.getName()).getCount());
assertTrue(nameMisses <= metric.getCounter(GraphDatabaseConfiguration.METRICS_SYSTEM_PREFIX_DEFAULT, METRICS_NAME, METRICS_TYPENAME, CacheMetricsAction.RETRIEVAL.getName()).getCount());
// assertEquals("On type cache relation retrievals",relationRetrievals, metric.getCounter(GraphDatabaseConfiguration.METRICS_SYSTEM_PREFIX_DEFAULT, METRICS_NAME, METRICS_RELATIONS, CacheMetricsAction.RETRIEVAL.getName()).getCount());
assertEquals("On type cache relation misses", relationMisses, metric.getCounter(GraphDatabaseConfiguration.METRICS_SYSTEM_PREFIX_DEFAULT, METRICS_NAME, METRICS_RELATIONS, CacheMetricsAction.MISS.getName()).getCount());
assertTrue(relationMisses <= metric.getCounter(GraphDatabaseConfiguration.METRICS_SYSTEM_PREFIX_DEFAULT, METRICS_NAME, METRICS_RELATIONS, CacheMetricsAction.RETRIEVAL.getName()).getCount());
}
代码示例来源:origin: JanusGraph/janusgraph
public void verifyTypeCacheMetrics(String prefix, int nameMisses, int relationMisses) {
// assertEquals("On type cache name retrievals",nameRetrievals, metric.getCounter(GraphDatabaseConfiguration.METRICS_SYSTEM_PREFIX_DEFAULT, METRICS_NAME, METRICS_TYPENAME, CacheMetricsAction.RETRIEVAL.getName()).getCount());
assertEquals("On type cache name misses",nameMisses, metric.getCounter(GraphDatabaseConfiguration.METRICS_SYSTEM_PREFIX_DEFAULT, METRICS_NAME, METRICS_TYPENAME, CacheMetricsAction.MISS.getName()).getCount());
assertTrue(nameMisses <= metric.getCounter(GraphDatabaseConfiguration.METRICS_SYSTEM_PREFIX_DEFAULT, METRICS_NAME, METRICS_TYPENAME, CacheMetricsAction.RETRIEVAL.getName()).getCount());
// assertEquals("On type cache relation retrievals",relationRetrievals, metric.getCounter(GraphDatabaseConfiguration.METRICS_SYSTEM_PREFIX_DEFAULT, METRICS_NAME, METRICS_RELATIONS, CacheMetricsAction.RETRIEVAL.getName()).getCount());
assertEquals("On type cache relation misses", relationMisses, metric.getCounter(GraphDatabaseConfiguration.METRICS_SYSTEM_PREFIX_DEFAULT, METRICS_NAME, METRICS_RELATIONS, CacheMetricsAction.MISS.getName()).getCount());
assertTrue(relationMisses <= metric.getCounter(GraphDatabaseConfiguration.METRICS_SYSTEM_PREFIX_DEFAULT, METRICS_NAME, METRICS_RELATIONS, CacheMetricsAction.RETRIEVAL.getName()).getCount());
}
代码示例来源:origin: JanusGraph/janusgraph
private void resetEdgeCacheCounts() {
Counter counter = metric.getCounter(metricsPrefix, EDGESTORE_NAME + METRICS_CACHE_SUFFIX, CacheMetricsAction.RETRIEVAL.getName());
counter.dec(counter.getCount());
counter = metric.getCounter(metricsPrefix, EDGESTORE_NAME + METRICS_CACHE_SUFFIX, CacheMetricsAction.MISS.getName());
counter.dec(counter.getCount());
}
代码示例来源:origin: spotify/helios
private void reportCounter(String name, Counter counter) {
final Metric metric = createMetric(name, "counter")
.value(counter.getCount());
send(metric);
}
代码示例来源:origin: apache/hive
private void verifyThatWaitingCompileOpsCountIsEqualTo(long count) {
Counter counter = getCounter(WAITING_COMPILE_OPS);
assertNotNull(counter);
assertThat(counter.getCount(), is(equalTo(count)));
}
代码示例来源:origin: apache/hive
@Test
public void testCount() throws Exception {
int runs = 5;
for (int i = 0; i < runs; i++) {
MetricsFactory.getInstance().incrementCounter("count1");
Counter counter = metricRegistry.getCounters().get("count1");
Assert.assertEquals(i + 1, counter.getCount());
}
}
内容来源于网络,如有侵权,请联系作者删除!