@Test public void testBothHostIsContacted() { Set<String> hosts = nodeSniffer.getAvailableNodes(new String[]{"http: assertEquals("Should be one host",3,hosts.size()); assertEquals("parsed host should be: http: assertEquals("parsed host should be: http: assertEquals("parsed host should be: http: wireMockRule1.verify(1,getRequestedFor(urlMatching(ConfigurationConstants.DEFAULT_ELASTIC_SEARCH_HTTP_NODE_SNIFFING_ENDPOINT))); wireMockRule2.verify(1,getRequestedFor(urlMatching(ConfigurationConstants.DEFAULT_ELASTIC_SEARCH_HTTP_NODE_SNIFFING_ENDPOINT))); }
@Override public Set<String> getAvailableNodes(String[] hosts) { Set<String> newHosts = new TreeSet<>(); for(String host : hosts) { HttpResult result = AHCRequestExecutor.executeSearch(client, HttpMethod.GET, host, NODE_ENDPOINT, null); if(result.getStatus()== HttpSearchExecutionStatus.OK) { newHosts.addAll(HostParsingUtil.parseAvailablePublishedHttpServerAddresses(result.getResult())); } } return newHosts; }
AHCHttpSniffAvailableNodes implements SniffAvailableNodes { @Override public Set<String> getAvailableNodes(String[] hosts) { Set<String> newHosts = new TreeSet<>(); for(String host : hosts) { HttpResult result = AHCRequestExecutor.executeSearch(client, HttpMethod.GET, host, NODE_ENDPOINT, null); if(result.getStatus()== HttpSearchExecutionStatus.OK) { newHosts.addAll(HostParsingUtil.parseAvailablePublishedHttpServerAddresses(result.getResult())); } } return newHosts; } }
AHCHttpSniffAvailableNodes implements SniffAvailableNodes { @Override public Set<String> getAvailableNodes(String[] hosts) { Set<String> newHosts = new TreeSet<>(); for(String host : hosts) { HttpResult result = AHCRequestExecutor.executeSearch(client, HttpMethod.GET, host, NODE_ENDPOINT, null); if(result.getStatus()== HttpSearchExecutionStatus.OK) { newHosts.addAll(HostParsingUtil.parseAvailablePublishedHttpServerAddresses(result.getResult())); } } return newHosts; } AHCHttpSniffAvailableNodes(Configuration configuration); }
AHCHttpSniffAvailableNodes implements SniffAvailableNodes { @Override public Set<String> getAvailableNodes(String[] hosts) { Set<String> newHosts = new TreeSet<>(); for(String host : hosts) { HttpResult result = AHCRequestExecutor.executeSearch(client, HttpMethod.GET, host, NODE_ENDPOINT, null); if(result.getStatus()== HttpSearchExecutionStatus.OK) { newHosts.addAll(HostParsingUtil.parseAvailablePublishedHttpServerAddresses(result.getResult())); } } return newHosts; } AHCHttpSniffAvailableNodes(Configuration configuration); @Override Set<String> getAvailableNodes(String[] hosts); @Override void shutdown(); }
AHCHttpSniffAvailableNodes implements SniffAvailableNodes { @Override public Set<String> getAvailableNodes(String[] hosts) { Set<String> newHosts = new TreeSet<>(); for(String host : hosts) { HttpResult result = AHCRequestExecutor.executeSearch(client, HttpMethod.GET, host, NODE_ENDPOINT, null); if(result.getStatus()== HttpSearchExecutionStatus.OK) { newHosts.addAll(HostParsingUtil.parseAvailablePublishedHttpServerAddresses(result.getResult())); } } return newHosts; } AHCHttpSniffAvailableNodes(Configuration configuration); @Override Set<String> getAvailableNodes(String[] hosts); @Override void shutdown(); final String NODE_ENDPOINT; }