com.codahale.metrics.UniformReservoir Java Examples

The following examples show how to use com.codahale.metrics.UniformReservoir. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: PlatformDriverExecutorRegistry.java    From arcusplatform with Apache License 2.0 6 votes vote down vote up
private Map<String, Object> queueBacklog() {
   Histogram backlog = new Histogram(new UniformReservoir(64));
   for(DriverExecutor executor: executorCache.asMap().values()) {
      backlog.update(((DefaultDriverExecutor) executor).getQueuedMessageCount());
   }
   Snapshot snap = backlog.getSnapshot();
   return ImmutableMap
         .<String, Object>builder()
         .put("count", backlog.getCount())
         .put("min", snap.getMin())
         .put("max", snap.getMax())
         .put("mean", snap.getMean())
         .put("stddev", snap.getStdDev())
         .put("p50", snap.getMedian())
         .put("p75", snap.get75thPercentile())
         .put("p95", snap.get95thPercentile())
         .put("p98", snap.get98thPercentile())
         .put("p99", snap.get99thPercentile())
         .put("p999", snap.get999thPercentile())
         .build();
}
 
Example #2
Source File: MetricsConfigTest.java    From lucene-solr with Apache License 2.0 6 votes vote down vote up
@Test
public void testCustomReservoir() throws Exception {
  System.setProperty("timer.reservoir", UniformReservoir.class.getName());
  System.setProperty("histogram.size", "2048");
  System.setProperty("histogram.window", "600");
  System.setProperty("histogram.reservoir", SlidingTimeWindowReservoir.class.getName());
  NodeConfig cfg = loadNodeConfig();
  SolrMetricManager mgr = new SolrMetricManager(cfg.getSolrResourceLoader(), cfg.getMetricsConfig());
  assertTrue(mgr.getCounterSupplier() instanceof MetricSuppliers.DefaultCounterSupplier);
  assertTrue(mgr.getMeterSupplier() instanceof MetricSuppliers.DefaultMeterSupplier);
  assertTrue(mgr.getTimerSupplier() instanceof MetricSuppliers.DefaultTimerSupplier);
  assertTrue(mgr.getHistogramSupplier() instanceof MetricSuppliers.DefaultHistogramSupplier);
  Reservoir rsv = ((MetricSuppliers.DefaultTimerSupplier)mgr.getTimerSupplier()).getReservoir();
  assertTrue(rsv instanceof UniformReservoir);
  rsv = ((MetricSuppliers.DefaultHistogramSupplier)mgr.getHistogramSupplier()).getReservoir();
  assertTrue(rsv instanceof SlidingTimeWindowReservoir);
}
 
Example #3
Source File: TestPerformanceEvaluation.java    From hbase with Apache License 2.0 6 votes vote down vote up
@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);
}
 
Example #4
Source File: RandomKeyGenerator.java    From hadoop-ozone with Apache License 2.0 5 votes vote down vote up
public void init(OzoneConfiguration configuration) throws IOException {
  startTime = System.nanoTime();
  jobStartTime = System.currentTimeMillis();
  volumeCreationTime = new AtomicLong();
  bucketCreationTime = new AtomicLong();
  keyCreationTime = new AtomicLong();
  keyWriteTime = new AtomicLong();
  totalBytesWritten = new AtomicLong();
  numberOfVolumesCreated = new AtomicInteger();
  numberOfBucketsCreated = new AtomicInteger();
  numberOfKeysAdded = new AtomicLong();
  volumeCounter = new AtomicInteger();
  bucketCounter = new AtomicInteger();
  keyCounter = new AtomicLong();
  volumes = new ConcurrentHashMap<>();
  buckets = new ConcurrentHashMap<>();
  if (omServiceID != null) {
    ozoneClient = OzoneClientFactory.getRpcClient(omServiceID, configuration);
  } else {
    ozoneClient = OzoneClientFactory.getRpcClient(configuration);
  }
  objectStore = ozoneClient.getObjectStore();
  for (FreonOps ops : FreonOps.values()) {
    histograms.add(ops.ordinal(), new Histogram(new UniformReservoir()));
  }
  if (freon != null) {
    freon.startHttpServer();
  }
}
 
Example #5
Source File: CompareHistogramsWithOtherLibraries.java    From micrometer with Apache License 2.0 5 votes vote down vote up
@Setup(Level.Iteration)
public void setup() {
    registry = new MetricRegistry();
    histogram = registry.histogram("histogram");
    histogramSlidingTimeWindow =
            registry.register("slidingTimeWindowHistogram",
                    new Histogram(new SlidingTimeWindowReservoir(10, TimeUnit.SECONDS)));
    histogramUniform =
            registry.register("uniformHistogram",
                    new Histogram(new UniformReservoir()));
}
 
Example #6
Source File: TimelineServerPerf.java    From hudi with Apache License 2.0 5 votes vote down vote up
private static PerfStats runOneRound(SyncableFileSystemView fsView, String partition, String fileId, int id,
    int numIterations) {
  Histogram latencyHistogram = new Histogram(new UniformReservoir(10000));
  for (int i = 0; i < numIterations; i++) {
    long beginTs = System.currentTimeMillis();
    Option<FileSlice> c = fsView.getLatestFileSlice(partition, fileId);
    long endTs = System.currentTimeMillis();
    System.out.println("Latest File Slice for part=" + partition + ", fileId=" + fileId + ", Slice=" + c + ", Time="
        + (endTs - beginTs));
    latencyHistogram.update(endTs - beginTs);
  }
  return new PerfStats(partition, id, latencyHistogram.getSnapshot());
}
 
