Java Code Examples for org.apache.hadoop.metrics2.lib.DefaultMetricsSystem#shutdown()

The following examples show how to use org.apache.hadoop.metrics2.lib.DefaultMetricsSystem#shutdown() . 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: TestMetricsSystemImpl.java    From hadoop with Apache License 2.0 6 votes vote down vote up
@Test public void testStartStopStart() {
  DefaultMetricsSystem.shutdown(); // Clear pre-existing source names.
  MetricsSystemImpl ms = new MetricsSystemImpl("test");
  TestSource ts = new TestSource("ts");
  ms.start();
  ms.register("ts", "", ts);
  MetricsSourceAdapter sa = ms.getSourceAdapter("ts");
  assertNotNull(sa);
  assertNotNull(sa.getMBeanName());
  ms.stop();
  ms.shutdown();
  ms.start();
  sa = ms.getSourceAdapter("ts");
  assertNotNull(sa);
  assertNotNull(sa.getMBeanName());
  ms.stop();
  ms.shutdown();
}
 
Example 2
Source File: ResourceManager.java    From big-c with Apache License 2.0 6 votes vote down vote up
@Override
protected void serviceStop() throws Exception {

  DefaultMetricsSystem.shutdown();

  if (rmContext != null) {
    RMStateStore store = rmContext.getStateStore();
    try {
      store.close();
    } catch (Exception e) {
      LOG.error("Error closing store.", e);
    }
  }

  super.serviceStop();
}
 
Example 3
Source File: ResourceManager.java    From hadoop with Apache License 2.0 6 votes vote down vote up
@Override
protected void serviceStop() throws Exception {

  DefaultMetricsSystem.shutdown();

  if (rmContext != null) {
    RMStateStore store = rmContext.getStateStore();
    try {
      store.close();
    } catch (Exception e) {
      LOG.error("Error closing store.", e);
    }
  }

  super.serviceStop();
}
 
Example 4
Source File: TestNodeStatusUpdater.java    From hadoop with Apache License 2.0 5 votes vote down vote up
@After
public void tearDown() {
  this.registeredNodes.clear();
  heartBeatID = 0;
  ServiceOperations.stop(nm);
  assertionFailedInThread.set(false);
  DefaultMetricsSystem.shutdown();
}
 
Example 5
Source File: ApplicationHistoryServer.java    From hadoop with Apache License 2.0 5 votes vote down vote up
@Override
protected void serviceStop() throws Exception {
  if (webApp != null) {
    webApp.stop();
  }

  DefaultMetricsSystem.shutdown();
  super.serviceStop();
}
 
Example 6
Source File: ApplicationHistoryServer.java    From big-c with Apache License 2.0 5 votes vote down vote up
@Override
protected void serviceStop() throws Exception {
  if (webApp != null) {
    webApp.stop();
  }

  DefaultMetricsSystem.shutdown();
  super.serviceStop();
}
 
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: TestFairScheduler.java    From big-c with Apache License 2.0 5 votes vote down vote up
@After
public void tearDown() {
  if (scheduler != null) {
    scheduler.stop();
    scheduler = null;
  }
  if (resourceManager != null) {
    resourceManager.stop();
    resourceManager = null;
  }
  QueueMetrics.clearQueueMetrics();
  DefaultMetricsSystem.shutdown();
}
 
Example 9
Source File: TestFairScheduler.java    From hadoop with Apache License 2.0 5 votes vote down vote up
@After
public void tearDown() {
  if (scheduler != null) {
    scheduler.stop();
    scheduler = null;
  }
  if (resourceManager != null) {
    resourceManager.stop();
    resourceManager = null;
  }
  QueueMetrics.clearQueueMetrics();
  DefaultMetricsSystem.shutdown();
}
 
Example 10
Source File: AMSApplicationServer.java    From ambari-metrics with Apache License 2.0 5 votes vote down vote up
@Override
protected void serviceStop() throws Exception {
  if (webApp != null) {
    webApp.stop();
  }

  DefaultMetricsSystem.shutdown();
  super.serviceStop();
}
 
Example 11
Source File: MiniOzoneClusterImpl.java    From hadoop-ozone with Apache License 2.0 5 votes vote down vote up
@Override
public void shutdown() {
  try {
    LOG.info("Shutting down the Mini Ozone Cluster");
    File baseDir = new File(GenericTestUtils.getTempPath(
        MiniOzoneClusterImpl.class.getSimpleName() + "-" +
            scm.getClientProtocolServer().getScmInfo().getClusterId()));
    stop();
    FileUtils.deleteDirectory(baseDir);
    ContainerCache.getInstance(conf).shutdownCache();
    DefaultMetricsSystem.shutdown();
  } catch (IOException e) {
    LOG.error("Exception while shutting down the cluster.", e);
  }
}
 
Example 12
Source File: DataNodeMetrics.java    From hadoop with Apache License 2.0 4 votes vote down vote up
public void shutdown() {
  DefaultMetricsSystem.shutdown();
}
 
Example 13
Source File: TestEventQueue.java    From hadoop-ozone with Apache License 2.0 4 votes vote down vote up
@After
public void stopEventQueue() {
  DefaultMetricsSystem.shutdown();
  queue.close();
}
 
Example 14
Source File: TestRMContainerAllocator.java    From hadoop with Apache License 2.0 4 votes vote down vote up
@After
public void tearDown() {
  DefaultMetricsSystem.shutdown();
}
 
