snleee commented on code in PR #10302:
URL: https://github.com/apache/pinot/pull/10302#discussion_r1110420914


##########
pinot-broker/src/main/java/org/apache/pinot/broker/routing/instanceselector/BaseInstanceSelector.java:
##########
@@ -231,7 +231,7 @@ void updateSegmentMaps(IdealState idealState, ExternalView 
externalView, Set<Str
    */
   @Nullable
   private List<String> calculateEnabledInstancesForSegment(String segment, 
List<String> onlineInstancesForSegment,
-      Set<String> unavailableSegments) {
+      Set<String> unavailableSegments, String debugString) {

Review Comment:
   Can we avoid adding`debugString`? Instead, we can log whether it's from 
assignment/instance change from the caller. Then, we should be able to check 
the logs to find the same information.
   
   ```
   LOGGER.info("Calculating enabled instances on assignment(or instance) 
change");
   List<String> enabledInstancesForSegment =
             calculateEnabledInstancesForSegment(segment, entry.getValue(), 
unavailableSegments);
   ```



##########
pinot-broker/src/main/java/org/apache/pinot/broker/routing/instanceselector/StrictReplicaGroupInstanceSelector.java:
##########
@@ -160,25 +160,18 @@ void updateSegmentMaps(IdealState idealState, 
ExternalView externalView, Set<Str
       // NOTE: Instances will be sorted here because 'tempOnlineInstances' is 
a TreeSet. We need the online instances to
       //       be sorted for replica-group routing to work. For multiple 
segments with the same online instances, if the
       //       list is sorted, the same index in the list will always point to 
the same instance.
-      List<String> onlineInstances = new 
ArrayList<>(tempOnlineInstances.size());
-      segmentToOnlineInstancesMap.put(segment, onlineInstances);
-
       Set<String> instancesInIdealState = 
idealStateSegmentToInstancesMap.get(segment);
       Set<String> unavailableInstances = 
unavailableInstancesMap.get(instancesInIdealState);
-      if (unavailableInstances == null) {
-        // No unavailable instance, add all instances as online instance
-        for (String instance : tempOnlineInstances) {
-          onlineInstances.add(instance);
-          instanceToSegmentsMap.computeIfAbsent(instance, k -> new 
ArrayList<>()).add(segment);
-        }
-      } else {
-        // Some instances are unavailable, add the remaining instances as 
online instance
-        for (String instance : tempOnlineInstances) {
-          if (!unavailableInstances.contains(instance)) {
-            onlineInstances.add(instance);
-            instanceToSegmentsMap.computeIfAbsent(instance, k -> new 
ArrayList<>()).add(segment);
-          }
+      List<String> onlineInstances = new 
ArrayList<>(tempOnlineInstances.size());
+      for (String instance : tempOnlineInstances) {
+        if (unavailableInstances != null && 
unavailableInstances.contains(instance)) {
+          continue;
         }
+        onlineInstances.add(instance);
+        instanceToSegmentsMap.computeIfAbsent(instance, k -> new 
ArrayList<>()).add(segment);
+      }
+      if (!onlineInstances.isEmpty()) {

Review Comment:
   Let's add the `TODO` comment about ignoring for the new segments only? 



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

Reply via email to