com.hazelcast.nio.Address.getInetAddress()方法的使用及代码示例

x33g5p2x  于2022-01-16 转载在 其他  
字(10.5k)|赞(0)|评价(0)|浏览(118)

本文整理了Java中com.hazelcast.nio.Address.getInetAddress()方法的一些代码示例,展示了Address.getInetAddress()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Address.getInetAddress()方法的具体详情如下:
包路径:com.hazelcast.nio.Address
类名称:Address
方法名:getInetAddress

Address.getInetAddress介绍

暂无

代码示例

代码示例来源:origin: com.hazelcast/hazelcast-all

  1. public InetSocketAddress getInetSocketAddress() throws UnknownHostException {
  2. return new InetSocketAddress(getInetAddress(), port);
  3. }

代码示例来源:origin: hazelcast/hazelcast-jet

  1. public InetSocketAddress getInetSocketAddress() throws UnknownHostException {
  2. return new InetSocketAddress(getInetAddress(), port);
  3. }

代码示例来源:origin: hazelcast/hazelcast-jet

  1. private InetSocketAddress get(Address target) {
  2. try {
  3. InetSocketAddress resolvedAddress = cache.get(target);
  4. if (resolvedAddress != null) {
  5. return resolvedAddress;
  6. }
  7. InetSocketAddress newResolvedAddress = new InetSocketAddress(target.getInetAddress(), target.getPort());
  8. InetSocketAddress prevAddress = cache.putIfAbsent(target, newResolvedAddress);
  9. if (prevAddress != null) {
  10. return prevAddress;
  11. }
  12. return newResolvedAddress;
  13. } catch (UnknownHostException e) {
  14. throw rethrow(e);
  15. }
  16. }
  17. }

代码示例来源:origin: org.bitsofinfo/hazelcast-consul-discovery-spi

  1. @Override
  2. public RegCheck buildRegistrationCheck( Map<String, Object> registratorConfig, Address localAddress) {
  3. RegCheck regCheck = null;
  4. try{
  5. /**
  6. * Deal with health check http
  7. */
  8. String healthCheckHttp = (String)registratorConfig.get(CONFIG_PROP_HEALTH_CHECK_HTTP);
  9. if (healthCheckHttp != null && !healthCheckHttp.trim().isEmpty()) {
  10. healthCheckHttp = healthCheckHttp.replaceAll(HTTP_TEMPLATE_MYIP, localAddress.getInetAddress().getHostAddress())
  11. .replaceAll(HTTP_TEMPLATE_MYPORT, String.valueOf(localAddress.getPort()));
  12. Long healthCheckHttpIntervalSeconds = Long.valueOf((Integer)registratorConfig.get(CONFIG_PROP_HEALTH_CHECK_HTTP_INTERVAL_SECONDS));
  13. regCheck = Registration.RegCheck.http(healthCheckHttp, healthCheckHttpIntervalSeconds);
  14. }
  15. }catch(Exception e){
  16. logger.severe("Unexpected error occured trying to build HTTP health check : " + e.getMessage(), e);
  17. }
  18. return regCheck;
  19. }

代码示例来源:origin: bitsofinfo/hazelcast-consul-discovery-spi

  1. @Override
  2. public RegCheck buildRegistrationCheck( Map<String, Object> registratorConfig, Address localAddress) {
  3. RegCheck regCheck = null;
  4. try{
  5. /**
  6. * Deal with health check http
  7. */
  8. String healthCheckHttp = (String)registratorConfig.get(CONFIG_PROP_HEALTH_CHECK_HTTP);
  9. if (healthCheckHttp != null && !healthCheckHttp.trim().isEmpty()) {
  10. healthCheckHttp = healthCheckHttp.replaceAll(HTTP_TEMPLATE_MYIP, localAddress.getInetAddress().getHostAddress())
  11. .replaceAll(HTTP_TEMPLATE_MYPORT, String.valueOf(localAddress.getPort()));
  12. Long healthCheckHttpIntervalSeconds = Long.valueOf((Integer)registratorConfig.get(CONFIG_PROP_HEALTH_CHECK_HTTP_INTERVAL_SECONDS));
  13. regCheck = Registration.RegCheck.http(healthCheckHttp, healthCheckHttpIntervalSeconds);
  14. }
  15. }catch(Exception e){
  16. logger.severe("Unexpected error occured trying to build HTTP health check : " + e.getMessage(), e);
  17. }
  18. return regCheck;
  19. }

