• 如果您觉得本站非常有看点,那么赶紧使用Ctrl+D 收藏吧

Java MetricsCollectorImpl类的典型用法和代码示例

java 1次浏览

本文整理汇总了Java中org.apache.hadoop.metrics2.impl.MetricsCollectorImpl的典型用法代码示例。如果您正苦于以下问题:Java MetricsCollectorImpl类的具体用法?Java MetricsCollectorImpl怎么用?Java MetricsCollectorImpl使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。

MetricsCollectorImpl类属于org.apache.hadoop.metrics2.impl包,在下文中一共展示了MetricsCollectorImpl类的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: testContainerMetricsFlow

点赞 2

import org.apache.hadoop.metrics2.impl.MetricsCollectorImpl; //导入依赖的package包/类
@Test
public void testContainerMetricsFlow() throws InterruptedException {
  final String ERR = "Error in number of records";

  // Create a dummy MetricsSystem
  MetricsSystem system = mock(MetricsSystem.class);
  doReturn(this).when(system).register(anyString(), anyString(), any());

  MetricsCollectorImpl collector = new MetricsCollectorImpl();
  ContainerId containerId = mock(ContainerId.class);
  ContainerMetrics metrics = ContainerMetrics.forContainer(containerId, 100);

  metrics.recordMemoryUsage(1024);
  metrics.getMetrics(collector, true);
  assertEquals(ERR, 0, collector.getRecords().size());

  Thread.sleep(110);
  metrics.getMetrics(collector, true);
  assertEquals(ERR, 1, collector.getRecords().size());
  collector.clear();

  Thread.sleep(110);
  metrics.getMetrics(collector, true);
  assertEquals(ERR, 1, collector.getRecords().size());
  collector.clear();

  metrics.finished();
  metrics.getMetrics(collector, true);
  assertEquals(ERR, 1, collector.getRecords().size());
  collector.clear();

  metrics.getMetrics(collector, true);
  assertEquals(ERR, 0, collector.getRecords().size());

  Thread.sleep(110);
  metrics.getMetrics(collector, true);
  assertEquals(ERR, 0, collector.getRecords().size());
}
 

开发者ID:naver,
项目名称:hadoop,
代码行数:39,
代码来源:TestContainerMetrics.java

示例2: testContainerMetricsLimit

点赞 2

import org.apache.hadoop.metrics2.impl.MetricsCollectorImpl; //导入依赖的package包/类
@Test
public void testContainerMetricsLimit() throws InterruptedException {
  final String ERR = "Error in number of records";

  MetricsSystem system = mock(MetricsSystem.class);
  doReturn(this).when(system).register(anyString(), anyString(), any());

  MetricsCollectorImpl collector = new MetricsCollectorImpl();
  ContainerId containerId = mock(ContainerId.class);
  ContainerMetrics metrics = ContainerMetrics.forContainer(containerId, 100);

  int anyPmemLimit = 1024;
  int anyVmemLimit = 2048;
  int anyVcores = 10;
  int anyGcores = 10;
  String anyProcessId = "1234";

  metrics.recordResourceLimit(anyVmemLimit, anyPmemLimit, anyVcores, anyGcores);
  metrics.recordProcessId(anyProcessId);

  Thread.sleep(110);
  metrics.getMetrics(collector, true);
  assertEquals(ERR, 1, collector.getRecords().size());
  MetricsRecord record = collector.getRecords().get(0);

  MetricsRecords.assertTag(record, ContainerMetrics.PROCESSID_INFO.name(),
      anyProcessId);

  MetricsRecords.assertMetric(record, ContainerMetrics
      .PMEM_LIMIT_METRIC_NAME, anyPmemLimit);
  MetricsRecords.assertMetric(record, ContainerMetrics.VMEM_LIMIT_METRIC_NAME, anyVmemLimit);
  MetricsRecords.assertMetric(record, ContainerMetrics.VCORE_LIMIT_METRIC_NAME, anyVcores);

  collector.clear();
}
 

开发者ID:naver,
项目名称:hadoop,
代码行数:36,
代码来源:TestContainerMetrics.java

示例3: testPerfMetricsInited

点赞 2

