org.apache.hadoop.metrics2.impl.MetricsSystemImpl Java Examples

The following examples show how to use org.apache.hadoop.metrics2.impl.MetricsSystemImpl. 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: TestShuffleHandler.java    From hadoop with Apache License 2.0 6 votes vote down vote up
/**
 * Validate shuffle connection and input/output metrics.
 *
 * @throws Exception exception
 */
@Test (timeout = 10000)
public void testShuffleMetrics() throws Exception {
  MetricsSystem ms = new MetricsSystemImpl();
  ShuffleHandler sh = new ShuffleHandler(ms);
  ChannelFuture cf = make(stub(ChannelFuture.class).
      returning(true, false).from.isSuccess());

  sh.metrics.shuffleConnections.incr();
  sh.metrics.shuffleOutputBytes.incr(1*MiB);
  sh.metrics.shuffleConnections.incr();
  sh.metrics.shuffleOutputBytes.incr(2*MiB);

  checkShuffleMetrics(ms, 3*MiB, 0 , 0, 2);

  sh.metrics.operationComplete(cf);
  sh.metrics.operationComplete(cf);

  checkShuffleMetrics(ms, 3*MiB, 1, 1, 0);
}
 
Example #2
Source File: TestShuffleHandler.java    From big-c with Apache License 2.0 6 votes vote down vote up
/**
 * Validate shuffle connection and input/output metrics.
 *
 * @throws Exception exception
 */
@Test (timeout = 10000)
public void testShuffleMetrics() throws Exception {
  MetricsSystem ms = new MetricsSystemImpl();
  ShuffleHandler sh = new ShuffleHandler(ms);
  ChannelFuture cf = make(stub(ChannelFuture.class).
      returning(true, false).from.isSuccess());

  sh.metrics.shuffleConnections.incr();
  sh.metrics.shuffleOutputBytes.incr(1*MiB);
  sh.metrics.shuffleConnections.incr();
  sh.metrics.shuffleOutputBytes.incr(2*MiB);

  checkShuffleMetrics(ms, 3*MiB, 0 , 0, 2);

  sh.metrics.operationComplete(cf);
  sh.metrics.operationComplete(cf);

  checkShuffleMetrics(ms, 3*MiB, 1, 1, 0);
}
 
Example #3
Source File: TestShuffleHandler.java    From tez with Apache License 2.0 6 votes vote down vote up
/**
 * Validate shuffle connection and input/output metrics.
 *
 * @throws Exception exception
 */
@Test (timeout = 10000)
public void testShuffleMetrics() throws Exception {
  MetricsSystem ms = new MetricsSystemImpl();
  ShuffleHandler sh = new ShuffleHandler(ms);
  ChannelFuture cf = mock(ChannelFuture.class);
  when(cf.isSuccess()).thenReturn(true, false);

  sh.metrics.shuffleConnections.incr();
  sh.metrics.shuffleOutputBytes.incr(1*MiB);
  sh.metrics.shuffleConnections.incr();
  sh.metrics.shuffleOutputBytes.incr(2*MiB);

  checkShuffleMetrics(ms, 3*MiB, 0 , 0, 2);

  sh.metrics.operationComplete(cf);
  sh.metrics.operationComplete(cf);

  checkShuffleMetrics(ms, 3*MiB, 1, 1, 0);
}
 
Example #4
Source File: TestQueueMetrics.java    From hadoop with Apache License 2.0 5 votes vote down vote up
@Test 
public void testMetricsCache() {
  MetricsSystem ms = new MetricsSystemImpl("cache");
  ms.start();
  
  try {
    String p1 = "root1";
    String leafQueueName = "root1.leaf";

    QueueMetrics p1Metrics =
        QueueMetrics.forQueue(ms, p1, null, true, conf);
    Queue parentQueue1 = make(stub(Queue.class).returning(p1Metrics).
        from.getMetrics());
    QueueMetrics metrics =
        QueueMetrics.forQueue(ms, leafQueueName, parentQueue1, true, conf);

    Assert.assertNotNull("QueueMetrics for A shoudn't be null", metrics);

    // Re-register to check for cache hit, shouldn't blow up metrics-system...
    // also, verify parent-metrics
    QueueMetrics alterMetrics =
        QueueMetrics.forQueue(ms, leafQueueName, parentQueue1, true, conf);

    Assert.assertNotNull("QueueMetrics for alterMetrics shoudn't be null", 
        alterMetrics);
  } finally {
    ms.shutdown();
  }
}
 
