diff --git a/helix-core/src/main/java/org/apache/helix/controller/rebalancer/util/DelayedRebalanceUtil.java b/helix-core/src/main/java/org/apache/helix/controller/rebalancer/util/DelayedRebalanceUtil.java index f42176a0a4..c9965f69c9 100644 --- a/helix-core/src/main/java/org/apache/helix/controller/rebalancer/util/DelayedRebalanceUtil.java +++ b/helix-core/src/main/java/org/apache/helix/controller/rebalancer/util/DelayedRebalanceUtil.java @@ -132,9 +132,10 @@ private static Set getActiveNodes(Set allNodes, Set live public static Set filterOutEvacuatingInstances(Map instanceConfigMap, Set 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()); } diff --git a/helix-core/src/main/java/org/apache/helix/manager/zk/ZKHelixAdmin.java b/helix-core/src/main/java/org/apache/helix/manager/zk/ZKHelixAdmin.java index 44afee5e1b..ebbcf64d02 100644 --- a/helix-core/src/main/java/org/apache/helix/manager/zk/ZKHelixAdmin.java +++ b/helix-core/src/main/java/org/apache/helix/manager/zk/ZKHelixAdmin.java @@ -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; } /**