Package org.apache.hadoop.metrics2

Examples of org.apache.hadoop.metrics2.AbstractMetric


  private <T extends MetricMutable> T addNewMetricIfAbsent(String name, T ret,
      Class<T> metricClass) {
    // If the value we get back is null then the put was successful and we will
    // return that. Otherwise metric should contain the thing that was in
    // before the put could be completed.
    MetricMutable metric = metricsMap.putIfAbsent(name, ret);
    if (metric == null) {
      return ret;
    }

    return returnExistingWithCast(metric, metricClass, name);
View Full Code Here


   * @param initValue of the metric
   * @return a new counter object
   */
  public MetricMutableCounterInt newCounter(String name, String description,
      int initValue) {
    MetricMutableCounterInt ret = mf.newCounter(name, description, initValue);
    return addNewMetricIfAbsent(name, ret, MetricMutableCounterInt.class);
  }
View Full Code Here

   *
   * @param key the name of the counter
   * @param delta the ammount to increment
   */
  public void incCounters(String key, long delta) {
    MetricMutableCounterLong counter = metricsRegistry.getLongCounter(key, 0l);
    counter.incr(delta);

  }
View Full Code Here

   * @param initValue of the metric
   * @return a new counter object
   */
  public MetricMutableCounterLong newCounter(String name, String description,
      long initValue) {
    MetricMutableCounterLong ret = mf.newCounter(name, description, initValue);
    return addNewMetricIfAbsent(name, ret, MetricMutableCounterLong.class);
  }
View Full Code Here

  public MetricMutableCounterLong getLongCounter(String counterName,
      long potentialStartingValue) {
    // See getLongGauge for description on how this works.
    MetricMutable counter = metricsMap.get(counterName);
    if (counter == null) {
      MetricMutableCounterLong newCounter = mf.newCounter(counterName, "",
          potentialStartingValue);
      counter = metricsMap.putIfAbsent(counterName, newCounter);
      if (counter == null) {
        return newCounter;
      }
View Full Code Here

  @Test
  public void testIncCounters() throws Exception {
    String key = "testinccounter";
    bmsi.incCounters(key, 100);
    MetricMutableCounterLong c = (MetricMutableCounterLong) bmsi.metricsRegistry
        .get(key);
    assertEquals(key, c.name);
    bmsi.incCounters(key, 100);
    assertSame(c, bmsi.metricsRegistry.get(key));
  }
View Full Code Here

   * Construct the registry with a record name
   * @param name of the record of the metrics
   */
  public DynamicMetricsRegistry(String name) {
    this.name = name;
    this.mf = new MetricMutableFactory();
  }
View Full Code Here

   * @param initValue of the metric
   * @return a new gauge object
   */
  public MetricMutableGaugeInt newGauge(String name, String description,
      int initValue) {
    MetricMutableGaugeInt ret = mf.newGauge(name, description, initValue);
    return addNewMetricIfAbsent(name, ret, MetricMutableGaugeInt.class);
  }
View Full Code Here

   *
   * @param gaugeName gauge name
   * @param value the new value of the gauge.
   */
  public void setGauge(String gaugeName, long value) {
    MetricMutableGaugeLong gaugeInt = metricsRegistry.getLongGauge(gaugeName,
        value);
    gaugeInt.set(value);
  }
View Full Code Here

   *
   * @param gaugeName The name of the gauge to increment.
   * @param delta The amount to increment the gauge by.
   */
  public void incGauge(String gaugeName, long delta) {
    MetricMutableGaugeLong gaugeInt = metricsRegistry.getLongGauge(gaugeName,
        0l);
    gaugeInt.incr(delta);
  }
View Full Code Here

TOP

Related Classes of org.apache.hadoop.metrics2.AbstractMetric

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.