代码示例来源:origin: org.bitsofinfo/hazelcast-consul-discovery-spi

  1. @Override
  2. public RegCheck buildRegistrationCheck(Map<String, Object> registratorConfig, Address localAddress) {
  3. RegCheck regCheck = null;
  4. try{
  5. /**
  6. * Deal with health check script
  7. */
  8. String rawScript = (String)registratorConfig.get(CONFIG_PROP_HEALTH_CHECK_SCRIPT);
  9. if (rawScript != null && !rawScript.trim().isEmpty()) {
  10. Long healthCheckScriptIntervalSeconds = Long.valueOf((Integer)registratorConfig.get(CONFIG_PROP_HEALTH_CHECK_SCRIPT_INTERVAL_SECONDS));
  11. String healthCheckScript = rawScript.replaceAll(HEALTH_SCRIPT_TEMPLATE_MYIP, localAddress.getInetAddress().getHostAddress())
  12. .replaceAll(HEALTH_SCRIPT_TEMPLATE_MYPORT, String.valueOf(localAddress.getPort()));
  13. regCheck = Registration.RegCheck.script(healthCheckScript, healthCheckScriptIntervalSeconds);
  14. }
  15. }catch(Exception e){
  16. logger.severe("Unexpected error occured trying to build HTTP health check : " + e.getMessage(), e);
  17. }
  18. return regCheck;
  19. }

代码示例来源:origin: bitsofinfo/hazelcast-consul-discovery-spi

  1. @Override
  2. public RegCheck buildRegistrationCheck(Map<String, Object> registratorConfig, Address localAddress) {
  3. RegCheck regCheck = null;
  4. try {
  5. /**
  6. * Deal with health check tcp
  7. */
  8. String healthCheckTcp = (String)registratorConfig.get(CONFIG_PROP_HEALTH_CHECK_TCP);
  9. if (healthCheckTcp != null && !healthCheckTcp.trim().isEmpty()) {
  10. healthCheckTcp = healthCheckTcp.replaceAll(TCP_TEMPLATE_MYIP, localAddress.getInetAddress().getHostAddress())
  11. .replaceAll(TCP_TEMPLATE_MYPORT, String.valueOf(localAddress.getPort()));
  12. Long healthCheckTcpIntervalSeconds = Long.valueOf((Integer)registratorConfig.get(CONFIG_PROP_HEALTH_CHECK_TCP_INTERVAL_SECONDS));
  13. regCheck = Registration.RegCheck.tcp(healthCheckTcp, healthCheckTcpIntervalSeconds);
  14. }
  15. } catch(Exception e) {
  16. logger.severe("Unexpected error occured trying to build TCP health check : " + e.getMessage(), e);
  17. }
  18. return regCheck;
  19. }