Example #7
Source File: PerformanceEvaluation.java    From hbase with Apache License 2.0 5 votes vote down vote up
void testSetup() throws IOException {
  // test metrics
  latencyHistogram = YammerHistogramUtils.newHistogram(new UniformReservoir(1024 * 500));
  valueSizeHistogram = YammerHistogramUtils.newHistogram(new UniformReservoir(1024 * 500));
  // scan metrics
  rpcCallsHistogram = YammerHistogramUtils.newHistogram(new UniformReservoir(1024 * 500));
  remoteRpcCallsHistogram = YammerHistogramUtils.newHistogram(new UniformReservoir(1024 * 500));
  millisBetweenNextHistogram = YammerHistogramUtils.newHistogram(new UniformReservoir(1024 * 500));
  regionsScannedHistogram = YammerHistogramUtils.newHistogram(new UniformReservoir(1024 * 500));
  bytesInResultsHistogram = YammerHistogramUtils.newHistogram(new UniformReservoir(1024 * 500));
  bytesInRemoteResultsHistogram = YammerHistogramUtils.newHistogram(new UniformReservoir(1024 * 500));

  onStartup();
}
 
Example #8
Source File: Metrics.java    From heftydb with Apache License 2.0 5 votes vote down vote up
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()));
}
 
Example #9
Source File: SingularityTaskReconciliation.java    From Singularity with Apache License 2.0 5 votes vote down vote up
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;
}
 
Example #10
Source File: IrisMetrics.java    From arcusplatform with Apache License 2.0 4 votes vote down vote up
public static Reservoir uniformReservoir() {
   return new UniformReservoir();
}
 
Example #11
Source File: IrisMetrics.java    From arcusplatform with Apache License 2.0 4 votes vote down vote up
public static Reservoir uniformReservoir(int size) {
   return new UniformReservoir(size);
}
 
Example #12
Source File: MetricSuppliers.java    From lucene-solr with Apache License 2.0 4 votes vote down vote up
@SuppressWarnings({"unchecked"})
private static final Reservoir getReservoir(SolrResourceLoader loader, PluginInfo info) {
  if (info == null) {
    return new ExponentiallyDecayingReservoir();
  }
  Clock clk = getClock(info, CLOCK);
  String clazz = ExponentiallyDecayingReservoir.class.getName();
  int size = -1;
  double alpha = -1;
  long window = -1;
  if (info.initArgs != null) {
    if (info.initArgs.get(RESERVOIR) != null) {
      String val = String.valueOf(info.initArgs.get(RESERVOIR)).trim();
      if (!val.isEmpty()) {
        clazz = val;
      }
    }
    Number n = (Number)info.initArgs.get(RESERVOIR_SIZE);
    if (n != null) {
      size = n.intValue();
    }
    n = (Number)info.initArgs.get(RESERVOIR_EDR_ALPHA);
    if (n != null) {
      alpha = n.doubleValue();
    }
    n = (Number)info.initArgs.get(RESERVOIR_WINDOW);
    if (n != null) {
      window = n.longValue();
    }
  }
  if (size <= 0) {
    size = DEFAULT_SIZE;
  }
  if (alpha <= 0) {
    alpha = DEFAULT_ALPHA;
  }
  // special case for core implementations
  if (clazz.equals(EDR_CLAZZ)) {
    return new ExponentiallyDecayingReservoir(size, alpha, clk);
  } else if (clazz.equals(UNI_CLAZZ)) {
    return new UniformReservoir(size);
  } else if (clazz.equals(STW_CLAZZ)) {
    if (window <= 0) {
      window = DEFAULT_WINDOW; // 5 minutes, comparable to EDR
    }
    return new SlidingTimeWindowReservoir(window, TimeUnit.SECONDS);
  } else if (clazz.equals(SW_CLAZZ)) {
    return new SlidingWindowReservoir(size);
  } else { // custom reservoir
    Reservoir reservoir;
    try {
      reservoir = loader.newInstance(clazz, Reservoir.class);
      if (reservoir instanceof PluginInfoInitialized) {
        ((PluginInfoInitialized)reservoir).init(info);
      } else {
        SolrPluginUtils.invokeSetters(reservoir, info.initArgs, true);
      }
      return reservoir;
    } catch (Exception e) {
      log.warn("Error initializing custom Reservoir implementation (will use default): {}", info, e);
      return new ExponentiallyDecayingReservoir(size, alpha, clk);
    }
  }
}
 
Example #13
Source File: ExecutableTimer.java    From strongback-java with MIT License 2 votes vote down vote up
/**
 * Create an executable timer that measures the specified number of samples.
 *
 * @param numberOfSamples the maximum number of samples to take; must be positive
 * @param uponCompletion the function that will be called
 */
private ExecutableTimer(int numberOfSamples, Consumer<ExecutableTimer> uponCompletion) {
    histogram = new Histogram(new UniformReservoir(numberOfSamples));
    numSamples = numberOfSamples;
    resultsHandler = uponCompletion;
}