Example usage for org.apache.hadoop.metrics2.lib DefaultMetricsSystem shutdown

List of usage examples for org.apache.hadoop.metrics2.lib DefaultMetricsSystem shutdown

Introduction

In this page you can find the example usage for org.apache.hadoop.metrics2.lib DefaultMetricsSystem shutdown.

Prototype

public static void shutdown() 

Source Link

Document

Shutdown the metrics system

Usage

From source file:com.datatorrent.stram.engine.StreamingContainer.java

License:Apache License

/**
 * 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./*ww  w.java 2s . co m*/
 *
 * @param args
 * @throws Throwable
 */
public static void main(String[] args) throws Throwable {
    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 = new RecoverableRpcProxy(appPath, new Configuration());
    final StreamingContainerUmbilicalProtocol umbilical = rpcProxy.getProxy();
    final String childId = System.getProperty(StreamingApplication.DT_PREFIX + "cid");
    try {
        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 error) {
        logger.error("Fatal error in container!", error);
        /* Report back any failures, for diagnostic purposes */
        String msg = ExceptionUtils.getStackTrace(error);
        umbilical.reportError(childId, null, "FATAL: " + msg);
    } catch (Exception exception) {
        logger.error("Fatal exception in container!", exception);
        /* Report back any failures, for diagnostic purposes */
        String msg = ExceptionUtils.getStackTrace(exception);
        umbilical.reportError(childId, null, msg);
    } finally {
        rpcProxy.close();
        DefaultMetricsSystem.shutdown();
        logger.info("Exit status for container: {}", exitStatus);
        LogManager.shutdown();
    }

    if (exitStatus != 0) {
        System.exit(exitStatus);
    }
}

From source file:com.twitter.hraven.hadoopJobMonitor.metrics.HadoopJobMonitorMetrics.java

License:Apache License

public void shutdown() {
    DefaultMetricsSystem.shutdown();
}

From source file:org.apache.tez.runtime.task.TezChild.java

License:Apache License

public void shutdown() {
    if (!isShutdown.getAndSet(true)) {
        executor.shutdownNow();/*from w  w w . j  av a 2  s .co  m*/
        if (taskReporter != null) {
            taskReporter.shutdown();
        }
        DefaultMetricsSystem.shutdown();
        if (!isLocal) {
            RPC.stopProxy(umbilical);
            LogManager.shutdown();
        }
    }
}