当前位置: 首页>>代码示例>>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;未经允许,请勿转载。