Example 15
Source File: StreamingContainer.java    From attic-apex-core with Apache License 2.0 4 votes vote down vote up
/**
 * Initialize container. Establishes heartbeat connection to the master
 * distribute through the callback address provided on the command line. Deploys
 * initial modules, then enters the heartbeat loop, which will only terminate
 * once container receives shutdown request from the master. On shutdown,
 * after exiting heartbeat loop, shutdown all modules and terminate
 * processing threads.
 *
 * @param args
 * @throws Throwable
 */
public static void main(String[] args) throws Throwable
{
  LoggerUtil.setupMDC("worker");
  StdOutErrLog.tieSystemOutAndErrToLog();
  logger.debug("PID: " + System.getenv().get("JVM_PID"));
  logger.info("Child starting with classpath: {}", System.getProperty("java.class.path"));

  String appPath = System.getProperty(PROP_APP_PATH);
  if (appPath == null) {
    logger.error("{} not set in container environment.", PROP_APP_PATH);
    System.exit(1);
  }

  int exitStatus = 1; // interpreted as unrecoverable container failure

  RecoverableRpcProxy rpcProxy = null;
  StreamingContainerUmbilicalProtocol umbilical = null;
  final String childId = System.getProperty(StreamingApplication.DT_PREFIX + "cid");
  try {
    rpcProxy = new RecoverableRpcProxy(appPath, new Configuration());
    umbilical = rpcProxy.getProxy();
    StreamingContainerContext ctx = umbilical.getInitContext(childId);
    StreamingContainer stramChild = new StreamingContainer(childId, umbilical);
    logger.debug("Container Context = {}", ctx);
    stramChild.setup(ctx);
    try {
      /* main thread enters heartbeat loop */
      stramChild.heartbeatLoop();
      exitStatus = 0;
    } finally {
      stramChild.teardown();
    }
  } catch (Error | Exception e) {
    LogFileInformation logFileInfo = LoggerUtil.getLogFileInformation();
    logger.error("Fatal {} in container!", (e instanceof Error) ? "Error" : "Exception", e);
    /* Report back any failures, for diagnostic purposes */
    try {
      umbilical.reportError(childId, null, ExceptionUtils.getStackTrace(e), logFileInfo);
    } catch (Exception ex) {
      logger.debug("Fail to log", ex);
    }
  } finally {
    if (rpcProxy != null) {
      rpcProxy.close();
    }
    DefaultMetricsSystem.shutdown();
    logger.info("Exit status for container: {}", exitStatus);
    LogManager.shutdown();
    if (exitStatus != 0) {
      System.exit(exitStatus);
    }
  }
}
 
Example 16
Source File: JobHistoryServer.java    From big-c with Apache License 2.0 4 votes vote down vote up
@Override
protected void serviceStop() throws Exception {
  DefaultMetricsSystem.shutdown();
  super.serviceStop();
}
 
Example 17
Source File: TestMetricsSystemImpl.java    From big-c with Apache License 2.0 4 votes vote down vote up
@Test public void testInitFirstVerifyStopInvokedImmediately() throws Exception {
  DefaultMetricsSystem.shutdown();
  new ConfigBuilder().add("*.period", 8)
      //.add("test.sink.plugin.urls", getPluginUrlsAsString())
      .add("test.sink.test.class", TestSink.class.getName())
      .add("test.*.source.filter.exclude", "s0")
      .add("test.source.s1.metric.filter.exclude", "X*")
      .add("test.sink.sink1.metric.filter.exclude", "Y*")
      .add("test.sink.sink2.metric.filter.exclude", "Y*")
      .save(TestMetricsConfig.getTestFilename("hadoop-metrics2-test"));
  MetricsSystemImpl ms = new MetricsSystemImpl("Test");
  ms.start();
  ms.register("s0", "s0 desc", new TestSource("s0rec"));
  TestSource s1 = ms.register("s1", "s1 desc", new TestSource("s1rec"));
  s1.c1.incr();
  s1.xxx.incr();
  s1.g1.set(2);
  s1.yyy.incr(2);
  s1.s1.add(0);
  MetricsSink sink1 = mock(MetricsSink.class);
  MetricsSink sink2 = mock(MetricsSink.class);
  ms.registerSink("sink1", "sink1 desc", sink1);
  ms.registerSink("sink2", "sink2 desc", sink2);
  ms.publishMetricsNow(); // publish the metrics
  ms.stop();
  ms.shutdown();

  //When we call stop, at most two sources will be consumed by each sink thread.
  verify(sink1, atMost(2)).putMetrics(r1.capture());
  List<MetricsRecord> mr1 = r1.getAllValues();
  verify(sink2, atMost(2)).putMetrics(r2.capture());
  List<MetricsRecord> mr2 = r2.getAllValues();
  if (mr1.size() != 0 && mr2.size() != 0) {
    checkMetricsRecords(mr1);
    assertEquals("output", mr1, mr2);
  } else if (mr1.size() != 0) {
    checkMetricsRecords(mr1);
  } else if (mr2.size() != 0) {
    checkMetricsRecords(mr2);
  }
}
 
Example 18
Source File: NameNodeMetrics.java    From hadoop with Apache License 2.0 4 votes vote down vote up
public void shutdown() {
  DefaultMetricsSystem.shutdown();
}
 
Example 19
Source File: TestSchedulerApplicationAttempt.java    From big-c with Apache License 2.0 4 votes vote down vote up
@After
public void tearDown() {
  QueueMetrics.clearQueueMetrics();
  DefaultMetricsSystem.shutdown();
}
 
Example 20
Source File: TestStagingCleanup.java    From hadoop with Apache License 2.0 4 votes vote down vote up
@Override
public void serviceStart() throws Exception {
  super.serviceStart();
  DefaultMetricsSystem.shutdown();
}