kfaraz commented on code in PR #18314:
URL: https://github.com/apache/druid/pull/18314#discussion_r2236115585
##########
server/src/main/java/org/apache/druid/client/BrokerServerView.java:
##########
@@ -436,4 +449,55 @@ public List<ImmutableDruidServer> getDruidServers()
.map(queryableDruidServer ->
queryableDruidServer.getServer().toImmutableDruidServer())
.collect(Collectors.toList());
}
+
+ private void incrementSegmentCount(RowKey key)
+ {
+ totalSegmentAddCount.compute(key, (k, currentValue) -> currentValue ==
null ? 1 : currentValue + 1);
+ }
+
+ @Override
+ public Map<RowKey, Long> getSegmentAddedCount()
+ {
+ final ConcurrentHashMap<RowKey, Long> total = totalSegmentAddCount;
+ synchronized (totalSegmentAddCount) {
+ final Map<RowKey, Long> delta = getDeltaValues(total,
previousSegmentAddCount);
+ previousSegmentAddCount = total;
+ return delta;
+ }
+ }
+
+ @Override
+ public Map<RowKey, Long> getSegmentRemovedCount()
+ {
+ final ConcurrentHashMap<RowKey, Long> total = totalSegmentRemoveCount;
+ synchronized (totalSegmentRemoveCount) {
+ final Map<RowKey, Long> delta = getDeltaValues(total,
previousSegmentRemoveCount);
+ previousSegmentRemoveCount = total;
+ return delta;
+ }
+ }
+
+ private void decrementSegmentCount(RowKey key)
+ {
+ totalSegmentRemoveCount.compute(key, (k, currentValue) -> currentValue ==
null ? 1 : currentValue + 1);
+ }
+
+ private Map<RowKey, Long> getDeltaValues(Map<RowKey, Long> total,
Map<RowKey, Long> prev)
+ {
+ final Map<RowKey, Long> deltaValues = new HashMap<>();
+ total.forEach(
+ (dataSource, totalCount) -> deltaValues.put(
+ dataSource,
+ totalCount - prev.getOrDefault(dataSource, 0L)
+ )
+ );
+ return deltaValues;
+ }
+
+ private static RowKey getMetricKey(final DataSegment segment)
+ {
+ return RowKey.with(Dimension.DATASOURCE, segment.getDataSource())
+ .with(Dimension.INTERVAL,
String.valueOf(segment.getInterval()))
+ .and(Dimension.VERSION, segment.getVersion());
Review Comment:
No, just the segment id.
`server` should be a separate dimension on the row key
--
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]