本文整理汇总了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);
}
示例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]));
}
示例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);
}
示例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);
}