本文整理匯總了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);
}