本文整理了Java中com.networknt.utility.Util.getInetAddress()
方法的一些代码示例,展示了Util.getInetAddress()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Util.getInetAddress()
方法的具体详情如下:
包路径:com.networknt.utility.Util
类名称:Util
方法名:getInetAddress
[英]Get InetAddress
[中]获取地址
代码示例来源:origin: networknt/light-4j
public Map<String, Object> getHost(HttpServerExchange exchange) {
Map<String, Object> hostMap = new LinkedHashMap<>();
String ip = "unknown";
String hostname = "unknown";
InetAddress inetAddress = Util.getInetAddress();
ip = inetAddress.getHostAddress();
hostname = inetAddress.getHostName();
hostMap.put("ip", ip);
hostMap.put("hostname", hostname);
hostMap.put("dns", exchange.getSourceAddress().getHostName());
return hostMap;
}
代码示例来源:origin: networknt/light-4j
public MetricsHandler() {
commonTags.put("apiName", Server.config.getServiceId());
commonTags.put("environment", Server.config.getEnvironment());
InetAddress inetAddress = Util.getInetAddress();
// On Docker for Mac, inetAddress will be null as there is a bug.
commonTags.put("ipAddress", inetAddress == null ? "unknown" : inetAddress.getHostAddress());
commonTags.put("hostname", inetAddress == null ? "unknown" : inetAddress.getHostName()); // will be container id if in docker.
if(logger.isDebugEnabled()) {
logger.debug(commonTags.toString());
}
}
代码示例来源:origin: networknt/light-4j
logger.info("Registry IP from STATUS_HOST_IP is " + ipAddress);
if (ipAddress == null) {
InetAddress inetAddress = Util.getInetAddress();
ipAddress = inetAddress.getHostAddress();
logger.info("Could not find IP from STATUS_HOST_IP, use the InetAddress " + ipAddress);
代码示例来源:origin: com.networknt/metrics
public MetricsHandler() {
commonTags.put("apiName", Server.config.getServiceId());
commonTags.put("environment", Server.config.getEnvironment());
InetAddress inetAddress = Util.getInetAddress();
// On Docker for Mac, inetAddress will be null as there is a bug.
commonTags.put("ipAddress", inetAddress == null ? "unknown" : inetAddress.getHostAddress());
commonTags.put("hostname", inetAddress == null ? "unknown" : inetAddress.getHostName()); // will be container id if in docker.
if(logger.isDebugEnabled()) {
logger.debug(commonTags.toString());
}
}
内容来源于网络,如有侵权,请联系作者删除!