Use a ConcurrentHashMap for metrics snapshots for each node.
@@ -13,9 +13,11 @@ import java.io.IOException;
import java.time.Clock;
import java.time.Duration;
import java.time.Instant;
+import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
+import java.util.concurrent.ConcurrentHashMap;
import java.util.logging.Logger;
import static com.yahoo.log.LogLevel.DEBUG;
@@ -41,7 +43,7 @@ public class NodeMetricsClient {
private final HttpClient httpClient;
private final Clock clock;
- private final Map<ConsumerId, Snapshot> snapshots = new HashMap<>();
+ private final Map<ConsumerId, Snapshot> snapshots = new ConcurrentHashMap<>();
private long snapshotsRetrieved = 0;
NodeMetricsClient(HttpClient httpClient, Node node, Clock clock) {
