hbase-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From te...@apache.org
Subject hbase git commit: HBASE-19752 RSGroupBasedLoadBalancer#getMisplacedRegions() should handle the case where rs group cannot be determined
Date Fri, 12 Jan 2018 20:16:12 GMT
Repository: hbase
Updated Branches:
  refs/heads/branch-2 b66208073 -> 9ed52ee3e


HBASE-19752 RSGroupBasedLoadBalancer#getMisplacedRegions() should handle the case where rs
group cannot be determined


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

Branch: refs/heads/branch-2
Commit: 9ed52ee3e5dd6cc7a3c02953e0afab11de8dd680
Parents: b662080
Author: tedyu <yuzhihong@gmail.com>
Authored: Fri Jan 12 12:16:06 2018 -0800
Committer: tedyu <yuzhihong@gmail.com>
Committed: Fri Jan 12 12:16:06 2018 -0800

----------------------------------------------------------------------
 .../hbase/rsgroup/RSGroupBasedLoadBalancer.java    | 17 ++++++++++++-----
 .../balancer/TestRSGroupBasedLoadBalancer.java     | 17 +++++++++++++++++
 2 files changed, 29 insertions(+), 5 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/hbase/blob/9ed52ee3/hbase-rsgroup/src/main/java/org/apache/hadoop/hbase/rsgroup/RSGroupBasedLoadBalancer.java
----------------------------------------------------------------------
diff --git a/hbase-rsgroup/src/main/java/org/apache/hadoop/hbase/rsgroup/RSGroupBasedLoadBalancer.java
b/hbase-rsgroup/src/main/java/org/apache/hadoop/hbase/rsgroup/RSGroupBasedLoadBalancer.java
index 1c70925..619de9e 100644
--- a/hbase-rsgroup/src/main/java/org/apache/hadoop/hbase/rsgroup/RSGroupBasedLoadBalancer.java
+++ b/hbase-rsgroup/src/main/java/org/apache/hadoop/hbase/rsgroup/RSGroupBasedLoadBalancer.java
@@ -300,7 +300,8 @@ public class RSGroupBasedLoadBalancer implements RSGroupableBalancer {
     return finalList;
   }
 
-  private Set<RegionInfo> getMisplacedRegions(
+  @VisibleForTesting
+  public Set<RegionInfo> getMisplacedRegions(
       Map<RegionInfo, ServerName> regions) throws IOException {
     Set<RegionInfo> misplacedRegions = new HashSet<>();
     for(Map.Entry<RegionInfo, ServerName> region : regions.entrySet()) {
@@ -308,10 +309,16 @@ public class RSGroupBasedLoadBalancer implements RSGroupableBalancer
{
       ServerName assignedServer = region.getValue();
       RSGroupInfo info = rsGroupInfoManager.getRSGroup(rsGroupInfoManager.
               getRSGroupOfTable(regionInfo.getTable()));
-      if (assignedServer != null &&
-          (info == null || !info.containsServer(assignedServer.getAddress()))) {
-        RSGroupInfo otherInfo = null;
-        otherInfo = rsGroupInfoManager.getRSGroupOfServer(assignedServer.getAddress());
+      if (assignedServer == null) {
+        LOG.debug("There is no assigned server for {}", region);
+        continue;
+      }
+      RSGroupInfo otherInfo = rsGroupInfoManager.getRSGroupOfServer(assignedServer.getAddress());
+      if (info == null && otherInfo == null) {
+        LOG.warn("Couldn't obtain rs group information for {} on {}", region, assignedServer);
+        continue;
+      }
+      if ((info == null || !info.containsServer(assignedServer.getAddress()))) {
         LOG.debug("Found misplaced region: " + regionInfo.getRegionNameAsString() +
             " on server: " + assignedServer +
             " found in group: " +  otherInfo +

http://git-wip-us.apache.org/repos/asf/hbase/blob/9ed52ee3/hbase-rsgroup/src/test/java/org/apache/hadoop/hbase/master/balancer/TestRSGroupBasedLoadBalancer.java
----------------------------------------------------------------------
diff --git a/hbase-rsgroup/src/test/java/org/apache/hadoop/hbase/master/balancer/TestRSGroupBasedLoadBalancer.java
b/hbase-rsgroup/src/test/java/org/apache/hadoop/hbase/master/balancer/TestRSGroupBasedLoadBalancer.java
index e234438..68845d7 100644
--- a/hbase-rsgroup/src/test/java/org/apache/hadoop/hbase/master/balancer/TestRSGroupBasedLoadBalancer.java
+++ b/hbase-rsgroup/src/test/java/org/apache/hadoop/hbase/master/balancer/TestRSGroupBasedLoadBalancer.java
@@ -76,6 +76,7 @@ public class TestRSGroupBasedLoadBalancer {
 
   static String[]  groups = new String[] { RSGroupInfo.DEFAULT_GROUP, "dg2", "dg3",
       "dg4" };
+  static TableName table0 = TableName.valueOf("dt0");
   static TableName[] tables =
       new TableName[] { TableName.valueOf("dt1"),
           TableName.valueOf("dt2"),
@@ -225,6 +226,20 @@ public class TestRSGroupBasedLoadBalancer {
     assertClusterAsBalanced(loadMap);
   }
 
+  @Test
+  public void testGetMisplacedRegions() throws Exception {
+    // Test case where region is not considered misplaced if RSGroupInfo cannot be determined
+    Map<RegionInfo, ServerName> inputForTest = new HashMap<>();
+    RegionInfo ri = RegionInfoBuilder.newBuilder(table0)
+        .setStartKey(new byte[16])
+        .setEndKey(new byte[16])
+        .setSplit(false)
+        .setRegionId(regionId++)
+        .build();
+    inputForTest.put(ri, servers.iterator().next());
+    Set<RegionInfo> misplacedRegions = loadBalancer.getMisplacedRegions(inputForTest);
+    assertFalse(misplacedRegions.contains(ri));
+  }
   /**
    * Test the cluster startup bulk assignment which attempts to retain
    * assignment info.
@@ -552,6 +567,8 @@ public class TestRSGroupBasedLoadBalancer {
       tableMap.put(tables[i], groupName);
       tds.add(htd);
     }
+    tableMap.put(table0, "");
+    tds.add(new HTableDescriptor(table0));
     return tds;
   }
 


Mime
View raw message