hbase-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From apurt...@apache.org
Subject [2/2] hbase git commit: Amend HBASE-15631 Backport Regionserver Groups (HBASE-6721) to branch-1 (Francis Liu and Andrew Purtell)
Date Wed, 25 Oct 2017 01:31:39 GMT
Amend HBASE-15631 Backport Regionserver Groups (HBASE-6721) to branch-1 (Francis Liu and Andrew
Purtell)

- Restore missing unit in TestRSGroupBasedLoadBalancer
- Restore missing hunk in RSGroupBasedLoadBalancer


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

Branch: refs/heads/branch-1.4
Commit: 11b7e1bc8cafca686d020b67239248f1347ad775
Parents: c3e03e5
Author: Andrew Purtell <apurtell@apache.org>
Authored: Tue Oct 24 18:25:52 2017 -0700
Committer: Andrew Purtell <apurtell@apache.org>
Committed: Tue Oct 24 18:26:38 2017 -0700

----------------------------------------------------------------------
 .../hbase/rsgroup/RSGroupBasedLoadBalancer.java |  8 ++++-
 .../balancer/TestRSGroupBasedLoadBalancer.java  | 34 ++++++++++++++++++++
 2 files changed, 41 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/hbase/blob/11b7e1bc/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 48bcb64..d7f9498 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
@@ -173,7 +173,13 @@ public class RSGroupBasedLoadBalancer implements RSGroupableBalancer,
LoadBalanc
                 regionMap.get(groupKey),
                 serverMap.get(groupKey));
         if(result != null) {
-          assignments.putAll(result);
+          if(result.containsKey(LoadBalancer.BOGUS_SERVER_NAME) &&
+              assignments.containsKey(LoadBalancer.BOGUS_SERVER_NAME)){
+            assignments.get(LoadBalancer.BOGUS_SERVER_NAME).addAll(
+              result.get(LoadBalancer.BOGUS_SERVER_NAME));
+          } else {
+            assignments.putAll(result);
+          }
         }
       }
     }

http://git-wip-us.apache.org/repos/asf/hbase/blob/11b7e1bc/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 3b96de6..dea0a94 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
@@ -37,6 +37,7 @@ import org.apache.hadoop.hbase.rsgroup.RSGroupInfo;
 import org.apache.hadoop.hbase.rsgroup.RSGroupInfoManager;
 import org.apache.hadoop.hbase.master.AssignmentManager;
 import org.apache.hadoop.hbase.master.HMaster;
+import org.apache.hadoop.hbase.master.LoadBalancer;
 import org.apache.hadoop.hbase.master.MasterServices;
 import org.apache.hadoop.hbase.master.RegionPlan;
 import org.apache.hadoop.hbase.net.Address;
@@ -55,6 +56,8 @@ import java.security.SecureRandom;
 import java.util.ArrayList;
 import java.util.Collections;
 import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Iterator;
 import java.util.List;
 import java.util.Map;
 import java.util.Set;
@@ -247,6 +250,37 @@ public class TestRSGroupBasedLoadBalancer {
   }
 
   /**
+   * Test BOGUS_SERVER_NAME among groups do not overwrite each other
+   * @throws Exception
+   */
+  @Test
+  public void testRoundRobinAssignment() throws Exception {
+    List<ServerName> onlineServers = new ArrayList<ServerName>(servers.size());
+    onlineServers.addAll(servers);
+    List<HRegionInfo> regions = randomRegions(25);
+    int bogusRegion = 0;
+    for(HRegionInfo region : regions){
+      String group = tableMap.get(region.getTable());
+      if("dg3".equals(group) || "dg4".equals(group)){
+        bogusRegion++;
+      }
+    }
+    Set<Address> offlineServers = new HashSet<Address>();
+    offlineServers.addAll(groupMap.get("dg3").getServers());
+    offlineServers.addAll(groupMap.get("dg4").getServers());
+    for(Iterator<ServerName> it =  onlineServers.iterator(); it.hasNext();){
+      ServerName server = it.next();
+      Address address = server.getAddress();
+      if(offlineServers.contains(address)){
+        it.remove();
+      }
+    }
+    Map<ServerName, List<HRegionInfo>> assignments = loadBalancer
+        .roundRobinAssignment(regions, onlineServers);
+    assertEquals(bogusRegion, assignments.get(LoadBalancer.BOGUS_SERVER_NAME).size());
+  }
+
+  /**
    * Asserts a valid retained assignment plan.
    * <p>
    * Must meet the following conditions:


Mime
View raw message