本文整理汇总了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);
}
示例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);
}
示例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);
}
示例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);
}
示例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);
}
示例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);
}
示例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);
}
示例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);
}
示例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);
}
}
}