public InetSocketAddress getInetSocketAddress() throws UnknownHostException { return new InetSocketAddress(getInetAddress(), port); }
public InetSocketAddress getInetSocketAddress() throws UnknownHostException { return new InetSocketAddress(getInetAddress(), port); }
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); } } }
@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; }
@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; }
@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; }
@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; }
@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; }
private InetAddress getInetAddress() throws UnknownHostException { return ioService.isSocketBindAny() ? null : ioService.getThisAddress().getInetAddress(); }
private InetAddress getInetAddress() throws UnknownHostException { return ioService.isSocketBindAny() ? null : ioService.getThisAddress().getInetAddress(); }
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; }
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; }
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); } }
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); } }
public InetAddress getInetAddress() { try { return address.getInetAddress(); } catch (UnknownHostException e) { if (getLogger() != null) { getLogger().warning(e); } return null; } }
public InetAddress getInetAddress() { try { return address.getInetAddress(); } catch (UnknownHostException e) { if (getLogger() != null) { getLogger().warning(e); } return null; } }
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; }
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; }
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; } }
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; } }