hbase-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From apurt...@apache.org
Subject hbase git commit: HBASE-10528 DefaultBalancer selects plans to move regions onto draining nodes
Date Thu, 15 Jan 2015 17:43:41 GMT
Repository: hbase
Updated Branches:
  refs/heads/0.98 98426a9f3 -> 5e36e70cf


HBASE-10528 DefaultBalancer selects plans to move regions onto draining nodes

Signed-off-by: Andrew Purtell <apurtell@apache.org>


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

Branch: refs/heads/0.98
Commit: 5e36e70cfd477d718d908b7852ba9dfa771c0ab3
Parents: 98426a9
Author: rahulgidwani <rahul.gidwani@flurry.com>
Authored: Thu Jan 15 09:37:34 2015 -0800
Committer: Andrew Purtell <apurtell@apache.org>
Committed: Thu Jan 15 09:37:44 2015 -0800

----------------------------------------------------------------------
 .../hadoop/hbase/master/RegionStates.java       |  4 ++-
 .../hbase/master/TestAssignmentManager.java     | 28 +++++++++++++++++---
 2 files changed, 27 insertions(+), 5 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/hbase/blob/5e36e70c/hbase-server/src/main/java/org/apache/hadoop/hbase/master/RegionStates.java
----------------------------------------------------------------------
diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/master/RegionStates.java b/hbase-server/src/main/java/org/apache/hadoop/hbase/master/RegionStates.java
index 393df49..68f3c18 100644
--- a/hbase-server/src/main/java/org/apache/hadoop/hbase/master/RegionStates.java
+++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/master/RegionStates.java
@@ -752,13 +752,15 @@ public class RegionStates {
 
     Map<ServerName, ServerLoad>
       onlineSvrs = serverManager.getOnlineServers();
-    // Take care of servers w/o assignments.
+    // Take care of servers w/o assignments, and remove servers in draining mode
+    List<ServerName> drainingServers = this.serverManager.getDrainingServersList();
     for (Map<ServerName, List<HRegionInfo>> map: result.values()) {
       for (ServerName svr: onlineSvrs.keySet()) {
         if (!map.containsKey(svr)) {
           map.put(svr, new ArrayList<HRegionInfo>());
         }
       }
+      map.keySet().removeAll(drainingServers);
     }
     return result;
   }

http://git-wip-us.apache.org/repos/asf/hbase/blob/5e36e70c/hbase-server/src/test/java/org/apache/hadoop/hbase/master/TestAssignmentManager.java
----------------------------------------------------------------------
diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/master/TestAssignmentManager.java
b/hbase-server/src/test/java/org/apache/hadoop/hbase/master/TestAssignmentManager.java
index 604e121..fcd3bcb 100644
--- a/hbase-server/src/test/java/org/apache/hadoop/hbase/master/TestAssignmentManager.java
+++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/master/TestAssignmentManager.java
@@ -24,10 +24,7 @@ import static org.junit.Assert.assertTrue;
 import static org.junit.Assert.fail;
 
 import java.io.IOException;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
+import java.util.*;
 import java.util.concurrent.atomic.AtomicBoolean;
 
 import org.apache.hadoop.hbase.CellScannable;
@@ -105,6 +102,8 @@ public class TestAssignmentManager {
       ServerName.valueOf("example.org", 1234, 5678);
   private static final ServerName SERVERNAME_B =
       ServerName.valueOf("example.org", 0, 5678);
+  private static final ServerName SERVERNAME_C =
+      ServerName.valueOf("example.org", 0, 5678);
   private static final HRegionInfo REGIONINFO =
     new HRegionInfo(TableName.valueOf("t"),
       HConstants.EMPTY_START_ROW, HConstants.EMPTY_START_ROW);
@@ -152,10 +151,12 @@ public class TestAssignmentManager {
     this.serverManager = Mockito.mock(ServerManager.class);
     Mockito.when(this.serverManager.isServerOnline(SERVERNAME_A)).thenReturn(true);
     Mockito.when(this.serverManager.isServerOnline(SERVERNAME_B)).thenReturn(true);
+    Mockito.when(this.serverManager.isServerOnline(SERVERNAME_C)).thenReturn(true);
     Mockito.when(this.serverManager.getDeadServers()).thenReturn(new DeadServer());
     final Map<ServerName, ServerLoad> onlineServers = new HashMap<ServerName, ServerLoad>();
     onlineServers.put(SERVERNAME_B, ServerLoad.EMPTY_SERVERLOAD);
     onlineServers.put(SERVERNAME_A, ServerLoad.EMPTY_SERVERLOAD);
+    onlineServers.put(SERVERNAME_C, ServerLoad.EMPTY_SERVERLOAD);
     Mockito.when(this.serverManager.getOnlineServersList()).thenReturn(
         new ArrayList<ServerName>(onlineServers.keySet()));
     Mockito.when(this.serverManager.getOnlineServers()).thenReturn(onlineServers);
@@ -169,12 +170,18 @@ public class TestAssignmentManager {
       thenReturn(true);
     Mockito.when(this.serverManager.sendRegionClose(SERVERNAME_B, REGIONINFO, -1)).
       thenReturn(true);
+    Mockito.when(this.serverManager.sendRegionClose(SERVERNAME_C, REGIONINFO, -1)).
+        thenReturn(true);
     // Ditto on open.
     Mockito.when(this.serverManager.sendRegionOpen(SERVERNAME_A, REGIONINFO, -1, null)).
       thenReturn(RegionOpeningState.OPENED);
     Mockito.when(this.serverManager.sendRegionOpen(SERVERNAME_B, REGIONINFO, -1, null)).
       thenReturn(RegionOpeningState.OPENED);
+    Mockito.when(this.serverManager.sendRegionOpen(SERVERNAME_C, REGIONINFO, -1, null)).
+        thenReturn(RegionOpeningState.OPENED);
     this.master = Mockito.mock(HMaster.class);
+    Mockito.when(this.serverManager.getDrainingServersList())
+        .thenReturn(Arrays.asList(SERVERNAME_C));
 
     Mockito.when(this.master.getServerManager()).thenReturn(serverManager);
   }
@@ -245,6 +252,19 @@ public class TestAssignmentManager {
   }
 
   @Test(timeout = 60000)
+  public void testGettingAssignmentsExcludesDrainingServers() throws Exception {
+    AssignmentManagerWithExtrasForTesting am =
+        setUpMockedAssignmentManager(this.server, this.serverManager);
+
+    Map<TableName, Map<ServerName, List<HRegionInfo>>>
+        result = am.getRegionStates().getAssignmentsByTable();
+    for (Map<ServerName, List<HRegionInfo>> map : result.values()) {
+      System.out.println(map.keySet());
+      assertFalse(map.containsKey(SERVERNAME_C));
+    }
+  }
+
+  @Test(timeout = 60000)
   public void testBalanceOnMasterFailoverScenarioWithClosedNode()
   throws IOException, KeeperException, InterruptedException, ServiceException, DeserializationException
{
     AssignmentManagerWithExtrasForTesting am =


Mime
View raw message