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



##########
File path: 
server/src/main/java/org/apache/druid/server/coordinator/DruidCoordinator.java
##########
@@ -269,6 +270,13 @@ public boolean isLeader()
   )
   {
     final Map<String, Object2LongMap<String>> 
underReplicationCountsPerDataSourcePerTier = new HashMap<>();
+    final Set<String> decommissioningServers = 
getDynamicConfigs().getDecommissioningNodes();

Review comment:
       In a previous PR there was a discussion about why it's ok for 
`segmentReplicantLookup` to be stale in this method:  
https://github.com/apache/druid/pull/9965/files#r440541949
   
   What do you think about having that explanation as a code comment for this 
method?

##########
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:
       If `Rule` subclasses are added in the future and should be considered in 
this method, is there a test that will fail?




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