Get hostname


private static final Log LOG = Logging.getLog(NodeHelper.class);

/**
* @return a node Id for this instance
*/
public static final String getNodeId () {
final String nodeId = String.format("hostname=%s", getHostname());
return nodeId;
}

/**
* @return a hostname for this instance
*/
public static final String getHostname () {
String hostname = "error-unknown";
try {
hostname = InetAddress.getLocalHost().getHostName();
} catch (final UnknownHostException e) {
LOG.error(String.format("Error acquiring hostname"), e);
} catch (final RuntimeException e) {
LOG.error(String.format("Error acquiring hostname"), e);
}
return hostname;
}

Comments

Popular posts from this blog

Sites, Newsletters, and Blogs

Oracle JDBC ReadTimeout QueryTimeout

Locks held on Oracle for hours after sessions abnormally terminated by node failure