本文整理汇总了Java中com.codahale.metrics.Counter.dec方法的典型用法代码示例。如果您正苦于以下问题:Java Counter.dec方法的具体用法?Java Counter.dec怎么用?Java Counter.dec使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.codahale.metrics.Counter
的用法示例。
在下文中一共展示了Counter.dec方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: invoke
import com.codahale.metrics.Counter; //导入方法依赖的package包/类
@Override
public Object invoke(MethodInvocation methodInvocation) throws Throwable {
EnableMetricCounter annotation = methodInvocation.getThis().getClass().getAnnotation(EnableMetricCounter.class);
String name = StringUtils.isBlank(annotation.value())
? methodInvocation.getThis().getClass().getName() + "." + methodInvocation.getMethod().getName()
: annotation.value();
Counter counter = Jboot.me().getMetric().counter(name);
try {
counter.inc();
return methodInvocation.proceed();
} finally {
counter.dec();
}
}
示例2: reportCounter
import com.codahale.metrics.Counter; //导入方法依赖的package包/类
/**
* A counter is just a gauge for an AtomicLong instance. You can increment or decrement its
* value. We want a more efficient way of measuring the pending job in a queue
*/
private static void reportCounter() {
// Create or fetch (if it is already created) the metric.
final Counter counter = registry.counter(APP_PREFIX.tagged("what", "job-count"));
// Somewhere in your code where you are adding new jobs to the queue you increment the
// counter as well
counter.inc();
// Oh look! Another job!
counter.inc();
// Somewhere in your code the job is going to be removed from the queue you decrement the
// counter
counter.dec();
// That's it! The rest will be automatically done inside semantic metrics library. The
// reported measurements will be kept in the registry.
// Every time the reporter wants to report, the current value of the counter will be read
// and
// a datapoint will be created and reported.
}
示例3: doProcess
import com.codahale.metrics.Counter; //导入方法依赖的package包/类
@Override
protected void doProcess(Exchange exchange, MetricsEndpoint endpoint, MetricRegistry registry, String metricsName) throws Exception {
Message in = exchange.getIn();
Counter counter = registry.counter(metricsName);
Long increment = endpoint.getIncrement();
Long decrement = endpoint.getDecrement();
Long finalIncrement = getLongHeader(in, HEADER_COUNTER_INCREMENT, increment);
Long finalDecrement = getLongHeader(in, HEADER_COUNTER_DECREMENT, decrement);
if (finalIncrement != null) {
counter.inc(finalIncrement);
} else if (finalDecrement != null) {
counter.dec(finalDecrement);
} else {
counter.inc();
}
}
示例4: processCounter
import com.codahale.metrics.Counter; //导入方法依赖的package包/类
protected static void processCounter(Counter counter, long delta) {
if (delta > 0) {
counter.inc(delta);
}
else if (delta < 0) {
counter.dec(delta * -1);
}
}
示例5: count
import com.codahale.metrics.Counter; //导入方法依赖的package包/类
protected Object count(Executable executable, Counted annotation, Invocation invocation) throws Throwable {
Counter counter = getCounter(executable);
try {
counter.inc();
return invocation.proceed();
} finally {
if (!annotation.monotonic()) {
counter.dec();
}
}
}
示例6: testCounterDec
import com.codahale.metrics.Counter; //导入方法依赖的package包/类
@Test
public void testCounterDec() throws Exception {
Counter counter = registry.counter("C3");
counter.dec();
assertEquals(counter, updatedMetric);
}
示例7: testCounterDecInt
import com.codahale.metrics.Counter; //导入方法依赖的package包/类
@Test
public void testCounterDecInt() throws Exception {
Counter counter = registry.counter("C4");
counter.dec(10);
assertEquals(counter, updatedMetric);
}