當前位置: 首頁>>代碼示例>>Java>>正文


Java Counter.dec方法代碼示例

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

}
 
開發者ID:yangfuhai,項目名稱:jboot,代碼行數:19,代碼來源:JbootMetricConterAopInterceptor.java

示例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.
}
 
開發者ID:spotify,項目名稱:semantic-metrics,代碼行數:26,代碼來源:MetricTypesExample.java

示例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();
    }
}
 
開發者ID:HydAu,項目名稱:Camel,代碼行數:17,代碼來源:CounterProducer.java

示例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);
    }
}
 
開發者ID:Nike-Inc,項目名稱:riposte,代碼行數:9,代碼來源:CodahaleMetricsCollector.java

示例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();
        }
    }
}
 
開發者ID:baharclerode,項目名稱:dropwizard-hk2,代碼行數:12,代碼來源:CountedInterceptorFactory.java

示例6: testCounterDec

import com.codahale.metrics.Counter; //導入方法依賴的package包/類
@Test
public void testCounterDec() throws Exception {
  Counter counter = registry.counter("C3");
  counter.dec();
  assertEquals(counter, updatedMetric);
}
 
開發者ID:ApptuitAI,項目名稱:JInsight,代碼行數:7,代碼來源:TracingMetricRegistryTest.java

示例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);
}
 
開發者ID:ApptuitAI,項目名稱:JInsight,代碼行數:7,代碼來源:TracingMetricRegistryTest.java


注:本文中的com.codahale.metrics.Counter.dec方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。