ccaominh commented on a change in pull request #10048:
URL: https://github.com/apache/druid/pull/10048#discussion_r442545687



##########
File path: 
server/src/main/java/org/apache/druid/server/coordinator/DruidCoordinator.java
##########
@@ -280,20 +288,38 @@ public boolean isLeader()
       final List<Rule> rules = 
metadataRuleManager.getRulesWithDefault(segment.getDataSource());
 
       for (final Rule rule : rules) {
-        if (!(rule instanceof LoadRule && rule.appliesTo(segment, now))) {
+        if (!rule.appliesTo(segment, now)) {
           continue;
         }
 
-        ((LoadRule) rule)
-            .getTieredReplicants()
-            .forEach((final String tier, final Integer ruleReplicants) -> {
-              int currentReplicants = 
segmentReplicantLookup.getLoadedReplicants(segment.getId(), tier);
-              Object2LongMap<String> underReplicationPerDataSource = 
underReplicationCountsPerDataSourcePerTier
-                  .computeIfAbsent(tier, ignored -> new 
Object2LongOpenHashMap<>());
+        if (rule instanceof LoadRule) {
+          ((LoadRule) rule)
+              .getTieredReplicants()
+              .forEach((final String tier, final Integer ruleReplicants) -> {
+                int currentReplicants = 
segmentReplicantLookup.getLoadedReplicants(segment.getId(), tier);
+                Object2LongMap<String> underReplicationPerDataSource = 
underReplicationCountsPerDataSourcePerTier
+                    .computeIfAbsent(tier, ignored -> new 
Object2LongOpenHashMap<>());
+                ((Object2LongOpenHashMap<String>) 
underReplicationPerDataSource)
+                    .addTo(segment.getDataSource(), Math.max(ruleReplicants - 
currentReplicants, 0));
+              });
+        }
+
+        if (rule instanceof BroadcastDistributionRule) {

Review comment:
       Maybe adding some comments to somewhere like `Rule` will be sufficient 
for now. Not sure how likely we'll add future `Rule`s, but if we do I think 
there's a good chance we'll forget to update this method if it's needed.




----------------------------------------------------------------
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]

Reply via email to