ClusterProtonMetricsRetriever { public Map<String, ProtonMetricsAggregator> requestMetricsGroupedByCluster(Collection<URI> hosts) { Map<String, ProtonMetricsAggregator> clusterMetricsMap = new ConcurrentHashMap<>(); for (URI uri : hosts) { addMetricsFromHost(uri, clusterMetricsMap); } return clusterMetricsMap; }  Map<String, ProtonMetricsAggregator> requestMetricsGroupedByCluster(Collection<URI> hosts);  }
@Test public void testMetricAggregation() throws IOException { List<URI> hosts = Stream.of(1, 2) .map(item -> URI.create("http: .collect(Collectors.toList()); stubFor(get(urlEqualTo("/metrics1/v2/values")) .willReturn(aResponse() .withStatus(200) .withBody(nodeMetrics("_1")))); stubFor(get(urlEqualTo("/metrics2/v2/values")) .willReturn(aResponse() .withStatus(200) .withBody(nodeMetrics("_2")))); String expectedClusterNameContent = "content/content/0/0"; String expectedClusterNameMusic = "content/music/0/0"; Map<String, ProtonMetricsAggregator> aggregatorMap = new ClusterProtonMetricsRetriever().requestMetricsGroupedByCluster(hosts); compareAggregators( new ProtonMetricsAggregator() .addDocumentReadyCount(1275) .addDocumentActiveCount(1275) .addDocumentTotalCount(1275) .addDocumentDiskUsage(14781856) .addResourceDiskUsageAverage(0.0009083386306) .addResourceMemoryUsageAverage(0.0183488434436), aggregatorMap.get(expectedClusterNameContent) ); compareAggregators( new ProtonMetricsAggregator() .addDocumentReadyCount(3008) .addDocumentActiveCount(3008) .addDocumentTotalCount(3008) .addDocumentDiskUsage(331157) .addResourceDiskUsageAverage(0.0000152263558) .addResourceMemoryUsageAverage(0.0156505524171), aggregatorMap.get(expectedClusterNameMusic) ); wireMock.stop(); }