Example usage for org.apache.hadoop.util SignalLogger INSTANCE

List of usage examples for org.apache.hadoop.util SignalLogger INSTANCE

Introduction

In this page you can find the example usage for org.apache.hadoop.util SignalLogger INSTANCE.

Prototype

SignalLogger INSTANCE

To view the source code for org.apache.hadoop.util SignalLogger INSTANCE.

Click Source Link

Usage

From source file:kr.co.bitnine.octopus.util.StringUtils.java

License:Apache License

/**
 * Print a log message for starting up and shutting down
 *
 * @param clazz the class of the server/*from   w  w w . j  av a2 s.c om*/
 * @param args  arguments
 * @param log   the target log object
 */
public static void startupShutdownMessage(Class<?> clazz, String[] args, final Log log) {
    final String classname = clazz.getSimpleName();
    final String hostname = NetUtils.getHostname();

    final String build = VersionInfo.getUrl() + ", rev. " + VersionInfo.getRevision() + "; compiled by '"
            + VersionInfo.getUser() + "' on " + VersionInfo.getDate();
    String[] msg = new String[] { "Starting " + classname, "  host = " + hostname,
            "  args = " + Arrays.asList(args), "  version = " + VersionInfo.getVersion(),
            "  classpath = " + System.getProperty("java.class.path"), "  build = " + build,
            "  java = " + System.getProperty("java.version") };
    log.info(toStartupShutdownString("STARTUP_MSG: ", msg));

    if (SystemUtils.IS_OS_UNIX) {
        try {
            SignalLogger.INSTANCE.register(log);
        } catch (Throwable t) {
            log.warn("failed to register any UNIX signal loggers: ", t);
        }
    }
    ShutdownHookManager.get().addShutdownHook(new Runnable() {
        @Override
        public void run() {
            log.info(toStartupShutdownString("SHUTDOWN_MSG: ",
                    new String[] { "Shutting down " + classname + " at " + hostname }));
        }
    }, SHUTDOWN_HOOK_PRIORITY);
}

From source file:org.apache.tajo.util.StringUtils.java

License:Apache License

/**
 * Print a log message for starting up and shutting down
 * @param clazz the class of the server/*  w w  w  .  ja v  a  2  s  .c om*/
 * @param args arguments
 * @param LOG the target log object
 */
public static void startupShutdownMessage(Class<?> clazz, String[] args,
        final org.apache.commons.logging.Log LOG) {
    final String hostname = org.apache.hadoop.net.NetUtils.getHostname();
    final String classname = clazz.getSimpleName();
    LOG.info(toStartupShutdownString("STARTUP_MSG: ",
            new String[] { "Starting " + classname, "  host = " + hostname, "  args = " + Arrays.asList(args),
                    "  version = " + org.apache.tajo.util.VersionInfo.getVersion(),
                    "  classpath = " + System.getProperty("java.class.path"),
                    "  build = " + org.apache.tajo.util.VersionInfo.getUrl() + " -r "
                            + org.apache.tajo.util.VersionInfo.getRevision() + "; compiled by '"
                            + org.apache.tajo.util.VersionInfo.getUser() + "' on "
                            + org.apache.tajo.util.VersionInfo.getDate(),
                    "  java = " + System.getProperty("java.version") }));

    if (SystemUtils.IS_OS_UNIX) {
        try {
            SignalLogger.INSTANCE.register(LOG);
        } catch (Throwable t) {
            LOG.warn("failed to register any UNIX signal loggers: ", t);
        }
    }
    ShutdownHookManager.get().addShutdownHook(new Runnable() {
        @Override
        public void run() {
            LOG.info(toStartupShutdownString("SHUTDOWN_MSG: ",
                    new String[] { "Shutting down " + classname + " at " + hostname }));
        }
    }, SHUTDOWN_HOOK_PRIORITY);
}