HBASE-21102 ServerCrashProcedure should select target server where no other replicas exist for the current region - addendum fixes NPE

This commit is contained in:
tedyu 2018-09-19 07:17:13 -07:00
parent cebb725a9f
commit 69431c75c1
1 changed files with 4 additions and 2 deletions

View File

@ -51,6 +51,7 @@ import org.apache.hadoop.hbase.master.LoadBalancer;
import org.apache.hadoop.hbase.master.MasterServices;
import org.apache.hadoop.hbase.master.RackManager;
import org.apache.hadoop.hbase.master.RegionPlan;
import org.apache.hadoop.hbase.master.assignment.RegionStates;
import org.apache.hadoop.hbase.master.balancer.BaseLoadBalancer.Cluster.Action.Type;
import org.apache.hbase.thirdparty.com.google.common.annotations.VisibleForTesting;
import org.apache.hbase.thirdparty.com.google.common.base.Joiner;
@ -1457,8 +1458,9 @@ public abstract class BaseLoadBalancer implements LoadBalancer {
// In the current set of regions even if one has region replica let us go with
// getting the entire snapshot
if (this.services != null && this.services.getAssignmentManager() != null) { // for tests
if (!hasRegionReplica && this.services.getAssignmentManager().getRegionStates()
.isReplicaAvailableForRegion(region)) {
RegionStates states = this.services.getAssignmentManager().getRegionStates();
if (!hasRegionReplica && states != null &&
states.isReplicaAvailableForRegion(region)) {
hasRegionReplica = true;
}
}