private String getConnectionAddress(CreateEnsembleOptions options) throws UnknownHostException { String oResolver = Strings.isNotBlank(options.getResolver()) ? options.getResolver() : localResolver; String oManualIp = Strings.isNotBlank(options.getManualIp()) ? options.getManualIp() : manualip; if (oResolver.equals(ZkDefs.LOCAL_HOSTNAME)) { return HostUtils.getLocalHostName(); } else if (oResolver.equals(ZkDefs.LOCAL_IP)) { return HostUtils.getLocalIp(); } else if (oResolver.equals(ZkDefs.PUBLIC_HOSTNAME) && (publichostname != null && !publichostname.isEmpty())) { return publichostname; } else if (oResolver.equals(ZkDefs.MANUAL_IP) && (oManualIp != null && !oManualIp.isEmpty())) { return oManualIp; } else { return HostUtils.getLocalHostName(); } }
/** * Returns the local IP. It loops through the network interfaces and returns the first non loopback address * * @return * @throws UnknownHostException */ public static String getLocalIp() throws UnknownHostException { String preffered = System.getProperty(PREFERED_ADDRESS_PROPERTY_NAME); return chooseAddress(preffered).getHostAddress(); }
Set<InetAddress> addresses = getAddresses(); if (preferred != null && !preferred.isEmpty()) {
/** * Returns a {@link Set} of {@link InetAddress} that are non-loopback or mac. * @return */ public static Set<InetAddress> getAddresses() { Set<InetAddress> allAddresses = new LinkedHashSet<InetAddress>(); Map<String, Set<InetAddress>> interfaceAddressMap = getNetworkInterfaceAddresses(); for (Map.Entry<String, Set<InetAddress>> entry : interfaceAddressMap.entrySet()) { Set<InetAddress> addresses = entry.getValue(); if (!addresses.isEmpty()) { for (InetAddress address : addresses) { allAddresses.add(address); } } } return allAddresses; }
/** * Returns a {@link Set} of {@link InetAddress} that are non-loopback or mac. * @return */ public static Set<InetAddress> getAddresses() { Set<InetAddress> allAddresses = new LinkedHashSet<InetAddress>(); Map<String, Set<InetAddress>> interfaceAddressMap = getNetworkInterfaceAddresses(); for (Map.Entry<String, Set<InetAddress>> entry : interfaceAddressMap.entrySet()) { Set<InetAddress> addresses = entry.getValue(); if (!addresses.isEmpty()) { for (InetAddress address : addresses) { allAddresses.add(address); } } } return allAddresses; }
private String getConnectionAddress(CreateEnsembleOptions options) throws UnknownHostException { String oResolver = Strings.isNotBlank(options.getResolver()) ? options.getResolver() : localResolver; String oManualIp = Strings.isNotBlank(options.getManualIp()) ? options.getManualIp() : manualip; if (oResolver.equals(ZkDefs.LOCAL_HOSTNAME)) { return HostUtils.getLocalHostName(); } else if (oResolver.equals(ZkDefs.LOCAL_IP)) { return HostUtils.getLocalIp(); } else if (oResolver.equals(ZkDefs.PUBLIC_HOSTNAME) && (publichostname != null && !publichostname.isEmpty())) { return publichostname; } else if (oResolver.equals(ZkDefs.MANUAL_IP) && (oManualIp != null && !oManualIp.isEmpty())) { return oManualIp; } else { return HostUtils.getLocalHostName(); } }
/** * Returns the local hostname. It loops through the network interfaces and returns the first non loopback address * * @return * @throws java.net.UnknownHostException */ public static String getLocalHostName() throws UnknownHostException { String preffered = System.getProperty(PREFERED_ADDRESS_PROPERTY_NAME); return chooseAddress(preffered).getHostName(); }
Set<InetAddress> addresses = getAddresses(); if (preferred != null && !preferred.isEmpty()) {
setData(curator.get(), CONTAINER_LOCAL_HOSTNAME.getPath(runtimeIdentity), HostUtils.getLocalHostName()); if (openshiftEnv) { setData(curator.get(), CONTAINER_LOCAL_IP.getPath(runtimeIdentity), System.getenv("OPENSHIFT_FUSE_IP")); setData(curator.get(), CONTAINER_PUBLIC_IP.getPath(runtimeIdentity), HostUtils.getLocalIp()); } else { setData(curator.get(), CONTAINER_LOCAL_IP.getPath(runtimeIdentity), HostUtils.getLocalIp());
/** * Returns the local hostname. It loops through the network interfaces and returns the first non loopback address * * @return * @throws java.net.UnknownHostException */ public static String getLocalHostName() throws UnknownHostException { String preffered = System.getProperty(PREFERED_ADDRESS_PROPERTY_NAME); return chooseAddress(preffered).getHostName(); }
setData(curator.get(), CONTAINER_LOCAL_HOSTNAME.getPath(runtimeIdentity), HostUtils.getLocalHostName()); if (openshiftEnv) { setData(curator.get(), CONTAINER_LOCAL_IP.getPath(runtimeIdentity), System.getenv("OPENSHIFT_FUSE_IP")); setData(curator.get(), CONTAINER_PUBLIC_IP.getPath(runtimeIdentity), HostUtils.getLocalIp()); } else { setData(curator.get(), CONTAINER_LOCAL_IP.getPath(runtimeIdentity), HostUtils.getLocalIp());
/** * Returns the local IP. It loops through the network interfaces and returns the first non loopback address * * @return * @throws UnknownHostException */ public static String getLocalIp() throws UnknownHostException { String preffered = System.getProperty(PREFERED_ADDRESS_PROPERTY_NAME); return chooseAddress(preffered).getHostAddress(); }
ZooKeeperUtils.setData(curator.get(), CONTAINER_LOCAL_HOSTNAME.getPath(karafName), HostUtils.getLocalHostName()); ZooKeeperUtils.setData(curator.get(), CONTAINER_LOCAL_IP.getPath(karafName), HostUtils.getLocalIp()); ZooKeeperUtils.setData(curator.get(), CONTAINER_IP.getPath(karafName), getContainerPointer(curator.get(), karafName)); ZooKeeperUtils.createDefault(curator.get(), CONTAINER_GEOLOCATION.getPath(karafName), geoLocationService.get().getGeoLocation());
ZooKeeperUtils.setData(curator.get(), CONTAINER_LOCAL_HOSTNAME.getPath(runtimeIdentity), HostUtils.getLocalHostName()); ZooKeeperUtils.setData(curator.get(), CONTAINER_LOCAL_IP.getPath(runtimeIdentity), HostUtils.getLocalIp());
ZooKeeperUtils.setData(curator.get(), CONTAINER_LOCAL_HOSTNAME.getPath(karafName), HostUtils.getLocalHostName()); ZooKeeperUtils.setData(curator.get(), CONTAINER_LOCAL_IP.getPath(karafName), HostUtils.getLocalIp()); ZooKeeperUtils.setData(curator.get(), CONTAINER_IP.getPath(karafName), getContainerPointer(curator.get(), karafName)); ZooKeeperUtils.createDefault(curator.get(), CONTAINER_GEOLOCATION.getPath(karafName), geoLocationService.get().getGeoLocation());
ZooKeeperUtils.setData(curator.get(), CONTAINER_LOCAL_HOSTNAME.getPath(runtimeIdentity), HostUtils.getLocalHostName()); ZooKeeperUtils.setData(curator.get(), CONTAINER_LOCAL_IP.getPath(runtimeIdentity), HostUtils.getLocalIp()); ZooKeeperUtils.setData(curator.get(), CONTAINER_IP.getPath(runtimeIdentity), getContainerPointer(curator.get(), runtimeIdentity));
ZooKeeperUtils.setData(curator.get(), CONTAINER_LOCAL_HOSTNAME.getPath(runtimeIdentity), HostUtils.getLocalHostName()); ZooKeeperUtils.setData(curator.get(), CONTAINER_LOCAL_IP.getPath(runtimeIdentity), HostUtils.getLocalIp()); ZooKeeperUtils.setData(curator.get(), CONTAINER_IP.getPath(runtimeIdentity), getContainerPointer(curator.get(), runtimeIdentity)); ZooKeeperUtils.createDefault(curator.get(), CONTAINER_GEOLOCATION.getPath(runtimeIdentity), geoLocationService.get().getGeoLocation());