import org.apache.hadoop.metrics2.impl.MetricsCollectorImpl; //导入依赖的package包/类
@Test
public void testPerfMetricsInited() {
  scheduler.init(conf);
  scheduler.start();
  MetricsCollectorImpl collector = new MetricsCollectorImpl();
  scheduler.fsOpDurations.getMetrics(collector, true);
  assertEquals("Incorrect number of perf metrics", 1,
      collector.getRecords().size());
}
 

开发者ID:naver,
项目名称:hadoop,
代码行数:10,
代码来源:TestFairScheduler.java

示例4: testContainerMetricsFlow

点赞 2

import org.apache.hadoop.metrics2.impl.MetricsCollectorImpl; //导入依赖的package包/类
@Test
public void testContainerMetricsFlow() throws InterruptedException {
  final String ERR = "Error in number of records";

  // Create a dummy MetricsSystem
  MetricsSystem system = mock(MetricsSystem.class);
  doReturn(this).when(system).register(anyString(), anyString(), any());

  MetricsCollectorImpl collector = new MetricsCollectorImpl();
  ContainerId containerId = mock(ContainerId.class);
  ContainerMetrics metrics = ContainerMetrics.forContainer(containerId,
      100, 1);

  metrics.recordMemoryUsage(1024);
  metrics.getMetrics(collector, true);
  assertEquals(ERR, 0, collector.getRecords().size());

  Thread.sleep(110);
  metrics.getMetrics(collector, true);
  assertEquals(ERR, 1, collector.getRecords().size());
  collector.clear();

  Thread.sleep(110);
  metrics.getMetrics(collector, true);
  assertEquals(ERR, 1, collector.getRecords().size());
  collector.clear();

  metrics.finished();
  metrics.getMetrics(collector, true);
  assertEquals(ERR, 1, collector.getRecords().size());
  collector.clear();

  metrics.getMetrics(collector, true);
  assertEquals(ERR, 0, collector.getRecords().size());

  Thread.sleep(110);
  metrics.getMetrics(collector, true);
  assertEquals(ERR, 0, collector.getRecords().size());
}
 

开发者ID:aliyun-beta,
项目名称:aliyun-oss-hadoop-fs,
代码行数:40,
代码来源:TestContainerMetrics.java

示例5: testContainerMetricsFinished

点赞 2

import org.apache.hadoop.metrics2.impl.MetricsCollectorImpl; //导入依赖的package包/类
@Test
public void testContainerMetricsFinished() throws InterruptedException {
  MetricsSystemImpl system = new MetricsSystemImpl();
  system.init("test");
  MetricsCollectorImpl collector = new MetricsCollectorImpl();
  ApplicationId appId = ApplicationId.newInstance(1234, 3);
  ApplicationAttemptId appAttemptId =
      ApplicationAttemptId.newInstance(appId, 4);
  ContainerId containerId1 = ContainerId.newContainerId(appAttemptId, 1);
  ContainerMetrics metrics1 = ContainerMetrics.forContainer(system,
      containerId1, 1, 0);
  ContainerId containerId2 = ContainerId.newContainerId(appAttemptId, 2);
  ContainerMetrics metrics2 = ContainerMetrics.forContainer(system,
      containerId2, 1, 0);
  ContainerId containerId3 = ContainerId.newContainerId(appAttemptId, 3);
  ContainerMetrics metrics3 = ContainerMetrics.forContainer(system,
      containerId3, 1, 0);
  metrics1.finished();
  metrics2.finished();
  system.sampleMetrics();
  system.sampleMetrics();
  Thread.sleep(100);
  system.stop();
  // verify metrics1 is unregistered
  assertTrue(metrics1 != ContainerMetrics.forContainer(
      system, containerId1, 1, 0));
  // verify metrics2 is unregistered
  assertTrue(metrics2 != ContainerMetrics.forContainer(
      system, containerId2, 1, 0));
  // verify metrics3 is still registered
  assertTrue(metrics3 == ContainerMetrics.forContainer(
      system, containerId3, 1, 0));
  system.shutdown();
}
 

开发者ID:aliyun-beta,
项目名称:aliyun-oss-hadoop-fs,
代码行数:35,
代码来源:TestContainerMetrics.java

示例6: verifyExpectedCalls

点赞 2

