xyuanlu commented on code in PR #2736:
URL: https://github.com/apache/helix/pull/2736#discussion_r1465869252
##########
helix-rest/src/main/java/org/apache/helix/rest/server/resources/helix/InstancesAccessor.java:
##########
@@ -302,16 +305,36 @@ private Response batchGetStoppableInstances(String
clusterId, JsonNode node, boo
ClusterService clusterService =
new ClusterServiceImpl(getDataAccssor(clusterId),
getConfigAccessor());
ClusterTopology clusterTopology =
clusterService.getClusterTopology(clusterId);
- StoppableInstancesSelector stoppableInstancesSelector =
+ StoppableInstancesSelector.StoppableInstancesSelectorBuilder builder =
new StoppableInstancesSelector.StoppableInstancesSelectorBuilder()
.setClusterId(clusterId)
.setOrderOfZone(orderOfZone)
.setCustomizedInput(customizedInput)
.setMaintenanceService(maintenanceService)
.setClusterTopology(clusterTopology)
.setDataAccessor((ZKHelixDataAccessor) getDataAccssor(clusterId))
- .build();
+ .setContinueOnFailure(continueOnFailures);
+
+ if (notExceedingMaxOfflineInstances) {
+ ClusterConfig clusterConfig =
getConfigAccessor().getClusterConfig(clusterId);
+ if (clusterConfig == null) {
+ String message =
+ "Invalid cluster name: " + clusterId + ". Cluster config does
not exist.";
+ _logger.error(message);
+ return badRequest(message);
+ }
+ // If maxOfflineInstancesAllowed is not set, it means there is no
limit on the number of offline instances.
+ // Therefore, builder sets the maxOfflineInstancesAllowed to the
default value, Integer.MAX_VALUE.
+ if (clusterConfig.getMaxOfflineInstancesAllowed() != -1) {
+
builder.setMaxAdditionalOfflineInstances(clusterConfig.getMaxOfflineInstancesAllowed());
+ }
+ }
+
+ StoppableInstancesSelector stoppableInstancesSelector = builder.build();
stoppableInstancesSelector.calculateOrderOfZone(instances, random);
+ Set<String> invalidInstances = new HashSet<>(toBeStoppedInstances);
Review Comment:
nit: use stream and filter our instances that are not in
clusterTopology.getAllInstances()
--
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]