Java Code Examples for org.apache.hadoop.metrics2.MetricsSystem#getSource()

The following examples show how to use org.apache.hadoop.metrics2.MetricsSystem#getSource() . 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: TestRocksDBStoreMBean.java    From hadoop-ozone with Apache License 2.0 6 votes vote down vote up
@Test
public void testMetricsSystemIntegration() throws Exception {

  RocksDBStore metadataStore = getTestRocksDBStoreWithData();
  Thread.sleep(2000);

  MetricsSystem ms = DefaultMetricsSystem.instance();
  MetricsSource rdbSource =
      ms.getSource("Rocksdb_TestRocksDBStoreMBean-withstat");

  BufferedMetricsCollector metricsCollector = new BufferedMetricsCollector();
  rdbSource.getMetrics(metricsCollector, true);

  Map<String, Double> metrics = metricsCollector.getMetricsRecordBuilder()
      .getMetrics();
  assertTrue(10.0 == metrics.get("NUMBER_KEYS_WRITTEN"));
  assertTrue(metrics.get("DB_WRITE_AVERAGE") > 0);
  metadataStore.close();
}
 
Example 2
Source File: TestResourceTrackerService.java    From hadoop with Apache License 2.0 6 votes vote down vote up
@After
public void tearDown() {
  if (hostFile != null && hostFile.exists()) {
    hostFile.delete();
  }

  ClusterMetrics.destroy();
  if (rm != null) {
    rm.stop();
  }

  MetricsSystem ms = DefaultMetricsSystem.instance();
  if (ms.getSource("ClusterMetrics") != null) {
    DefaultMetricsSystem.shutdown();
  }
}
 
Example 3
Source File: TestMetricsSystemImpl.java    From hadoop with Apache License 2.0 6 votes vote down vote up
@Test public void testUnregisterSource() {
  MetricsSystem ms = new MetricsSystemImpl();
  TestSource ts1 = new TestSource("ts1");
  TestSource ts2 = new TestSource("ts2");
  ms.register("ts1", "", ts1);
  ms.register("ts2", "", ts2);
  MetricsSource s1 = ms.getSource("ts1");
  assertNotNull(s1);
  // should work when metrics system is not started
  ms.unregisterSource("ts1");
  s1 = ms.getSource("ts1");
  assertNull(s1);
  MetricsSource s2 = ms.getSource("ts2");
  assertNotNull(s2);
  ms.shutdown();
}
 
Example 4
Source File: TestResourceTrackerService.java    From big-c with Apache License 2.0 6 votes vote down vote up
@After
public void tearDown() {
  if (hostFile != null && hostFile.exists()) {
    hostFile.delete();
  }

  ClusterMetrics.destroy();
  if (rm != null) {
    rm.stop();
  }

  MetricsSystem ms = DefaultMetricsSystem.instance();
  if (ms.getSource("ClusterMetrics") != null) {
    DefaultMetricsSystem.shutdown();
  }
}
 
Example 5
Source File: TestMetricsSystemImpl.java    From big-c with Apache License 2.0 6 votes vote down vote up
@Test public void testUnregisterSource() {
  MetricsSystem ms = new MetricsSystemImpl();
  TestSource ts1 = new TestSource("ts1");
  TestSource ts2 = new TestSource("ts2");
  ms.register("ts1", "", ts1);
  ms.register("ts2", "", ts2);
  MetricsSource s1 = ms.getSource("ts1");
  assertNotNull(s1);
  // should work when metrics system is not started
  ms.unregisterSource("ts1");
  s1 = ms.getSource("ts1");
  assertNull(s1);
  MetricsSource s2 = ms.getSource("ts2");
  assertNotNull(s2);
  ms.shutdown();
}
 
Example 6
Source File: RocksDBStoreMBean.java    From hadoop-ozone with Apache License 2.0 5 votes vote down vote up
public static RocksDBStoreMBean create(Statistics statistics,
                                       String contextName) {

  RocksDBStoreMBean rocksDBStoreMBean = new RocksDBStoreMBean(
      statistics, contextName);
  MetricsSystem ms = DefaultMetricsSystem.instance();
  MetricsSource metricsSource = ms.getSource(rocksDBStoreMBean.contextName);
  if (metricsSource != null) {
    return (RocksDBStoreMBean)metricsSource;
  } else {
    return ms.register(rocksDBStoreMBean.contextName,
        "RocksDB Metrics",
        rocksDBStoreMBean);
  }
}
 
