HBASE-12167 NPE in AssignmentManager
This commit is contained in:
parent
d8a7b67d79
commit
5375ff07bc
|
@ -1377,6 +1377,9 @@ public class AssignmentManager {
|
|||
// Reuse existing assignment info
|
||||
Map<ServerName, List<HRegionInfo>> bulkPlan =
|
||||
balancer.retainAssignment(regions, servers);
|
||||
if (bulkPlan == null) {
|
||||
throw new IOException("Unable to determine a plan to assign region(s)");
|
||||
}
|
||||
|
||||
assign(regions.size(), servers.size(),
|
||||
"retainAssignment=true", bulkPlan);
|
||||
|
@ -1404,8 +1407,11 @@ public class AssignmentManager {
|
|||
// Generate a round-robin bulk assignment plan
|
||||
Map<ServerName, List<HRegionInfo>> bulkPlan
|
||||
= balancer.roundRobinAssignment(regions, servers);
|
||||
processFavoredNodes(regions);
|
||||
if (bulkPlan == null) {
|
||||
throw new IOException("Unable to determine a plan to assign region(s)");
|
||||
}
|
||||
|
||||
processFavoredNodes(regions);
|
||||
assign(regions.size(), servers.size(),
|
||||
"round-robin=true", bulkPlan);
|
||||
}
|
||||
|
|
|
@ -1079,13 +1079,28 @@ public class HMaster extends HRegionServer implements MasterServices, Server {
|
|||
final List<ServerName> destServers = this.serverManager.createDestinationServersList(
|
||||
regionState.getServerName());
|
||||
dest = balancer.randomAssignment(hri, destServers);
|
||||
} else {
|
||||
dest = ServerName.valueOf(Bytes.toString(destServerName));
|
||||
if (dest.equals(regionState.getServerName())) {
|
||||
LOG.debug("Skipping move of region " + hri.getRegionNameAsString()
|
||||
+ " because region already assigned to the same server " + dest + ".");
|
||||
if (dest == null) {
|
||||
LOG.debug("Unable to determine a plan to assign " + hri);
|
||||
return;
|
||||
}
|
||||
} else {
|
||||
dest = ServerName.valueOf(Bytes.toString(destServerName));
|
||||
if (dest.equals(serverName) && balancer instanceof BaseLoadBalancer
|
||||
&& !((BaseLoadBalancer)balancer).shouldBeOnMaster(hri)) {
|
||||
// To avoid unnecessary region moving later by balancer. Don't put user
|
||||
// regions on master. Regions on master could be put on other region
|
||||
// server intentionally by test however.
|
||||
LOG.debug("Skipping move of region " + hri.getRegionNameAsString()
|
||||
+ " to avoid unnecessary region moving later by load balancer,"
|
||||
+ " because it should not be on master");
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if (dest.equals(regionState.getServerName())) {
|
||||
LOG.debug("Skipping move of region " + hri.getRegionNameAsString()
|
||||
+ " because region already assigned to the same server " + dest + ".");
|
||||
return;
|
||||
}
|
||||
|
||||
// Now we can do the move
|
||||
|
|
|
@ -858,7 +858,7 @@ public abstract class BaseLoadBalancer implements LoadBalancer {
|
|||
* Check if a region belongs to some small system table.
|
||||
* If so, it may be expected to be put on the master regionserver.
|
||||
*/
|
||||
protected boolean shouldBeOnMaster(HRegionInfo region) {
|
||||
public boolean shouldBeOnMaster(HRegionInfo region) {
|
||||
return tablesOnMaster.contains(region.getTable().getNameAsString());
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue