本文整理汇总了Java中com.codahale.metrics.UniformReservoir类的典型用法代码示例。如果您正苦于以下问题:Java UniformReservoir类的具体用法?Java UniformReservoir怎么用?Java UniformReservoir使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
UniformReservoir类属于com.codahale.metrics包,在下文中一共展示了UniformReservoir类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: forTestSetMetricsRegistryName
import com.codahale.metrics.UniformReservoir; //导入依赖的package包/类
@VisibleForTesting
@SuppressWarnings("unused")
public static void forTestSetMetricsRegistryName(String metricsRegistryName) {
if (imStarted) {
throw new IllegalStateException("Unit tests only!!!");
}
MetricRegistry metrics = SharedMetricRegistries.getOrCreate(metricsRegistryName);
bambooReadTimer = new Timer();
metrics.register("bambooReadTimer", bambooReadTimer);
bambooParseTimer = new Timer();
metrics.register("bambooParseTimer", bambooParseTimer);
warcDocCountHistogram = new Histogram(new UniformReservoir());
metrics.register("warcDocCountHistogram", warcDocCountHistogram);
warcSizeHistogram = new Histogram(new UniformReservoir());
metrics.register("warcSizeHistogram", warcSizeHistogram);
}
示例2: create
import com.codahale.metrics.UniformReservoir; //导入依赖的package包/类
@Override
@SuppressWarnings("unchecked")
public <T> T create(final Class<T> type) {
if (type.equals(Meter.class)) {
return (T) new Meter();
}
if (type.equals(Counter.class)) {
return (T) new Counter();
}
if (type.equals(Histogram.class)) {
return (T) new Histogram(new UniformReservoir());
}
return null;
}
示例3: testZipfian
import com.codahale.metrics.UniformReservoir; //导入依赖的package包/类
@Test
public void testZipfian()
throws NoSuchMethodException, SecurityException, InstantiationException, IllegalAccessException,
IllegalArgumentException, InvocationTargetException {
TestOptions opts = new PerformanceEvaluation.TestOptions();
opts.setValueZipf(true);
final int valueSize = 1024;
opts.setValueSize(valueSize);
RandomReadTest rrt = new RandomReadTest(null, opts, null);
Constructor<?> ctor =
Histogram.class.getDeclaredConstructor(com.codahale.metrics.Reservoir.class);
ctor.setAccessible(true);
Histogram histogram = (Histogram)ctor.newInstance(new UniformReservoir(1024 * 500));
for (int i = 0; i < 100; i++) {
histogram.update(rrt.getValueLength(null));
}
Snapshot snapshot = histogram.getSnapshot();
double stddev = snapshot.getStdDev();
assertTrue(stddev != 0 && stddev != 1.0);
assertTrue(snapshot.getStdDev() != 0);
double median = snapshot.getMedian();
assertTrue(median != 0 && median != 1 && median != valueSize);
}
示例4: startReconciliation
import com.codahale.metrics.UniformReservoir; //导入依赖的package包/类
public ReconciliationState startReconciliation() {
final long taskReconciliationStartedAt = System.currentTimeMillis();
if (!isRunningReconciliation.compareAndSet(false, true)) {
LOG.info("Reconciliation is already running, NOT starting a new reconciliation process");
return ReconciliationState.ALREADY_RUNNING;
}
if (!schedulerClient.isRunning()) {
LOG.trace("Not running reconciliation - no active scheduler present");
isRunningReconciliation.set(false);
return ReconciliationState.NO_DRIVER;
}
final List<SingularityTaskId> activeTaskIds = taskManager.getActiveTaskIds();
LOG.info("Starting a reconciliation cycle - {} current active tasks", activeTaskIds.size());
schedulerClient.reconcile(Collections.emptyList());
scheduleReconciliationCheck(taskReconciliationStartedAt, activeTaskIds, 0, new Histogram(new UniformReservoir()));
return ReconciliationState.STARTED;
}
示例5: initMetrics
import com.codahale.metrics.UniformReservoir; //导入依赖的package包/类
private void initMetrics() {
//Main DB Metrics
metrics.register(metricName("write"), new Timer(new UniformReservoir()));
metrics.register(metricName("write.rate"), new Meter());
metrics.register(metricName("read"), new Timer(new UniformReservoir()));
metrics.register(metricName("read.rate"), new Meter());
metrics.register(metricName("scan"), new Timer(new UniformReservoir()));
metrics.register(metricName("scan.rate"), new Meter());
//Write
metrics.register(metricName("write.concurrentMemoryTableSerializers"), new Histogram(new UniformReservoir()));
metrics.register(metricName("write.memoryTableSerialize"), new Timer(new UniformReservoir()));
//Read
metrics.register(metricName("read.tablesConsulted"), new Histogram(new UniformReservoir()));
metrics.register(metricName("read.bloomFilterFalsePositiveRate"), new CacheHitGauge());
metrics.register(metricName("read.recordNotFoundRate"), new CacheHitGauge());
//FileTable
metrics.register(metricName("table.cacheHitRate"), new CacheHitGauge());
//Index
metrics.register(metricName("index.searchLevels"), new Histogram(new UniformReservoir()));
metrics.register(metricName("index.cacheHitRate"), new CacheHitGauge());
//Compactor
metrics.register(metricName("compactor.concurrentTasks"), new Histogram(new UniformReservoir()));
metrics.register(metricName("compactor.taskExecution"), new Timer(new UniformReservoir()));
}
示例6: testCreateTimer
import com.codahale.metrics.UniformReservoir; //导入依赖的package包/类
@Test
public void testCreateTimer() throws ReflectiveOperationException {
final UniformTimingStrategy strategy = new UniformTimingStrategy();
final Timer timer = strategy.createTimer(new MapConfig());
UniformReservoir reservoir = reservoir(timer);
assertNotNull(reservoir);
assertEquals("uniform", strategy.name());
}
示例7: getReservoir
import com.codahale.metrics.UniformReservoir; //导入依赖的package包/类
/**
* Get reservoir implementation based on the reservoir type
*
* @return The {@link Reservoir} implementation
*/
private Reservoir getReservoir() {
// The Reservoir implementation is selected using a switch statement.
// The ReservoirType enum is a part of YAML configuration
// and foreign imports are not supported by Carbon Configuration Maven Plugin.
// Therefore, the Reservoir class cannot be imported and the Reservoir
// creation logic cannot be written inside ReservoirType enum.
switch (reservoirType) {
case EXPONENTIALLY_DECAYING:
return new ExponentiallyDecayingReservoir();
case UNIFORM:
return new UniformReservoir(reservoirParametersConfig.getSize());
case SLIDING_WINDOW:
return new SlidingWindowReservoir(reservoirParametersConfig.getSize());
case SLIDING_TIME_WINDOW:
return new SlidingTimeWindowReservoir(reservoirParametersConfig.getWindow(),
reservoirParametersConfig.getWindowUnit());
case HDR_HISTOGRAM:
Recorder recorder = new Recorder(reservoirParametersConfig.getNumberOfSignificantValueDigits());
if (reservoirParametersConfig.isResetOnSnapshot()) {
return new HdrHistogramResetOnSnapshotReservoir(recorder);
} else {
return new HdrHistogramReservoir(recorder);
}
default:
throw new RuntimeException("Invalid Reservoir Type");
}
}
示例8: yearHistogram
import com.codahale.metrics.UniformReservoir; //导入依赖的package包/类
private Histogram yearHistogram(String year) {
if (!yearSizes.containsKey(year)) {
synchronized (yearSizes) {
if (!yearSizes.containsKey(year)) {
Histogram h = new Histogram(new UniformReservoir());
metrics.register("size.year." + year, h);
yearSizes.put(year, h);
}
}
}
return yearSizes.get(year);
}
示例9: lazyLoadByKey
import com.codahale.metrics.UniformReservoir; //导入依赖的package包/类
private void lazyLoadByKey(Map map, Object key, String prefix) {
if (key == null) return;
if (!map.containsKey(key)) {
synchronized (map) {
if (!map.containsKey(key)) {
Histogram h = new Histogram(new UniformReservoir());
metrics.register(prefix + key.toString().replaceAll("\\*", "star") + "", h);
map.put(key, h);
}
}
}
}
示例10: histograms
import com.codahale.metrics.UniformReservoir; //导入依赖的package包/类
@Test
public void histograms() throws Exception {
MetricRegistry registry = new MetricRegistry();
Histogram h = new Histogram(new UniformReservoir());
registry.register("h", h);
h.update(7);
// result
Map<String, Object> result = new TreeMap<>();
result.put("histograms",
ImmutableMap.of("h", ImmutableMap.builder()
.put("max", 7D)
.put("mean", 7D)
.put("min", 7D)
.put("p50", 7D)
.put("p75", 7D)
.put("p95", 7D)
.put("p98", 7D)
.put("p99", 7D)
.put("p999", 7D)
.put("values", Lists.newArrayList(7D))
.build()));
new MockUnit(Request.class, Response.class)
.expect(registry(registry))
.expect(name("name", Optional.empty()))
.expect(param("type", "*"))
.expect(param("unit", "seconds", "seconds"))
.expect(bparam("showSamples", true))
.expect(send(Status.OK, result))
.run(unit -> {
new MetricHandler().handle(unit.get(Request.class), unit.get(Response.class));
});
}
示例11: createTimer
import com.codahale.metrics.UniformReservoir; //导入依赖的package包/类
@Override
public Timer createTimer(Config config) {
return new Timer(new UniformReservoir(config.integerValue(SIZE_PROP).orElse(DEFAULT_SIZE)));
}
示例12: newDomainFilterHistogram
import com.codahale.metrics.UniformReservoir; //导入依赖的package包/类
private void newDomainFilterHistogram(String rules, String metricsName) {
Histogram h = new Histogram(new UniformReservoir());
domainSizes.put(new SurtFilter(rules), h);
metrics.register(metricsName, h);
}
示例13: startMe
import com.codahale.metrics.UniformReservoir; //导入依赖的package包/类
protected static synchronized void startMe(FilteringCoordinationService filtering, boolean indexFullText) {
if (imStarted) {
throw new IllegalStateException("You started me twice!");
}
log.info("Bamboo Base URL : {}", bambooBaseUrl);
log.info("Metrics registry : {}", filtering.getMetricsRegistryName());
log.info("# Filters : {}", filterPoolLimit);
log.info("# Transformers : {}", transformPoolLimit);
log.info("# Indexers : {}", indexPoolLimit);
// Metrics are fun...
MetricRegistry metrics = SharedMetricRegistries.getOrCreate(filtering.getMetricsRegistryName());
bambooReadTimer = new Timer();
metrics.register("bambooReadTimer", bambooReadTimer);
bambooParseTimer = new Timer();
metrics.register("bambooParseTimer", bambooParseTimer);
Gauge<Long> bambooCacheNull = () -> bambooCacheNullLong;
metrics.register("bambooCacheNull", bambooCacheNull);
Gauge<Long> bambooCacheHit = () -> bambooCacheHitLong;
metrics.register("bambooCacheHit", bambooCacheHit);
Gauge<Long> bambooCacheMiss = () -> bambooCacheMissLong;
metrics.register("bambooCacheMiss", bambooCacheMiss);
warcDocCountHistogram = new Histogram(new UniformReservoir());
metrics.register("warcDocCountHistogram", warcDocCountHistogram);
warcSizeHistogram = new Histogram(new UniformReservoir());
metrics.register("warcSizeHistogram", warcSizeHistogram);
Timer filterTimer = new Timer();
metrics.register("filterTimer", filterTimer);
Timer transformTimer = new Timer();
metrics.register("transformTimer", transformTimer);
Timer indexTimer = new Timer();
metrics.register("indexTimer", indexTimer);
// Filter workers
WorkProcessor filterPool = new WorkProcessor(filterPoolLimit);
for (int i = 0; i < filterPoolLimit; i++) {
filterPool.process(new FilterWorker(filtering, filterTimer));
}
// Transform workers
WorkProcessor transformPool = new WorkProcessor(transformPoolLimit);
for (int i = 0; i < transformPoolLimit; i++) {
transformPool.process(new TransformWorker(transformTimer, indexFullText));
}
// Indexing workers
WorkProcessor indexPool = new WorkProcessor(indexPoolLimit);
for (int i = 0; i < indexPoolLimit; i++) {
indexPool.process(new IndexerWorker(indexTimer));
}
imStarted = true;
}
示例14: testSetup
import com.codahale.metrics.UniformReservoir; //导入依赖的package包/类
void testSetup() throws IOException {
createConnection();
onStartup();
latencyHistogram = YammerHistogramUtils.newHistogram(new UniformReservoir(1024 * 500));
valueSizeHistogram = YammerHistogramUtils.newHistogram(new UniformReservoir(1024 * 500));
}
示例15: newInstance
import com.codahale.metrics.UniformReservoir; //导入依赖的package包/类
public IQDigest newInstance(long factor)
{
return new MetricsHistogram(new UniformReservoir());
}