Skip to content

Commit

Permalink
add npr guard
Browse files Browse the repository at this point in the history
  • Loading branch information
xyuanlu committed Oct 18, 2023
1 parent 38ac277 commit 30261e5
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -132,9 +132,10 @@ private static Set<String> getActiveNodes(Set<String> allNodes, Set<String> live

public static Set<String> filterOutEvacuatingInstances(Map<String, InstanceConfig> instanceConfigMap,
Set<String> nodes) {
return nodes.stream()
.filter(instance -> !instanceConfigMap.get(instance).getInstanceOperation().equals(
InstanceConstants.InstanceOperation.EVACUATE.name()))
return nodes.stream()
.filter(instance -> (instanceConfigMap.get(instance) != null && !instanceConfigMap.get(instance)
.getInstanceOperation()
.equals(InstanceConstants.InstanceOperation.EVACUATE.name())))
.collect(Collectors.toSet());
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -410,15 +410,21 @@ public ZNRecord update(ZNRecord currentData) {

@Override
public boolean isEvacuateFinished(String clusterName, String instanceName) {
return !instanceHasCurrentSateOrMessage(clusterName, instanceName) && (getInstanceConfig(clusterName,
instanceName).getInstanceOperation().equals(InstanceConstants.InstanceOperation.EVACUATE.name()));
if (!instanceHasCurrentSateOrMessage(clusterName, instanceName)) {
InstanceConfig config = getInstanceConfig(clusterName, instanceName);
return config != null && config.getInstanceOperation().equals(InstanceConstants.InstanceOperation.EVACUATE.name());
}
return false;
}

@Override
public boolean isReadyForPreparingJoiningCluster(String clusterName, String instanceName) {
return !instanceHasCurrentSateOrMessage(clusterName, instanceName)
&& DelayedAutoRebalancer.INSTANCE_OPERATION_TO_EXCLUDE_FROM_ASSIGNMENT.contains(
getInstanceConfig(clusterName, instanceName).getInstanceOperation());
if (!instanceHasCurrentSateOrMessage(clusterName, instanceName)) {
InstanceConfig config = getInstanceConfig(clusterName, instanceName);
return config != null && DelayedAutoRebalancer.INSTANCE_OPERATION_TO_EXCLUDE_FROM_ASSIGNMENT.contains(
config.getInstanceOperation());
}
return false;
}

/**
Expand Down

0 comments on commit 30261e5

Please sign in to comment.