本文整理匯總了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);
}