Example 7
Source File: TestClusterMetrics.java    From hadoop with Apache License 2.0 5 votes vote down vote up
@After
public void tearDown() {
  ClusterMetrics.destroy();

  MetricsSystem ms = DefaultMetricsSystem.instance();
  if (ms.getSource("ClusterMetrics") != null) {
    DefaultMetricsSystem.shutdown();
  }
}
 
Example 8
Source File: TestShuffleHandler.java    From hadoop with Apache License 2.0 5 votes vote down vote up
static void checkShuffleMetrics(MetricsSystem ms, long bytes, int failed,
                                int succeeded, int connections) {
  MetricsSource source = ms.getSource("ShuffleMetrics");
  MetricsRecordBuilder rb = getMetrics(source);
  assertCounter("ShuffleOutputBytes", bytes, rb);
  assertCounter("ShuffleOutputsFailed", failed, rb);
  assertCounter("ShuffleOutputsOK", succeeded, rb);
  assertGauge("ShuffleConnections", connections, rb);
}
 
Example 9
Source File: TestMetricsSystemImpl.java    From hadoop with Apache License 2.0 5 votes vote down vote up
@Test public void testRegisterDups() {
  MetricsSystem ms = new MetricsSystemImpl();
  TestSource ts1 = new TestSource("ts1");
  TestSource ts2 = new TestSource("ts2");
  ms.register("ts1", "", ts1);
  MetricsSource s1 = ms.getSource("ts1");
  assertNotNull(s1);
  // should work when metrics system is not started
  ms.register("ts1", "", ts2);
  MetricsSource s2 = ms.getSource("ts1");
  assertNotNull(s2);
  assertNotSame(s1, s2);
  ms.shutdown();
}
 
Example 10
Source File: TestClusterMetrics.java    From big-c with Apache License 2.0 5 votes vote down vote up
@After
public void tearDown() {
  ClusterMetrics.destroy();

  MetricsSystem ms = DefaultMetricsSystem.instance();
  if (ms.getSource("ClusterMetrics") != null) {
    DefaultMetricsSystem.shutdown();
  }
}
 
Example 11
Source File: TestShuffleHandler.java    From big-c with Apache License 2.0 5 votes vote down vote up
static void checkShuffleMetrics(MetricsSystem ms, long bytes, int failed,
                                int succeeded, int connections) {
  MetricsSource source = ms.getSource("ShuffleMetrics");
  MetricsRecordBuilder rb = getMetrics(source);
  assertCounter("ShuffleOutputBytes", bytes, rb);
  assertCounter("ShuffleOutputsFailed", failed, rb);
  assertCounter("ShuffleOutputsOK", succeeded, rb);
  assertGauge("ShuffleConnections", connections, rb);
}
 
Example 12
Source File: TestMetricsSystemImpl.java    From big-c with Apache License 2.0 5 votes vote down vote up
@Test public void testRegisterDups() {
  MetricsSystem ms = new MetricsSystemImpl();
  TestSource ts1 = new TestSource("ts1");
  TestSource ts2 = new TestSource("ts2");
  ms.register("ts1", "", ts1);
  MetricsSource s1 = ms.getSource("ts1");
  assertNotNull(s1);
  // should work when metrics system is not started
  ms.register("ts1", "", ts2);
  MetricsSource s2 = ms.getSource("ts1");
  assertNotNull(s2);
  assertNotSame(s1, s2);
  ms.shutdown();
}
 
Example 13
Source File: TestQueueMetrics.java    From hadoop with Apache License 2.0 4 votes vote down vote up
public static MetricsSource queueSource(MetricsSystem ms, String queue) {
  MetricsSource s = ms.getSource(QueueMetrics.sourceName(queue).toString());
  return s;
}
 
Example 14
Source File: TestQueueMetrics.java    From hadoop with Apache License 2.0 4 votes vote down vote up
public static MetricsSource userSource(MetricsSystem ms, String queue,
                                       String user) {
  MetricsSource s = ms.getSource(QueueMetrics.sourceName(queue).
      append(",user=").append(user).toString());
  return s;
}
 
Example 15
Source File: TestQueueMetrics.java    From big-c with Apache License 2.0 4 votes vote down vote up
public static MetricsSource queueSource(MetricsSystem ms, String queue) {
  MetricsSource s = ms.getSource(QueueMetrics.sourceName(queue).toString());
  return s;
}
 
Example 16
Source File: TestQueueMetrics.java    From big-c with Apache License 2.0 4 votes vote down vote up
public static MetricsSource userSource(MetricsSystem ms, String queue,
                                       String user) {
  MetricsSource s = ms.getSource(QueueMetrics.sourceName(queue).
      append(",user=").append(user).toString());
  return s;
}