代码示例来源:origin: org.bitsofinfo/hazelcast-consul-discovery-spi

  1. @Override
  2. public RegCheck buildRegistrationCheck(Map<String, Object> registratorConfig, Address localAddress) {
  3. RegCheck regCheck = null;
  4. try {
  5. /**
  6. * Deal with health check tcp
  7. */
  8. String healthCheckTcp = (String)registratorConfig.get(CONFIG_PROP_HEALTH_CHECK_TCP);
  9. if (healthCheckTcp != null && !healthCheckTcp.trim().isEmpty()) {
  10. healthCheckTcp = healthCheckTcp.replaceAll(TCP_TEMPLATE_MYIP, localAddress.getInetAddress().getHostAddress())
  11. .replaceAll(TCP_TEMPLATE_MYPORT, String.valueOf(localAddress.getPort()));
  12. Long healthCheckTcpIntervalSeconds = Long.valueOf((Integer)registratorConfig.get(CONFIG_PROP_HEALTH_CHECK_TCP_INTERVAL_SECONDS));
  13. regCheck = Registration.RegCheck.tcp(healthCheckTcp, healthCheckTcpIntervalSeconds);
  14. }
  15. } catch(Exception e) {
  16. logger.severe("Unexpected error occured trying to build TCP health check : " + e.getMessage(), e);
  17. }
  18. return regCheck;
  19. }

代码示例来源:origin: hazelcast/hazelcast-jet

  1. private InetAddress getInetAddress() throws UnknownHostException {
  2. return ioService.isSocketBindAny() ? null : ioService.getThisAddress().getInetAddress();
  3. }

代码示例来源:origin: com.hazelcast/hazelcast-all

  1. private InetAddress getInetAddress() throws UnknownHostException {
  2. return ioService.isSocketBindAny() ? null : ioService.getThisAddress().getInetAddress();
  3. }

代码示例来源:origin: hazelcast/hazelcast-jet

  1. boolean doPing(Address address, Level level)
  2. throws IOException {
  3. try {
  4. if (address.getInetAddress().isReachable(null, icmpTtl, icmpTimeoutMillis)) {
  5. String msg = format("%s is pinged successfully", address);
  6. logger.log(level, msg);
  7. return true;
  8. }
  9. } catch (ConnectException ignored) {
  10. // no route to host, means we cannot connect anymore
  11. ignore(ignored);
  12. }
  13. return false;
  14. }

代码示例来源:origin: com.hazelcast/hazelcast-all

  1. boolean doPing(Address address, Level level)
  2. throws IOException {
  3. try {
  4. if (address.getInetAddress().isReachable(null, icmpTtl, icmpTimeoutMillis)) {
  5. String msg = format("%s is pinged successfully", address);
  6. logger.log(level, msg);
  7. return true;
  8. }
  9. } catch (ConnectException ignored) {
  10. // no route to host, means we cannot connect anymore
  11. ignore(ignored);
  12. }
  13. return false;
  14. }

代码示例来源:origin: hazelcast/hazelcast-jet

  1. private boolean isSplitLocalForMember(InputSplit split, Address memberAddr) {
  2. try {
  3. final InetAddress inetAddr = memberAddr.getInetAddress();
  4. return Arrays.stream(split.getLocations())
  5. .flatMap(loc -> Arrays.stream(uncheckCall(() -> InetAddress.getAllByName(loc))))
  6. .anyMatch(inetAddr::equals);
  7. } catch (IOException e) {
  8. if (e instanceof UnknownHostException) {
  9. logger.warning("Failed to resolve host name for the split, " +
  10. "will use host name equality to determine data locality", e);
  11. return isSplitLocalForMember(split, memberAddr.getScopedHost());
  12. }
  13. throw sneakyThrow(e);
  14. }
  15. }

代码示例来源:origin: com.hazelcast.jet/hazelcast-jet-hadoop

  1. private boolean isSplitLocalForMember(InputSplit split, Address memberAddr) {
  2. try {
  3. final InetAddress inetAddr = memberAddr.getInetAddress();
  4. return Arrays.stream(split.getLocations())
  5. .flatMap(loc -> Arrays.stream(uncheckCall(() -> InetAddress.getAllByName(loc))))
  6. .anyMatch(inetAddr::equals);
  7. } catch (IOException e) {
  8. if (e instanceof UnknownHostException) {
  9. logger.warning("Failed to resolve host name for the split, " +
  10. "will use host name equality to determine data locality", e);
  11. return isSplitLocalForMember(split, memberAddr.getScopedHost());
  12. }
  13. throw sneakyThrow(e);
  14. }
  15. }

