AnalyticsServiceElasticsearch extends AbstractAnalyticsService { @Override public Set<String> getHostNames(String tenantId, Criteria criteria) { String index = client.getIndex(tenantId); if (!refresh(index)) { return null; } List<Trace> btxns = TraceServiceElasticsearch.internalQuery(client, tenantId, criteria); return btxns.stream() .filter(t -> t.getHostName() != null && !t.getHostName().trim().isEmpty()) .map(Trace::getHostName) .sorted() .collect(Collectors.toSet()); }  @Override List<TransactionInfo> getTransactionInfo(String tenantId, Criteria criteria); @Override List<PropertyInfo> getPropertyInfo(String tenantId, Criteria criteria); @Override long getTraceCompletionCount(String tenantId, Criteria criteria); @Override long getTraceCompletionFaultCount(String tenantId, Criteria criteria); @Override List<CompletionTime> getTraceCompletions(String tenantId, Criteria criteria); @Override Percentiles getTraceCompletionPercentiles(String tenantId, Criteria criteria); @Override List<TimeseriesStatistics> getTraceCompletionTimeseriesStatistics(String tenantId, Criteria criteria, long interval); @Override List<Cardinality> getTraceCompletionFaultDetails(String tenantId, Criteria criteria); @Override List<Cardinality> getTraceCompletionPropertyDetails(String tenantId, Criteria criteria, String property); @Override List<NodeTimeseriesStatistics> getNodeTimeseriesStatistics(String tenantId, Criteria criteria, long interval); @Override Collection<NodeSummaryStatistics> getNodeSummaryStatistics(String tenantId, Criteria criteria); @Override List<TimeseriesStatistics> getEndpointResponseTimeseriesStatistics(String tenantId, Criteria criteria, long interval); @Override Set<String> getHostNames(String tenantId, Criteria criteria); @Override void storeCommunicationDetails(String tenantId, List<CommunicationDetails> communicationDetails); @Override void storeNodeDetails(String tenantId, List<NodeDetails> nodeDetails); @Override void storeTraceCompletions(String tenantId, List<CompletionTime> completionTimes); @Override void clear(String tenantId);  }
@Test public void testHostNames() throws StoreException { Trace trace1 = new Trace(); trace1.setTimestamp(1000); trace1.setHostName("hostA"); Trace trace2 = new Trace(); trace2.setTimestamp(2000); trace2.setHostName("hostB"); bts.storeFragments(null, Arrays.asList(trace1, trace2)); Wait.until(() -> analytics.getHostNames(null, new Criteria().setStartTime(1)).size() == 2); Set<String> hostnames = analytics.getHostNames(null, new Criteria().setStartTime(1)); assertNotNull(hostnames); assertEquals(2, hostnames.size()); assertTrue(hostnames.contains("hostA")); assertTrue(hostnames.contains("hostB")); }