Java 类org.apache.hadoop.util.SignalLogger 实例源码

项目:octopus    文件:StringUtils.java   
/**
 * Print a log message for starting up and shutting down
 *
 * @param clazz the class of the server
 * @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);
}
项目:tajo    文件:StringUtils.java   
/**
 * Print a log message for starting up and shutting down
 * @param clazz the class of the server
 * @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);
}
项目:tajo-cdh    文件:StringUtils.java   
/**
 * Print a log message for starting up and shutting down
 * @param clazz the class of the server
 * @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);
}