zachjsh commented on a change in pull request #11056:
URL: https://github.com/apache/druid/pull/11056#discussion_r605953046
##########
File path:
server/src/main/java/org/apache/druid/server/coordinator/DruidCoordinator.java
##########
@@ -584,6 +580,59 @@ public void runCompactSegmentsDuty()
compactSegmentsDuty.run();
}
+ private Map<String, Object2LongMap<String>>
computeUnderReplicationCountsPerDataSourcePerTierForSegmentsInternal(
+ Iterable<DataSegment> dataSegments,
+ boolean computeUsingClusterView
+ )
+ {
+ final Map<String, Object2LongMap<String>>
underReplicationCountsPerDataSourcePerTier = new HashMap<>();
+
+ if (segmentReplicantLookup == null) {
+ throw new ServiceUnavailableException(
+ "Coordinator segment replicant lookup is not initialized yet. Try
again later.");
+ }
+
+ if (computeUsingClusterView && cluster == null) {
+ throw new ServiceUnavailableException(
+ "coordinator hasn't populated information about cluster yet, try
again later");
+ }
+
+ final DateTime now = DateTimes.nowUtc();
+
+ for (final DataSegment segment : dataSegments) {
+ final List<Rule> rules =
metadataRuleManager.getRulesWithDefault(segment.getDataSource());
+
+ for (final Rule rule : rules) {
+ if (!rule.appliesTo(segment, now)) {
+ // Rule did not match. Continue to the next Rule.
+ continue;
+ }
+ if (!rule.canLoadSegments()) {
+ // Rule matched but rule does not and cannot load segments.
+ // Hence, there is no need to update
underReplicationCountsPerDataSourcePerTier map
+ break;
+ }
+
+ if (computeUsingClusterView && (rule instanceof LoadRule)) {
Review comment:
Changed accordingly. Before though, for broadcast rule, it was falling
through to else branch and effectively doing same thing. Thought it was weird
to add implementation for Broadcast rule that didn't use the parameter, but I
guess not a big deal.
--
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.
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]