import org.apache.hadoop.metrics2.impl.MetricsCollectorImpl; //导入依赖的package包/类
private void verifyExpectedCalls(long expectedCalls, int memory, int vcores)
  throws InterruptedException {
  boolean verified = false;
  int count = 0;
  while (count < 100) {
    if (scheduler.fsOpDurations.hasUpdateThreadRunChanged()) {
      break;
    }
    count++;
    Thread.sleep(10);
  }
  assertTrue("Update Thread has not run based on its metrics",
      scheduler.fsOpDurations.hasUpdateThreadRunChanged());
  assertEquals("Root queue metrics memory does not have expected value",
      memory, scheduler.getRootQueueMetrics().getAvailableMB());
  assertEquals("Root queue metrics cpu does not have expected value",
      vcores, scheduler.getRootQueueMetrics().getAvailableVirtualCores());

  MetricsCollectorImpl collector = new MetricsCollectorImpl();
  scheduler.fsOpDurations.getMetrics(collector, true);
  MetricsRecord record = collector.getRecords().get(0);
  for (AbstractMetric abstractMetric : record.metrics()) {
    if (abstractMetric.name().contains("UpdateThreadRunNumOps")) {
      assertEquals("Update Thread did not run expected number of times " +
              "based on metric record count",
          expectedCalls,
          abstractMetric.value());
      verified = true;
    }
  }
  assertTrue("Did not find metric for UpdateThreadRunNumOps", verified);
}
 

开发者ID:aliyun-beta,
项目名称:aliyun-oss-hadoop-fs,
代码行数:33,
代码来源:TestSchedulingUpdate.java

示例7: testContainerMetricsLimit

点赞 2

import org.apache.hadoop.metrics2.impl.MetricsCollectorImpl; //导入依赖的package包/类
@Test
public void testContainerMetricsLimit() throws InterruptedException {
  final String ERR = "Error in number of records";

  MetricsSystem system = mock(MetricsSystem.class);
  doReturn(this).when(system).register(anyString(), anyString(), any());

  MetricsCollectorImpl collector = new MetricsCollectorImpl();
  ContainerId containerId = mock(ContainerId.class);
  ContainerMetrics metrics = ContainerMetrics.forContainer(containerId, 100);

  int anyPmemLimit = 1024;
  int anyVmemLimit = 2048;
  int anyVcores = 10;
  String anyProcessId = "1234";

  metrics.recordResourceLimit(anyVmemLimit, anyPmemLimit, anyVcores);
  metrics.recordProcessId(anyProcessId);

  Thread.sleep(110);
  metrics.getMetrics(collector, true);
  assertEquals(ERR, 1, collector.getRecords().size());
  MetricsRecord record = collector.getRecords().get(0);

  MetricsRecords.assertTag(record, ContainerMetrics.PROCESSID_INFO.name(),
      anyProcessId);

  MetricsRecords.assertMetric(record, ContainerMetrics
      .PMEM_LIMIT_METRIC_NAME, anyPmemLimit);
  MetricsRecords.assertMetric(record, ContainerMetrics.VMEM_LIMIT_METRIC_NAME, anyVmemLimit);
  MetricsRecords.assertMetric(record, ContainerMetrics.VCORE_LIMIT_METRIC_NAME, anyVcores);

  collector.clear();
}
 

开发者ID:yncxcw,
项目名称:big-c,
代码行数:35,
代码来源:TestContainerMetrics.java

示例8: testContainerMetricsFinished

点赞 2

