Package org.apache.hadoop.metrics2.impl

Examples of org.apache.hadoop.metrics2.impl.TestMetricsCollectorImpl


import org.mockito.ArgumentCaptor;
import org.mockito.internal.util.reflection.Whitebox;

public class TestGraphiteMetrics {
    private AbstractMetric makeMetric(String name, Number value) {
        AbstractMetric metric = mock(AbstractMetric.class);
        when(metric.name()).thenReturn(name);
        when(metric.value()).thenReturn(value);
        return metric;
    }
View Full Code Here


  @Test public void testPresence() {
    JvmPauseMonitor pauseMonitor = new JvmPauseMonitor(new Configuration());
    JvmMetrics jvmMetrics = new JvmMetrics("test", "test");
    jvmMetrics.setPauseMonitor(pauseMonitor);
    MetricsRecordBuilder rb = getMetrics(jvmMetrics);
    MetricsCollector mc = rb.parent();

    verify(mc).addRecord(JvmMetrics);
    verify(rb).tag(ProcessName, "test");
    verify(rb).tag(SessionId, "test");
    for (JvmMetricsInfo info : JvmMetricsInfo.values()) {
View Full Code Here

  @Override
  public synchronized void start() {
    checkNotNull(prefix, "prefix");
    if (monitoring) {
      LOG.warn(prefix +" metrics system already started!",
               new MetricsException("Illegal start"));
      return;
    }
    for (Callback cb : callbacks) cb.preStart();
    configure(prefix);
    startTimer();
View Full Code Here

  @Override
  public synchronized void stop() {
    if (!monitoring && !DefaultMetricsSystem.inMiniClusterMode()) {
      LOG.warn(prefix +" metrics system not yet started!",
               new MetricsException("Illegal stop"));
      return;
    }
    if (!monitoring) {
      // in mini cluster mode
      LOG.info(prefix +" metrics system stopped (again)");
View Full Code Here

    MetricsTag tag = new MetricsTag(name, description, value);

    if (!override) {
      MetricsTag existing = tagsMap.putIfAbsent(name, tag);
      if (existing != null) {
        throw new MetricsException("Tag " + name + " already exists!");
      }
      return this;
    }

    tagsMap.put(name, tag);
View Full Code Here

        return newGauge;
      }
    }

    if (!(metric instanceof MetricMutableGaugeLong)) {
      throw new MetricsException(
          "Metric already exists in registry for metric name: " + name
              + " and not of type MetricMutableGaugeLong");
    }

    return (MetricMutableGaugeLong) metric;
View Full Code Here

        return newCounter;
      }
    }

    if (!(counter instanceof MetricMutableCounterLong)) {
      throw new MetricsException(
          "Metric already exists in registry for metric name: " + name
              + "and not of type MetricMutableCounterLong");
    }

    return (MetricMutableCounterLong) counter;
View Full Code Here

        return newHisto;
      }
    }

    if (!(histo instanceof MetricMutableHistogram)) {
      throw new MetricsException(
          "Metric already exists in registry for metric name: " + name
              + "and not of type MetricMutableHistogram");
    }

    return (MetricMutableHistogram) histo;
View Full Code Here

        return newHisto;
      }
    }

    if (!(histo instanceof MetricMutableQuantiles)) {
      throw new MetricsException(
          "Metric already exists in registry for metric name: " + name
              + "and not of type MetricMutableQuantiles");
    }

    return (MetricMutableQuantiles) histo;
View Full Code Here

  }

  private <T> T returnExistingWithCast(MetricMutable metric,
      Class<T> metricClass, String name) {
    if (!metricClass.isAssignableFrom(metric.getClass())) {
      throw new MetricsException(
          "Metric already exists in registry for metric name: " + name
              + " and not of type " + metricClass);
    }

    return (T) metric;
View Full Code Here

TOP

Related Classes of org.apache.hadoop.metrics2.impl.TestMetricsCollectorImpl

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.