public String[] getHostNames() { String[] newLocations = new String[locations.length]; for (int i = 0; i < locations.length; i++) { newLocations[i] = StringUtils.parseIpAddress(locations[i]).ip; } return newLocations; }
/** * Returns the first address in {@code locations} that is equals to a public IP of the system * @param locations The list of address (hostname:port or ip:port) to check * @return The first address in {@code locations} that is equals to a public IP of the system or null if none */ static String checkLocality(String[] locations, Log log) { try { InetAddress[] candidates = NetworkUtils.getGlobalInterfaces(); for (String address : locations) { StringUtils.IpAndPort ipAndPort = StringUtils.parseIpAddress(address); InetAddress addr = InetAddress.getByName(ipAndPort.ip); for (InetAddress candidate : candidates) { if (addr.equals(candidate)) { return address; } } } } catch (SocketException e) { if (log.isDebugEnabled()) { log.debug("Unable to retrieve the global interfaces of the system", e); } } catch (UnknownHostException e) { if (log.isDebugEnabled()) { log.debug("Unable to retrieve IP address", e); } } return null; }
String addr = (String) httpMap.get("publish_address"); if (addr != null) { StringUtils.IpAndPort ipAndPort = StringUtils.parseIpAddress(addr); this.publishAddress = ipAndPort.ip + ":" + ipAndPort.port; this.hasHttp = true;
@Test public void testParseIpInEs1xWithHostName() { assertEquals("11.22.33.44", StringUtils.parseIpAddress("inet[foobar/11.22.33.44:9200]").ip); }
@Test public void testParseIpInEs2x() { assertEquals("111.222.333.444", StringUtils.parseIpAddress("111.222.333.444:9200").ip); }
@Test public void testParseIpInEs1x() { assertEquals("1.2.3.4", StringUtils.parseIpAddress("inet[/1.2.3.4:9200]").ip); }
@Test public void testParseIpInEs2xWithHostName() { assertEquals("11.222.3.4", StringUtils.parseIpAddress("foobar/11.222.3.4:9200").ip); }
public String[] getHostNames() { String[] newLocations = new String[locations.length]; for (int i = 0; i < locations.length; i++) { newLocations[i] = StringUtils.parseIpAddress(locations[i]).ip; } return newLocations; }
public String[] getHostNames() { String[] newLocations = new String[locations.length]; for (int i = 0; i < locations.length; i++) { newLocations[i] = StringUtils.parseIpAddress(locations[i]).ip; } return newLocations; }
public String[] getHostNames() { String[] newLocations = new String[locations.length]; for (int i = 0; i < locations.length; i++) { newLocations[i] = StringUtils.parseIpAddress(locations[i]).ip; } return newLocations; }
public Node(String id, Map<String, Object> data) { this.id = id; name = data.get("name").toString(); Object http = data.get("http_address"); hasHttp = (http != null); Map<String, Object> attributes = (Map<String, Object>) data.get("attributes"); if (attributes != null) { isClient = ("false".equals(attributes.get("data")) && "false".equals(attributes.get("master"))); isData = !"false".equals(attributes.get("data")); } if (!hasHttp) { return; } IpAndPort ip = StringUtils.parseIpAddress(http.toString()); ipAddress = ip.ip; httpPort = ip.port; }
@SuppressWarnings({ "rawtypes", "unchecked" }) public List<String> discoverNodes() { String endpoint = "_nodes/transport"; Map<String, Map> nodes = (Map<String, Map>) get(endpoint, "nodes"); List<String> hosts = new ArrayList<String>(nodes.size()); for (Map value : nodes.values()) { String inet = (String) value.get("http_address"); if (StringUtils.hasText(inet)) { hosts.add(StringUtils.parseIpAddress(inet).toString()); } } return hosts; }
/** * Returns the first address in {@code locations} that is equals to a public IP of the system * @param locations The list of address (hostname:port or ip:port) to check * @return The first address in {@code locations} that is equals to a public IP of the system or null if none */ static String checkLocality(String[] locations, Log log) { try { InetAddress[] candidates = NetworkUtils.getGlobalInterfaces(); for (String address : locations) { StringUtils.IpAndPort ipAndPort = StringUtils.parseIpAddress(address); InetAddress addr = InetAddress.getByName(ipAndPort.ip); for (InetAddress candidate : candidates) { if (addr.equals(candidate)) { return address; } } } } catch (SocketException e) { if (log.isDebugEnabled()) { log.debug("Unable to retrieve the global interfaces of the system", e); } } catch (UnknownHostException e) { if (log.isDebugEnabled()) { log.debug("Unable to retrieve IP address", e); } } return null; }
/** * Returns the first address in {@code locations} that is equals to a public IP of the system * @param locations The list of address (hostname:port or ip:port) to check * @return The first address in {@code locations} that is equals to a public IP of the system or null if none */ static String checkLocality(String[] locations, Log log) { try { InetAddress[] candidates = NetworkUtils.getGlobalInterfaces(); for (String address : locations) { StringUtils.IpAndPort ipAndPort = StringUtils.parseIpAddress(address); InetAddress addr = InetAddress.getByName(ipAndPort.ip); for (InetAddress candidate : candidates) { if (addr.equals(candidate)) { return address; } } } } catch (SocketException e) { if (log.isDebugEnabled()) { log.debug("Unable to retrieve the global interfaces of the system", e); } } catch (UnknownHostException e) { if (log.isDebugEnabled()) { log.debug("Unable to retrieve IP address", e); } } return null; }
/** * Returns the first address in {@code locations} that is equals to a public IP of the system * @param locations The list of address (hostname:port or ip:port) to check * @return The first address in {@code locations} that is equals to a public IP of the system or null if none */ static String checkLocality(String[] locations, Log log) { try { InetAddress[] candidates = NetworkUtils.getGlobalInterfaces(); for (String address : locations) { StringUtils.IpAndPort ipAndPort = StringUtils.parseIpAddress(address); InetAddress addr = InetAddress.getByName(ipAndPort.ip); for (InetAddress candidate : candidates) { if (addr.equals(candidate)) { return address; } } } } catch (SocketException e) { if (log.isDebugEnabled()) { log.debug("Unable to retrieve the global interfaces of the system", e); } } catch (UnknownHostException e) { if (log.isDebugEnabled()) { log.debug("Unable to retrieve IP address", e); } } return null; }
String addr = (String) httpMap.get("publish_address"); if (addr != null) { StringUtils.IpAndPort ipAndPort = StringUtils.parseIpAddress(addr); this.publishAddress = ipAndPort.ip + ":" + ipAndPort.port; this.hasHttp = true;
String addr = (String) httpMap.get("publish_address"); if (addr != null) { StringUtils.IpAndPort ipAndPort = StringUtils.parseIpAddress(addr); this.publishAddress = ipAndPort.ip + ":" + ipAndPort.port; this.hasHttp = true;
String addr = (String) httpMap.get("publish_address"); if (addr != null) { StringUtils.IpAndPort ipAndPort = StringUtils.parseIpAddress(addr); this.publishAddress = ipAndPort.ip + ":" + ipAndPort.port; this.hasHttp = true;
String nodeAddress = nodes.get(nextInt); Node node = new Node(shard.getNode(), "wan-only-node-" + nextInt, StringUtils.parseIpAddress(nodeAddress)); httpNodes.put(shard.getNode(), node);