當前位置: 首頁>>代碼示例>>Java>>正文


Java NetUtils.getHostname方法代碼示例

本文整理匯總了Java中org.apache.hadoop.net.NetUtils.getHostname方法的典型用法代碼示例。如果您正苦於以下問題:Java NetUtils.getHostname方法的具體用法?Java NetUtils.getHostname怎麽用?Java NetUtils.getHostname使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在org.apache.hadoop.net.NetUtils的用法示例。


在下文中一共展示了NetUtils.getHostname方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: init

import org.apache.hadoop.net.NetUtils; //導入方法依賴的package包/類
@Override
public void init(SubsetConfiguration conf) {
  // Get StatsD host configurations.
  final String serverHost = conf.getString(SERVER_HOST_KEY);
  final int serverPort = Integer.parseInt(conf.getString(SERVER_PORT_KEY));

  skipHostname = conf.getBoolean(SKIP_HOSTNAME_KEY, false);
  if (!skipHostname) {
    hostName = conf.getString(HOST_NAME_KEY, null);
    if (null == hostName) {
      hostName = NetUtils.getHostname();
    }
  }

  serviceName = conf.getString(SERVICE_NAME_KEY, null);

  statsd = new StatsD(serverHost, serverPort);
}
 
開發者ID:nucypher,項目名稱:hadoop-oss,代碼行數:19,代碼來源:StatsDSink.java

示例2: checkHostname

import org.apache.hadoop.net.NetUtils; //導入方法依賴的package包/類
private boolean checkHostname(String appHostname) throws Exception {

    String hostname = NetUtils.getHostname();
    if (hostname.equals(appHostname)) {
      return true;
    }

    Assert.assertTrue("Unknown format for hostname " + appHostname,
      appHostname.contains("/"));
    Assert.assertTrue("Unknown format for hostname " + hostname,
      hostname.contains("/"));

    String[] appHostnameParts = appHostname.split("/");
    String[] hostnameParts = hostname.split("/");

    return (compareFQDNs(appHostnameParts[0], hostnameParts[0]) && checkIPs(
      hostnameParts[0], hostnameParts[1], appHostnameParts[1]));
  }
 
開發者ID:naver,項目名稱:hadoop,代碼行數:19,代碼來源:TestDistributedShell.java

示例3: startupShutdownMessage

import org.apache.hadoop.net.NetUtils; //導入方法依賴的package包/類
static void startupShutdownMessage(Class<?> clazz, String[] args,
                                   final LogAdapter LOG) { 
  final String hostname = NetUtils.getHostname();
  final String classname = clazz.getSimpleName();
  LOG.info(
      toStartupShutdownString("STARTUP_MSG: ", new String[] {
          "Starting " + classname,
          "  user = " + System.getProperty("user.name"),
          "  host = " + hostname,
          "  args = " + Arrays.asList(args),
          "  version = " + VersionInfo.getVersion(),
          "  classpath = " + System.getProperty("java.class.path"),
          "  build = " + VersionInfo.getUrl() + " -r "
                       + VersionInfo.getRevision()  
                       + "; compiled by '" + VersionInfo.getUser()
                       + "' on " + 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);

}
 
開發者ID:nucypher,項目名稱:hadoop-oss,代碼行數:38,代碼來源:StringUtils.java

示例4: startupShutdownMessage

import org.apache.hadoop.net.NetUtils; //導入方法依賴的package包/類
static void startupShutdownMessage(Class<?> clazz, String[] args,
                                   final LogAdapter LOG) { 
  final String hostname = NetUtils.getHostname();
  final String classname = clazz.getSimpleName();
  LOG.info(
      toStartupShutdownString("STARTUP_MSG: ", new String[] {
          "Starting " + classname,
          "  host = " + hostname,
          "  args = " + Arrays.asList(args),
          "  version = " + VersionInfo.getVersion(),
          "  classpath = " + System.getProperty("java.class.path"),
          "  build = " + VersionInfo.getUrl() + " -r "
                       + VersionInfo.getRevision()  
                       + "; compiled by '" + VersionInfo.getUser()
                       + "' on " + 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);

}
 
開發者ID:naver,項目名稱:hadoop,代碼行數:37,代碼來源:StringUtils.java


注:本文中的org.apache.hadoop.net.NetUtils.getHostname方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。