本文整理了Java中com.hazelcast.nio.Address.getInetAddress()
方法的一些代码示例,展示了Address.getInetAddress()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Address.getInetAddress()
方法的具体详情如下:
包路径:com.hazelcast.nio.Address
类名称:Address
方法名:getInetAddress
暂无
代码示例来源:origin: com.hazelcast/hazelcast-all
public InetSocketAddress getInetSocketAddress() throws UnknownHostException {
return new InetSocketAddress(getInetAddress(), port);
}
代码示例来源:origin: hazelcast/hazelcast-jet
public InetSocketAddress getInetSocketAddress() throws UnknownHostException {
return new InetSocketAddress(getInetAddress(), port);
}
代码示例来源:origin: hazelcast/hazelcast-jet
private InetSocketAddress get(Address target) {
try {
InetSocketAddress resolvedAddress = cache.get(target);
if (resolvedAddress != null) {
return resolvedAddress;
}
InetSocketAddress newResolvedAddress = new InetSocketAddress(target.getInetAddress(), target.getPort());
InetSocketAddress prevAddress = cache.putIfAbsent(target, newResolvedAddress);
if (prevAddress != null) {
return prevAddress;
}
return newResolvedAddress;
} catch (UnknownHostException e) {
throw rethrow(e);
}
}
}
代码示例来源:origin: org.bitsofinfo/hazelcast-consul-discovery-spi
@Override
public RegCheck buildRegistrationCheck( Map<String, Object> registratorConfig, Address localAddress) {
RegCheck regCheck = null;
try{
/**
* Deal with health check http
*/
String healthCheckHttp = (String)registratorConfig.get(CONFIG_PROP_HEALTH_CHECK_HTTP);
if (healthCheckHttp != null && !healthCheckHttp.trim().isEmpty()) {
healthCheckHttp = healthCheckHttp.replaceAll(HTTP_TEMPLATE_MYIP, localAddress.getInetAddress().getHostAddress())
.replaceAll(HTTP_TEMPLATE_MYPORT, String.valueOf(localAddress.getPort()));
Long healthCheckHttpIntervalSeconds = Long.valueOf((Integer)registratorConfig.get(CONFIG_PROP_HEALTH_CHECK_HTTP_INTERVAL_SECONDS));
regCheck = Registration.RegCheck.http(healthCheckHttp, healthCheckHttpIntervalSeconds);
}
}catch(Exception e){
logger.severe("Unexpected error occured trying to build HTTP health check : " + e.getMessage(), e);
}
return regCheck;
}
代码示例来源:origin: bitsofinfo/hazelcast-consul-discovery-spi
@Override
public RegCheck buildRegistrationCheck( Map<String, Object> registratorConfig, Address localAddress) {
RegCheck regCheck = null;
try{
/**
* Deal with health check http
*/
String healthCheckHttp = (String)registratorConfig.get(CONFIG_PROP_HEALTH_CHECK_HTTP);
if (healthCheckHttp != null && !healthCheckHttp.trim().isEmpty()) {
healthCheckHttp = healthCheckHttp.replaceAll(HTTP_TEMPLATE_MYIP, localAddress.getInetAddress().getHostAddress())
.replaceAll(HTTP_TEMPLATE_MYPORT, String.valueOf(localAddress.getPort()));
Long healthCheckHttpIntervalSeconds = Long.valueOf((Integer)registratorConfig.get(CONFIG_PROP_HEALTH_CHECK_HTTP_INTERVAL_SECONDS));
regCheck = Registration.RegCheck.http(healthCheckHttp, healthCheckHttpIntervalSeconds);
}
}catch(Exception e){
logger.severe("Unexpected error occured trying to build HTTP health check : " + e.getMessage(), e);
}
return regCheck;
}
代码示例来源:origin: org.bitsofinfo/hazelcast-consul-discovery-spi
@Override
public RegCheck buildRegistrationCheck(Map<String, Object> registratorConfig, Address localAddress) {
RegCheck regCheck = null;
try{
/**
* Deal with health check script
*/
String rawScript = (String)registratorConfig.get(CONFIG_PROP_HEALTH_CHECK_SCRIPT);
if (rawScript != null && !rawScript.trim().isEmpty()) {
Long healthCheckScriptIntervalSeconds = Long.valueOf((Integer)registratorConfig.get(CONFIG_PROP_HEALTH_CHECK_SCRIPT_INTERVAL_SECONDS));
String healthCheckScript = rawScript.replaceAll(HEALTH_SCRIPT_TEMPLATE_MYIP, localAddress.getInetAddress().getHostAddress())
.replaceAll(HEALTH_SCRIPT_TEMPLATE_MYPORT, String.valueOf(localAddress.getPort()));
regCheck = Registration.RegCheck.script(healthCheckScript, healthCheckScriptIntervalSeconds);
}
}catch(Exception e){
logger.severe("Unexpected error occured trying to build HTTP health check : " + e.getMessage(), e);
}
return regCheck;
}
代码示例来源:origin: bitsofinfo/hazelcast-consul-discovery-spi
@Override
public RegCheck buildRegistrationCheck(Map<String, Object> registratorConfig, Address localAddress) {
RegCheck regCheck = null;
try {
/**
* Deal with health check tcp
*/
String healthCheckTcp = (String)registratorConfig.get(CONFIG_PROP_HEALTH_CHECK_TCP);
if (healthCheckTcp != null && !healthCheckTcp.trim().isEmpty()) {
healthCheckTcp = healthCheckTcp.replaceAll(TCP_TEMPLATE_MYIP, localAddress.getInetAddress().getHostAddress())
.replaceAll(TCP_TEMPLATE_MYPORT, String.valueOf(localAddress.getPort()));
Long healthCheckTcpIntervalSeconds = Long.valueOf((Integer)registratorConfig.get(CONFIG_PROP_HEALTH_CHECK_TCP_INTERVAL_SECONDS));
regCheck = Registration.RegCheck.tcp(healthCheckTcp, healthCheckTcpIntervalSeconds);
}
} catch(Exception e) {
logger.severe("Unexpected error occured trying to build TCP health check : " + e.getMessage(), e);
}
return regCheck;
}
代码示例来源:origin: org.bitsofinfo/hazelcast-consul-discovery-spi
@Override
public RegCheck buildRegistrationCheck(Map<String, Object> registratorConfig, Address localAddress) {
RegCheck regCheck = null;
try {
/**
* Deal with health check tcp
*/
String healthCheckTcp = (String)registratorConfig.get(CONFIG_PROP_HEALTH_CHECK_TCP);
if (healthCheckTcp != null && !healthCheckTcp.trim().isEmpty()) {
healthCheckTcp = healthCheckTcp.replaceAll(TCP_TEMPLATE_MYIP, localAddress.getInetAddress().getHostAddress())
.replaceAll(TCP_TEMPLATE_MYPORT, String.valueOf(localAddress.getPort()));
Long healthCheckTcpIntervalSeconds = Long.valueOf((Integer)registratorConfig.get(CONFIG_PROP_HEALTH_CHECK_TCP_INTERVAL_SECONDS));
regCheck = Registration.RegCheck.tcp(healthCheckTcp, healthCheckTcpIntervalSeconds);
}
} catch(Exception e) {
logger.severe("Unexpected error occured trying to build TCP health check : " + e.getMessage(), e);
}
return regCheck;
}
代码示例来源:origin: hazelcast/hazelcast-jet
private InetAddress getInetAddress() throws UnknownHostException {
return ioService.isSocketBindAny() ? null : ioService.getThisAddress().getInetAddress();
}
代码示例来源:origin: com.hazelcast/hazelcast-all
private InetAddress getInetAddress() throws UnknownHostException {
return ioService.isSocketBindAny() ? null : ioService.getThisAddress().getInetAddress();
}
代码示例来源:origin: hazelcast/hazelcast-jet
boolean doPing(Address address, Level level)
throws IOException {
try {
if (address.getInetAddress().isReachable(null, icmpTtl, icmpTimeoutMillis)) {
String msg = format("%s is pinged successfully", address);
logger.log(level, msg);
return true;
}
} catch (ConnectException ignored) {
// no route to host, means we cannot connect anymore
ignore(ignored);
}
return false;
}
代码示例来源:origin: com.hazelcast/hazelcast-all
boolean doPing(Address address, Level level)
throws IOException {
try {
if (address.getInetAddress().isReachable(null, icmpTtl, icmpTimeoutMillis)) {
String msg = format("%s is pinged successfully", address);
logger.log(level, msg);
return true;
}
} catch (ConnectException ignored) {
// no route to host, means we cannot connect anymore
ignore(ignored);
}
return false;
}
代码示例来源:origin: hazelcast/hazelcast-jet
private boolean isSplitLocalForMember(InputSplit split, Address memberAddr) {
try {
final InetAddress inetAddr = memberAddr.getInetAddress();
return Arrays.stream(split.getLocations())
.flatMap(loc -> Arrays.stream(uncheckCall(() -> InetAddress.getAllByName(loc))))
.anyMatch(inetAddr::equals);
} catch (IOException e) {
if (e instanceof UnknownHostException) {
logger.warning("Failed to resolve host name for the split, " +
"will use host name equality to determine data locality", e);
return isSplitLocalForMember(split, memberAddr.getScopedHost());
}
throw sneakyThrow(e);
}
}
代码示例来源:origin: com.hazelcast.jet/hazelcast-jet-hadoop
private boolean isSplitLocalForMember(InputSplit split, Address memberAddr) {
try {
final InetAddress inetAddr = memberAddr.getInetAddress();
return Arrays.stream(split.getLocations())
.flatMap(loc -> Arrays.stream(uncheckCall(() -> InetAddress.getAllByName(loc))))
.anyMatch(inetAddr::equals);
} catch (IOException e) {
if (e instanceof UnknownHostException) {
logger.warning("Failed to resolve host name for the split, " +
"will use host name equality to determine data locality", e);
return isSplitLocalForMember(split, memberAddr.getScopedHost());
}
throw sneakyThrow(e);
}
}
代码示例来源:origin: com.hazelcast/hazelcast-all
public InetAddress getInetAddress() {
try {
return address.getInetAddress();
} catch (UnknownHostException e) {
if (getLogger() != null) {
getLogger().warning(e);
}
return null;
}
}
代码示例来源:origin: hazelcast/hazelcast-jet
public InetAddress getInetAddress() {
try {
return address.getInetAddress();
} catch (UnknownHostException e) {
if (getLogger() != null) {
getLogger().warning(e);
}
return null;
}
}
代码示例来源:origin: hazelcast/hazelcast-jet
private boolean ensureValidBindSource(TcpIpConnection connection, Address remoteEndPoint) {
try {
InetAddress originalRemoteAddr = connection.getRemoteSocketAddress().getAddress();
InetAddress presentedRemoteAddr = remoteEndPoint.getInetAddress();
if (!originalRemoteAddr.equals(presentedRemoteAddr)) {
String msg = "Wrong bind request from " + originalRemoteAddr + ", identified as " + presentedRemoteAddr;
logger.warning(msg);
connection.close(msg, null);
return false;
}
} catch (UnknownHostException e) {
String msg = e.getMessage();
logger.warning(msg);
connection.close(msg, e);
return false;
}
return true;
}
代码示例来源:origin: com.hazelcast/hazelcast-all
private boolean ensureValidBindSource(TcpIpConnection connection, Address remoteEndPoint) {
try {
InetAddress originalRemoteAddr = connection.getRemoteSocketAddress().getAddress();
InetAddress presentedRemoteAddr = remoteEndPoint.getInetAddress();
if (!originalRemoteAddr.equals(presentedRemoteAddr)) {
String msg = "Wrong bind request from " + originalRemoteAddr + ", identified as " + presentedRemoteAddr;
logger.warning(msg);
connection.close(msg, null);
return false;
}
} catch (UnknownHostException e) {
String msg = e.getMessage();
logger.warning(msg);
connection.close(msg, e);
return false;
}
return true;
}
代码示例来源:origin: hazelcast/hazelcast-jet
boolean doPing(Address address, Level level) {
try {
if (address.getInetAddress().isReachable(null, icmpTtl, icmpTimeoutMillis)) {
String msg = format("%s pinged %s successfully", node.getThisAddress(), address);
logger.log(level, msg);
return true;
}
} catch (ConnectException ignored) {
// no route to host, means we cannot connect anymore
ignore(ignored);
} catch (IOException e) {
if (logger.isFinestEnabled()) {
logger.finest("Failed while pinging " + address, e);
}
}
return false;
}
}
代码示例来源:origin: com.hazelcast/hazelcast-all
boolean doPing(Address address, Level level) {
try {
if (address.getInetAddress().isReachable(null, icmpTtl, icmpTimeoutMillis)) {
String msg = format("%s pinged %s successfully", node.getThisAddress(), address);
logger.log(level, msg);
return true;
}
} catch (ConnectException ignored) {
// no route to host, means we cannot connect anymore
ignore(ignored);
} catch (IOException e) {
if (logger.isFinestEnabled()) {
logger.finest("Failed while pinging " + address, e);
}
}
return false;
}
}
内容来源于网络,如有侵权,请联系作者删除!