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


Java Counter.getCount方法代碼示例

本文整理匯總了Java中com.codahale.metrics.Counter.getCount方法的典型用法代碼示例。如果您正苦於以下問題:Java Counter.getCount方法的具體用法?Java Counter.getCount怎麽用?Java Counter.getCount使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在com.codahale.metrics.Counter的用法示例。


在下文中一共展示了Counter.getCount方法的9個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: taskStatuses

import com.codahale.metrics.Counter; //導入方法依賴的package包/類
@Test
public void taskStatuses() {
    Counter runningCounter = Metrics.getRegistry().counter("task_status.task_running");
    Counter lostCounter = Metrics.getRegistry().counter("task_status.task_lost");

    long runningVal = runningCounter.getCount();
    Metrics.record(Protos.TaskStatus.newBuilder()
            .setState(Protos.TaskState.TASK_RUNNING)
            .setTaskId(TestConstants.TASK_ID)
            .build());
    Assert.assertEquals(1, runningCounter.getCount() - runningVal);

    long lostVal = lostCounter.getCount();
    Metrics.record(Protos.TaskStatus.newBuilder()
            .setState(Protos.TaskState.TASK_LOST)
            .setTaskId(TestConstants.TASK_ID)
            .build());
    Assert.assertEquals(1, lostCounter.getCount() - lostVal);
}
 
開發者ID:mesosphere,項目名稱:dcos-commons,代碼行數:20,代碼來源:MetricsTest.java

示例2: taskLaunches

import com.codahale.metrics.Counter; //導入方法依賴的package包/類
@Test
public void taskLaunches() throws Exception {
    OfferRecommendation realRecommendation = getRecommendation(true);
    Assert.assertTrue(((LaunchOfferRecommendation)realRecommendation).shouldLaunch());

    OfferRecommendation suppressedRecommendation = getRecommendation(false);
    Assert.assertFalse(((LaunchOfferRecommendation)suppressedRecommendation).shouldLaunch());

    Counter launchCounter = Metrics.getRegistry().counter("operation.launch_group");

    long val = launchCounter.getCount();
    Metrics.OperationsCounter.getInstance().record(realRecommendation);
    Metrics.OperationsCounter.getInstance().record(realRecommendation);
    Metrics.OperationsCounter.getInstance().record(realRecommendation);
    Assert.assertEquals(3, launchCounter.getCount() - val);

    val = launchCounter.getCount();
    Metrics.OperationsCounter.getInstance().record(suppressedRecommendation);
    Metrics.OperationsCounter.getInstance().record(suppressedRecommendation);
    Assert.assertEquals(0, launchCounter.getCount() - val);
}
 
開發者ID:mesosphere,項目名稱:dcos-commons,代碼行數:22,代碼來源:MetricsTest.java

示例3: incrementReceivedOffers

import com.codahale.metrics.Counter; //導入方法依賴的package包/類
@Test
public void incrementReceivedOffers() {
    Counter counter = Metrics.getRegistry().counter(Metrics.RECEIVED_OFFERS);
    long val = counter.getCount();
    Metrics.incrementReceivedOffers(5);
    Assert.assertEquals(5, counter.getCount() - val);
}
 
開發者ID:mesosphere,項目名稱:dcos-commons,代碼行數:8,代碼來源:MetricsTest.java

示例4: incrementProcessedOffers

import com.codahale.metrics.Counter; //導入方法依賴的package包/類
@Test
public void incrementProcessedOffers() {
    Counter counter = Metrics.getRegistry().counter(Metrics.PROCESSED_OFFERS);
    long val = counter.getCount();
    Metrics.incrementProcessedOffers(5);
    Assert.assertEquals(5, counter.getCount() - val);
}
 
開發者ID:mesosphere,項目名稱:dcos-commons,代碼行數:8,代碼來源:MetricsTest.java

示例5: incrementRevives