import org.apache.hadoop.metrics2.impl.MetricsCollectorImpl; //导入依赖的package包/类
@Test
public void testContainerMetricsFinished() throws InterruptedException {
  MetricsSystemImpl system = new MetricsSystemImpl();
  system.init("test");
  MetricsCollectorImpl collector = new MetricsCollectorImpl();
  ApplicationId appId = ApplicationId.newInstance(1234, 3);
  ApplicationAttemptId appAttemptId =
      ApplicationAttemptId.newInstance(appId, 4);
  ContainerId containerId1 = ContainerId.newContainerId(appAttemptId, 1);
  ContainerMetrics metrics1 = ContainerMetrics.forContainer(system,
      containerId1, 1, 0);
  ContainerId containerId2 = ContainerId.newContainerId(appAttemptId, 2);
  ContainerMetrics metrics2 = ContainerMetrics.forContainer(system,
      containerId2, 1, 0);
  ContainerId containerId3 = ContainerId.newContainerId(appAttemptId, 3);
  ContainerMetrics metrics3 = ContainerMetrics.forContainer(system,
      containerId3, 1, 0);
  metrics1.finished();
  metrics2.finished();
  system.sampleMetrics();
  system.sampleMetrics();
  Thread.sleep(100);
  // verify metrics1 is unregistered
  assertTrue(metrics1 != ContainerMetrics.forContainer(
      system, containerId1, 1, 0));
  // verify metrics2 is unregistered
  assertTrue(metrics2 != ContainerMetrics.forContainer(
      system, containerId2, 1, 0));
  // verify metrics3 is still registered
  assertTrue(metrics3 == ContainerMetrics.forContainer(
      system, containerId3, 1, 0));
  // YARN-5190: move stop() to the end to verify registering containerId1 and
  // containerId2 won't get MetricsException thrown.
  system.stop();
  system.shutdown();
}
 

开发者ID:hopshadoop,
项目名称:hops,
代码行数:37,
代码来源:TestContainerMetrics.java

示例9: testContainerMetricsLimit

点赞 2

import org.apache.hadoop.metrics2.impl.MetricsCollectorImpl; //导入依赖的package包/类
@Test
public void testContainerMetricsLimit() throws InterruptedException {
  final String ERR = "Error in number of records";

  MetricsSystem system = mock(MetricsSystem.class);
  doReturn(this).when(system).register(anyString(), anyString(), any());

  MetricsCollectorImpl collector = new MetricsCollectorImpl();
  ContainerId containerId = mock(ContainerId.class);
  ContainerMetrics metrics = ContainerMetrics.forContainer(containerId,
      100, 1);

  int anyPmemLimit = 1024;
  int anyVmemLimit = 2048;
  int anyVcores = 10;
  long anyLaunchDuration = 20L;
  long anyLocalizationDuration = 1000L;
  String anyProcessId = "1234";

  metrics.recordResourceLimit(anyVmemLimit, anyPmemLimit, anyVcores);
  metrics.recordProcessId(anyProcessId);
  metrics.recordStateChangeDurations(anyLaunchDuration,
      anyLocalizationDuration);

  Thread.sleep(110);
  metrics.getMetrics(collector, true);
  assertEquals(ERR, 1, collector.getRecords().size());
  MetricsRecord record = collector.getRecords().get(0);

  MetricsRecords.assertTag(record, ContainerMetrics.PROCESSID_INFO.name(),
      anyProcessId);

  MetricsRecords.assertMetric(record, ContainerMetrics
      .PMEM_LIMIT_METRIC_NAME, anyPmemLimit);
  MetricsRecords.assertMetric(record, ContainerMetrics.VMEM_LIMIT_METRIC_NAME, anyVmemLimit);
  MetricsRecords.assertMetric(record, ContainerMetrics.VCORE_LIMIT_METRIC_NAME, anyVcores);

  MetricsRecords.assertMetric(record,
      ContainerMetrics.LAUNCH_DURATION_METRIC_NAME, anyLaunchDuration);
  MetricsRecords.assertMetric(record,
      ContainerMetrics.LOCALIZATION_DURATION_METRIC_NAME,
      anyLocalizationDuration);

  collector.clear();
}
 

开发者ID:aliyun-beta,
项目名称:aliyun-oss-hadoop-fs,
代码行数:46,
代码来源:TestContainerMetrics.java

示例10: testContainerMetricsLimit

点赞 2

