hbase-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jxi...@apache.org
Subject git commit: HBASE-12167 NPE in AssignmentManager
Date Fri, 03 Oct 2014 19:03:36 GMT
Repository: hbase
Updated Branches:
  refs/heads/branch-1 566686d9e -> c452942f5


HBASE-12167 NPE in AssignmentManager


Project: http://git-wip-us.apache.org/repos/asf/hbase/repo
Commit: http://git-wip-us.apache.org/repos/asf/hbase/commit/c452942f
Tree: http://git-wip-us.apache.org/repos/asf/hbase/tree/c452942f
Diff: http://git-wip-us.apache.org/repos/asf/hbase/diff/c452942f

Branch: refs/heads/branch-1
Commit: c452942f57daa0ac8075556ed5d03940a0a13571
Parents: 566686d
Author: Jimmy Xiang <jxiang@cloudera.com>
Authored: Fri Oct 3 09:29:00 2014 -0700
Committer: Jimmy Xiang <jxiang@cloudera.com>
Committed: Fri Oct 3 12:01:31 2014 -0700

----------------------------------------------------------------------
 .../hadoop/hbase/master/AssignmentManager.java   |  8 +++++++-
 .../org/apache/hadoop/hbase/master/HMaster.java  | 19 +++++++++++++++++--
 .../hbase/master/balancer/BaseLoadBalancer.java  |  2 +-
 3 files changed, 25 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/hbase/blob/c452942f/hbase-server/src/main/java/org/apache/hadoop/hbase/master/AssignmentManager.java
----------------------------------------------------------------------
diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/master/AssignmentManager.java
b/hbase-server/src/main/java/org/apache/hadoop/hbase/master/AssignmentManager.java
index c3cb9f9..0880134 100644
--- a/hbase-server/src/main/java/org/apache/hadoop/hbase/master/AssignmentManager.java
+++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/master/AssignmentManager.java
@@ -2586,6 +2586,9 @@ public class AssignmentManager extends ZooKeeperListener {
     // 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);
@@ -2613,8 +2616,11 @@ public class AssignmentManager extends ZooKeeperListener {
     // 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);
   }

http://git-wip-us.apache.org/repos/asf/hbase/blob/c452942f/hbase-server/src/main/java/org/apache/hadoop/hbase/master/HMaster.java
----------------------------------------------------------------------
diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/master/HMaster.java b/hbase-server/src/main/java/org/apache/hadoop/hbase/master/HMaster.java
index 95f831f..6e0f9f6 100644
--- a/hbase-server/src/main/java/org/apache/hadoop/hbase/master/HMaster.java
+++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/master/HMaster.java
@@ -1073,15 +1073,30 @@ public class HMaster extends HRegionServer implements MasterServices,
Server {
       final List<ServerName> destServers = this.serverManager.createDestinationServersList(
         regionState.getServerName());
       dest = balancer.randomAssignment(hri, destServers);
+      if (dest == null) {
+        LOG.debug("Unable to determine a plan to assign " + hri);
+        return;
+      }
     } else {
       dest = ServerName.valueOf(Bytes.toString(destServerName));
-      if (dest.equals(regionState.getServerName())) {
+      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()
-          + " because region already assigned to the same server " + dest + ".");
+          + " 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
     RegionPlan rp = new RegionPlan(hri, regionState.getServerName(), dest);
 

http://git-wip-us.apache.org/repos/asf/hbase/blob/c452942f/hbase-server/src/main/java/org/apache/hadoop/hbase/master/balancer/BaseLoadBalancer.java
----------------------------------------------------------------------
diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/master/balancer/BaseLoadBalancer.java
b/hbase-server/src/main/java/org/apache/hadoop/hbase/master/balancer/BaseLoadBalancer.java
index 275e268..2dfa02f 100644
--- a/hbase-server/src/main/java/org/apache/hadoop/hbase/master/balancer/BaseLoadBalancer.java
+++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/master/balancer/BaseLoadBalancer.java
@@ -843,7 +843,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());
   }
 


Mime
View raw message