Example #5
Source File: SnapshotTestHelper.java    From hadoop with Apache License 2.0 5 votes vote down vote up
/** Disable the logs that are not very useful for snapshot related tests. */
public static void disableLogs() {
  final String[] lognames = {
      "org.apache.hadoop.hdfs.server.datanode.BlockPoolSliceScanner",
      "org.apache.hadoop.hdfs.server.datanode.fsdataset.impl.FsDatasetImpl",
      "org.apache.hadoop.hdfs.server.datanode.fsdataset.impl.FsDatasetAsyncDiskService",
  };
  for(String n : lognames) {
    GenericTestUtils.disableLog(LogFactory.getLog(n));
  }
  
  GenericTestUtils.disableLog(LogFactory.getLog(UserGroupInformation.class));
  GenericTestUtils.disableLog(LogFactory.getLog(BlockManager.class));
  GenericTestUtils.disableLog(LogFactory.getLog(FSNamesystem.class));
  GenericTestUtils.disableLog(LogFactory.getLog(DirectoryScanner.class));
  GenericTestUtils.disableLog(LogFactory.getLog(MetricsSystemImpl.class));
  
  GenericTestUtils.disableLog(BlockScanner.LOG);
  GenericTestUtils.disableLog(HttpServer2.LOG);
  GenericTestUtils.disableLog(DataNode.LOG);
  GenericTestUtils.disableLog(BlockPoolSliceStorage.LOG);
  GenericTestUtils.disableLog(LeaseManager.LOG);
  GenericTestUtils.disableLog(NameNode.stateChangeLog);
  GenericTestUtils.disableLog(NameNode.blockStateChangeLog);
  GenericTestUtils.disableLog(DFSClient.LOG);
  GenericTestUtils.disableLog(Server.LOG);
}
 
Example #6
Source File: AzureFileSystemMetricsSystem.java    From hadoop with Apache License 2.0 5 votes vote down vote up
public static synchronized void fileSystemStarted() {
  if (numFileSystems == 0) {
    instance = new MetricsSystemImpl();
    instance.init("azure-file-system");
  }
  numFileSystems++;
}
 
Example #7
Source File: TestQueueMetrics.java    From big-c with Apache License 2.0 5 votes vote down vote up
@Test 
public void testMetricsCache() {
  MetricsSystem ms = new MetricsSystemImpl("cache");
  ms.start();
  
  try {
    String p1 = "root1";
    String leafQueueName = "root1.leaf";

    QueueMetrics p1Metrics =
        QueueMetrics.forQueue(ms, p1, null, true, conf);
    Queue parentQueue1 = make(stub(Queue.class).returning(p1Metrics).
        from.getMetrics());
    QueueMetrics metrics =
        QueueMetrics.forQueue(ms, leafQueueName, parentQueue1, true, conf);

    Assert.assertNotNull("QueueMetrics for A shoudn't be null", metrics);

    // Re-register to check for cache hit, shouldn't blow up metrics-system...
    // also, verify parent-metrics
    QueueMetrics alterMetrics =
        QueueMetrics.forQueue(ms, leafQueueName, parentQueue1, true, conf);

    Assert.assertNotNull("QueueMetrics for alterMetrics shoudn't be null", 
        alterMetrics);
  } finally {
    ms.shutdown();
  }
}
 
Example #8
Source File: SnapshotTestHelper.java    From big-c with Apache License 2.0 5 votes vote down vote up
/** Disable the logs that are not very useful for snapshot related tests. */
public static void disableLogs() {
  final String[] lognames = {
      "org.apache.hadoop.hdfs.server.datanode.BlockPoolSliceScanner",
      "org.apache.hadoop.hdfs.server.datanode.fsdataset.impl.FsDatasetImpl",
      "org.apache.hadoop.hdfs.server.datanode.fsdataset.impl.FsDatasetAsyncDiskService",
  };
  for(String n : lognames) {
    GenericTestUtils.disableLog(LogFactory.getLog(n));
  }
  
  GenericTestUtils.disableLog(LogFactory.getLog(UserGroupInformation.class));
  GenericTestUtils.disableLog(LogFactory.getLog(BlockManager.class));
  GenericTestUtils.disableLog(LogFactory.getLog(FSNamesystem.class));
  GenericTestUtils.disableLog(LogFactory.getLog(DirectoryScanner.class));
  GenericTestUtils.disableLog(LogFactory.getLog(MetricsSystemImpl.class));
  
  GenericTestUtils.disableLog(BlockScanner.LOG);
  GenericTestUtils.disableLog(HttpServer2.LOG);
  GenericTestUtils.disableLog(DataNode.LOG);
  GenericTestUtils.disableLog(BlockPoolSliceStorage.LOG);
  GenericTestUtils.disableLog(LeaseManager.LOG);
  GenericTestUtils.disableLog(NameNode.stateChangeLog);
  GenericTestUtils.disableLog(NameNode.blockStateChangeLog);
  GenericTestUtils.disableLog(DFSClient.LOG);
  GenericTestUtils.disableLog(Server.LOG);
}
 
Example #9
Source File: AzureFileSystemMetricsSystem.java    From big-c with Apache License 2.0 5 votes vote down vote up
public static synchronized void fileSystemStarted() {
  if (numFileSystems == 0) {
    instance = new MetricsSystemImpl();
    instance.init("azure-file-system");
  }
  numFileSystems++;
}
 
Example #10
Source File: TestQueueMetrics.java    From hadoop with Apache License 2.0 4 votes vote down vote up
@Before
public void setUp() {
  ms = new MetricsSystemImpl();
  QueueMetrics.clearQueueMetrics();
}
 
Example #11
Source File: TestQueueMetrics.java    From big-c with Apache License 2.0 4 votes vote down vote up
@Before
public void setUp() {
  ms = new MetricsSystemImpl();
  QueueMetrics.clearQueueMetrics();
}