import org.apache.hadoop.metrics2.impl.MetricsCollectorImpl; //导入依赖的package包/类
@Test
public void testContainerMetricsLimit() throws InterruptedException {
  final String ERR = "Error in number of records";

  MetricsSystem system = mock(MetricsSystem.class);
  doReturn(this).when(system).register(anyString(), anyString(), any());

  MetricsCollectorImpl collector = new MetricsCollectorImpl();
  ContainerId containerId = mock(ContainerId.class);
  ContainerMetrics metrics = ContainerMetrics.forContainer(containerId, 100);

  int anyPmemLimit = 1024;
  int anyVmemLimit = 2048;
  int anyVcores = 10;
  long anyLaunchDuration = 20L;
  long anyLocalizationDuration = 1000L;
  String anyProcessId = "1234";

  metrics.recordResourceLimit(anyVmemLimit, anyPmemLimit, anyVcores);
  metrics.recordProcessId(anyProcessId);
  metrics.recordStateChangeDurations(anyLaunchDuration,
      anyLocalizationDuration);

  Thread.sleep(110);
  metrics.getMetrics(collector, true);
  assertEquals(ERR, 1, collector.getRecords().size());
  MetricsRecord record = collector.getRecords().get(0);

  MetricsRecords.assertTag(record, ContainerMetrics.PROCESSID_INFO.name(),
      anyProcessId);

  MetricsRecords.assertMetric(record, ContainerMetrics
      .PMEM_LIMIT_METRIC_NAME, anyPmemLimit);
  MetricsRecords.assertMetric(record, ContainerMetrics.VMEM_LIMIT_METRIC_NAME, anyVmemLimit);
  MetricsRecords.assertMetric(record, ContainerMetrics.VCORE_LIMIT_METRIC_NAME, anyVcores);

  MetricsRecords.assertMetric(record,
      ContainerMetrics.LAUNCH_DURATION_METRIC_NAME, anyLaunchDuration);
  MetricsRecords.assertMetric(record,
      ContainerMetrics.LOCALIZATION_DURATION_METRIC_NAME,
      anyLocalizationDuration);

  collector.clear();
}
 

开发者ID:Nextzero,
项目名称:hadoop-2.6.0-cdh5.4.3,
代码行数:45,
代码来源:TestContainerMetrics.java

示例11: testContainerMetricsLimit

点赞 2

import org.apache.hadoop.metrics2.impl.MetricsCollectorImpl; //导入依赖的package包/类
@Test
public void testContainerMetricsLimit() throws InterruptedException {
  final String ERR = "Error in number of records";

  MetricsSystem system = mock(MetricsSystem.class);
  doReturn(this).when(system).register(anyString(), anyString(), any());

  MetricsCollectorImpl collector = new MetricsCollectorImpl();
  ContainerId containerId = mock(ContainerId.class);
  ContainerMetrics metrics = ContainerMetrics.forContainer(containerId,
      100, 1);

  int anyPmemLimit = 1024;
  int anyVmemLimit = 2048;
  int anyVcores = 10;
  int anyGPUs = 4;
  long anyLaunchDuration = 20L;
  long anyLocalizationDuration = 1000L;
  String anyProcessId = "1234";

  metrics.recordResourceLimit(anyVmemLimit, anyPmemLimit, anyVcores, anyGPUs);
  metrics.recordProcessId(anyProcessId);
  metrics.recordStateChangeDurations(anyLaunchDuration,
      anyLocalizationDuration);

  int nbTry=0;
  do {
    Thread.sleep(110);
    metrics.getMetrics(collector, true);
    nbTry++;
  } while (nbTry < 10 && collector.getRecords().size() != 1);
  assertEquals(ERR, 1, collector.getRecords().size());
  MetricsRecord record = collector.getRecords().get(0);

  MetricsRecords.assertTag(record, ContainerMetrics.PROCESSID_INFO.name(),
      anyProcessId);

  MetricsRecords.assertMetric(record, ContainerMetrics
      .PMEM_LIMIT_METRIC_NAME, anyPmemLimit);
  MetricsRecords.assertMetric(record, ContainerMetrics.VMEM_LIMIT_METRIC_NAME, anyVmemLimit);
  MetricsRecords.assertMetric(record, ContainerMetrics.VCORE_LIMIT_METRIC_NAME, anyVcores);
  MetricsRecords.assertMetric(record, ContainerMetrics
      .GPU_LIMIT_METRIC_NAME, anyGPUs);

  MetricsRecords.assertMetric(record,
      ContainerMetrics.LAUNCH_DURATION_METRIC_NAME, anyLaunchDuration);
  MetricsRecords.assertMetric(record,
      ContainerMetrics.LOCALIZATION_DURATION_METRIC_NAME,
      anyLocalizationDuration);

  collector.clear();
}
 

开发者ID:hopshadoop,
项目名称:hops,
代码行数:53,
代码来源:TestContainerMetrics.java


版权声明:本文转自网络文章,转载此文章仅为分享知识,如有侵权,请联系管理员进行删除。
喜欢 (0)