当前位置: 首页>>代码示例>>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;未经允许,请勿转载。