private AddressDefinition getPublicAddressByPortSearch() throws IOException { boolean bindAny = hazelcastProperties.getBoolean(GroupProperty.SOCKET_SERVER_BIND_ANY); AddressDefinition bindAddressDef = pickAddressDef(); int port = createServerSocketChannel(bindAddressDef.inetAddress, bindAddressDef.port, bindAny); bindAddress = createAddress(bindAddressDef, port); logger.info("Picked " + bindAddress + ", using socket " + getServerSocketChannel().socket() + ", bind any local is " + bindAny); return getPublicAddress(port); }
private AddressDefinition getPublicAddressByPortSearch() throws IOException { boolean bindAny = hazelcastProperties.getBoolean(GroupProperty.SOCKET_SERVER_BIND_ANY); AddressDefinition bindAddressDef = pickAddressDef(); int port = createServerSocketChannel(bindAddressDef.inetAddress, bindAddressDef.port, bindAny); bindAddress = createAddress(bindAddressDef, port); logger.info("Picked " + bindAddress + ", using socket " + getServerSocketChannel().socket() + ", bind any local is " + bindAny); return getPublicAddress(port); }
@Override public void pickAddress() throws Exception { if (publicAddress != null || bindAddress != null) { return; } try { AddressDefinition publicAddressDef = getPublicAddressByPortSearch(); if (publicAddressDef != null) { publicAddress = createAddress(publicAddressDef, publicAddressDef.port); logger.info("Using public address: " + publicAddress); } else { publicAddress = bindAddress; logger.finest("Using public address the same as the bind address: " + publicAddress); } } catch (Exception e) { ServerSocketChannel serverSocketChannel = getServerSocketChannel(); if (serverSocketChannel != null) { serverSocketChannel.close(); } logger.severe(e); throw e; } }
@Override public void pickAddress() throws Exception { if (publicAddress != null || bindAddress != null) { return; } try { AddressDefinition publicAddressDef = getPublicAddressByPortSearch(); if (publicAddressDef != null) { publicAddress = createAddress(publicAddressDef, publicAddressDef.port); logger.info("Using public address: " + publicAddress); } else { publicAddress = bindAddress; logger.finest("Using public address the same as the bind address: " + publicAddress); } } catch (Exception e) { ServerSocketChannel serverSocketChannel = getServerSocketChannel(); if (serverSocketChannel != null) { serverSocketChannel.close(); } logger.severe(e); throw e; } }