代码示例来源:origin: com.hazelcast/hazelcast-all

  1. public InetAddress getInetAddress() {
  2. try {
  3. return address.getInetAddress();
  4. } catch (UnknownHostException e) {
  5. if (getLogger() != null) {
  6. getLogger().warning(e);
  7. }
  8. return null;
  9. }
  10. }

代码示例来源:origin: hazelcast/hazelcast-jet

  1. public InetAddress getInetAddress() {
  2. try {
  3. return address.getInetAddress();
  4. } catch (UnknownHostException e) {
  5. if (getLogger() != null) {
  6. getLogger().warning(e);
  7. }
  8. return null;
  9. }
  10. }

代码示例来源:origin: hazelcast/hazelcast-jet

  1. private boolean ensureValidBindSource(TcpIpConnection connection, Address remoteEndPoint) {
  2. try {
  3. InetAddress originalRemoteAddr = connection.getRemoteSocketAddress().getAddress();
  4. InetAddress presentedRemoteAddr = remoteEndPoint.getInetAddress();
  5. if (!originalRemoteAddr.equals(presentedRemoteAddr)) {
  6. String msg = "Wrong bind request from " + originalRemoteAddr + ", identified as " + presentedRemoteAddr;
  7. logger.warning(msg);
  8. connection.close(msg, null);
  9. return false;
  10. }
  11. } catch (UnknownHostException e) {
  12. String msg = e.getMessage();
  13. logger.warning(msg);
  14. connection.close(msg, e);
  15. return false;
  16. }
  17. return true;
  18. }

代码示例来源:origin: com.hazelcast/hazelcast-all

  1. private boolean ensureValidBindSource(TcpIpConnection connection, Address remoteEndPoint) {
  2. try {
  3. InetAddress originalRemoteAddr = connection.getRemoteSocketAddress().getAddress();
  4. InetAddress presentedRemoteAddr = remoteEndPoint.getInetAddress();
  5. if (!originalRemoteAddr.equals(presentedRemoteAddr)) {
  6. String msg = "Wrong bind request from " + originalRemoteAddr + ", identified as " + presentedRemoteAddr;
  7. logger.warning(msg);
  8. connection.close(msg, null);
  9. return false;
  10. }
  11. } catch (UnknownHostException e) {
  12. String msg = e.getMessage();
  13. logger.warning(msg);
  14. connection.close(msg, e);
  15. return false;
  16. }
  17. return true;
  18. }

代码示例来源:origin: hazelcast/hazelcast-jet

  1. boolean doPing(Address address, Level level) {
  2. try {
  3. if (address.getInetAddress().isReachable(null, icmpTtl, icmpTimeoutMillis)) {
  4. String msg = format("%s pinged %s successfully", node.getThisAddress(), address);
  5. logger.log(level, msg);
  6. return true;
  7. }
  8. } catch (ConnectException ignored) {
  9. // no route to host, means we cannot connect anymore
  10. ignore(ignored);
  11. } catch (IOException e) {
  12. if (logger.isFinestEnabled()) {
  13. logger.finest("Failed while pinging " + address, e);
  14. }
  15. }
  16. return false;
  17. }
  18. }

代码示例来源:origin: com.hazelcast/hazelcast-all

  1. boolean doPing(Address address, Level level) {
  2. try {
  3. if (address.getInetAddress().isReachable(null, icmpTtl, icmpTimeoutMillis)) {
  4. String msg = format("%s pinged %s successfully", node.getThisAddress(), address);
  5. logger.log(level, msg);
  6. return true;
  7. }
  8. } catch (ConnectException ignored) {
  9. // no route to host, means we cannot connect anymore
  10. ignore(ignored);
  11. } catch (IOException e) {
  12. if (logger.isFinestEnabled()) {
  13. logger.finest("Failed while pinging " + address, e);
  14. }
  15. }
  16. return false;
  17. }
  18. }

相关文章