import com.codahale.metrics.Counter; //導入方法依賴的package包/類
@Test
public void incrementRevives() {
    Counter counter = Metrics.getRegistry().counter(Metrics.REVIVES);
    long val = counter.getCount();
    Metrics.incrementRevives();
    Assert.assertEquals(1, counter.getCount() - val);
}
 
開發者ID:mesosphere,項目名稱:dcos-commons,代碼行數:8,代碼來源:MetricsTest.java

示例6: incrementReviveThrottles

import com.codahale.metrics.Counter; //導入方法依賴的package包/類
@Test
public void incrementReviveThrottles() {
    Counter counter = Metrics.getRegistry().counter(Metrics.REVIVE_THROTTLES);
    long val = counter.getCount();
    Metrics.incrementReviveThrottles();
    Assert.assertEquals(1, counter.getCount() - val);
}
 
開發者ID:mesosphere,項目名稱:dcos-commons,代碼行數:8,代碼來源:MetricsTest.java

示例7: incrementDeclinesShort

import com.codahale.metrics.Counter; //導入方法依賴的package包/類
@Test
public void incrementDeclinesShort() {
    Counter counter = Metrics.getRegistry().counter(Metrics.DECLINE_SHORT);
    long val = counter.getCount();
    Metrics.incrementDeclinesShort(5);
    Assert.assertEquals(5, counter.getCount() - val);
}
 
開發者ID:mesosphere,項目名稱:dcos-commons,代碼行數:8,代碼來源:MetricsTest.java

示例8: incrementDeclinesLong

import com.codahale.metrics.Counter; //導入方法依賴的package包/類
@Test
public void incrementDeclinesLong() {
    Counter counter = Metrics.getRegistry().counter(Metrics.DECLINE_LONG);
    long val = counter.getCount();
    Metrics.incrementDeclinesLong(5);
    Assert.assertEquals(5, counter.getCount() - val);
}
 
開發者ID:mesosphere,項目名稱:dcos-commons,代碼行數:8,代碼來源:MetricsTest.java

示例9: report

import com.codahale.metrics.Counter; //導入方法依賴的package包/類
/** {@inheritDoc} */
@Override public void report(SortedMap<String, Gauge> gauges, SortedMap<String, Counter> counters,
    SortedMap<String, Histogram> histograms, SortedMap<String, Meter> meters,
    SortedMap<String, Timer> timers) {
    if (clusterOverloaded) {
        return;
    }
    Histogram histogram = histograms.get(StatisticsCollector.LATENCY_HISTOGRAM);
    Counter workersCounter = counters.get(StatisticsCollector.LOAD_THREADS_COUNTER);

    if (histogram != null) {
        if (startTime == 0) {
            // Set start time only when load testing has been started.
            startTime = System.currentTimeMillis();
        }
        if (warmup && ((System.currentTimeMillis() - startTime) >= TestsHelper.getLoadTestsWarmupPeriod())) {
            warmup = false;
        }
        if (warmup) {
            return; // Exclude warmup period from overload stop checking.
        }
        double currentLatency = histogram.getSnapshot().getValue(quantile);
        Long currentWorkers = workersCounter == null ? null : workersCounter.getCount();

        if (workers == null) {
            workers = currentWorkers;
        }
        if (workers != null && !workers.equals(currentWorkers)) {
            if (measuredLatencies.size() >= MINIMUM_NUMBER_OF_MEASUREMENTS) {
                int medianIndex = measuredLatencies.size() / 2;

                Collections.sort(measuredLatencies);
                if (measuredLatencies.get(medianIndex) > latencyThreshold) {
                    clusterOverloaded = true;
                    LOGGER.warn("Cluster is considered overloaded and will be stopped.");
                    ClusterStopper.stopCluster(ignite);
                    return;
                }
            }
            measuredLatencies.clear();
            workers = currentWorkers;
        }
        if (workers == null || workers.equals(currentWorkers)) {
            measuredLatencies.add(currentLatency);
        }
    }
}
 
開發者ID:epam,項目名稱:Lagerta,代碼行數:48,代碼來源:IgniteNodeOverloadReporter.java


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