kfaraz commented on code in PR #18314:
URL: https://github.com/apache/druid/pull/18314#discussion_r2228733013
##########
server/src/main/java/org/apache/druid/client/BrokerServerView.java:
##########
@@ -436,4 +446,42 @@ public List<ImmutableDruidServer> getDruidServers()
.map(queryableDruidServer ->
queryableDruidServer.getServer().toImmutableDruidServer())
.collect(Collectors.toList());
}
+
+ @Override
+ public Map<RowKey, Long> getAvailableSegmentCount()
+ {
+ return CollectionUtils.mapValues(segmentAvailableCount, AtomicLong::get);
+ }
+
+ private static long incrementAndGetLong(ConcurrentHashMap<RowKey,
AtomicLong> counters, RowKey key)
+ {
+ AtomicLong counter = counters.get(key);
+ if (counter == null) {
+ counter = counters.computeIfAbsent(key, k -> new AtomicLong());
+ }
+ return counter.incrementAndGet();
Review Comment:
Oh, sorry, I must have clarified. I meant why do we need to keep an
`AtomicLong`, we are already using a concurrent hash map. The
`segmentAvailableCount` can just be `Map<RowKey, Long>`.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]