Repository: hbase
Updated Branches:
  refs/heads/branch-2 bb6f24cd5 -> 02fe89951


HBASE-20927 RSGroupAdminEndpoint doesn't handle clearing dead servers if they 
are not processed yet.

Signed-off-by: tedyu <yuzhih...@gmail.com>


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

Branch: refs/heads/branch-2
Commit: 02fe8995100bda04bfc925e22249f11fa0e58aa8
Parents: bb6f24c
Author: Sergey Soldatov <s...@apache.org>
Authored: Wed Jul 25 23:32:36 2018 -0700
Committer: tedyu <yuzhih...@gmail.com>
Committed: Thu Jul 26 09:59:25 2018 -0700

----------------------------------------------------------------------
 .../hbase/rsgroup/RSGroupAdminEndpoint.java     |  4 ++-
 .../hadoop/hbase/rsgroup/TestRSGroupsBase.java  | 28 ++++++++++++++++++++
 2 files changed, 31 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/hbase/blob/02fe8995/hbase-rsgroup/src/main/java/org/apache/hadoop/hbase/rsgroup/RSGroupAdminEndpoint.java
----------------------------------------------------------------------
diff --git 
a/hbase-rsgroup/src/main/java/org/apache/hadoop/hbase/rsgroup/RSGroupAdminEndpoint.java
 
b/hbase-rsgroup/src/main/java/org/apache/hadoop/hbase/rsgroup/RSGroupAdminEndpoint.java
index 464d74d..e1d6650 100644
--- 
a/hbase-rsgroup/src/main/java/org/apache/hadoop/hbase/rsgroup/RSGroupAdminEndpoint.java
+++ 
b/hbase-rsgroup/src/main/java/org/apache/hadoop/hbase/rsgroup/RSGroupAdminEndpoint.java
@@ -515,7 +515,9 @@ public class RSGroupAdminEndpoint implements 
MasterCoprocessor, MasterObserver {
         filter(server -> !notClearedServers.contains(server)).
         map(ServerName::getAddress).
         collect(Collectors.toSet());
-    groupAdminServer.removeServers(clearedServer);
+    if(!clearedServer.isEmpty()) {
+      groupAdminServer.removeServers(clearedServer);
+    }
   }
 
   public void checkPermission(String request) throws IOException {

http://git-wip-us.apache.org/repos/asf/hbase/blob/02fe8995/hbase-rsgroup/src/test/java/org/apache/hadoop/hbase/rsgroup/TestRSGroupsBase.java
----------------------------------------------------------------------
diff --git 
a/hbase-rsgroup/src/test/java/org/apache/hadoop/hbase/rsgroup/TestRSGroupsBase.java
 
b/hbase-rsgroup/src/test/java/org/apache/hadoop/hbase/rsgroup/TestRSGroupsBase.java
index e70a88b..386dcf3 100644
--- 
a/hbase-rsgroup/src/test/java/org/apache/hadoop/hbase/rsgroup/TestRSGroupsBase.java
+++ 
b/hbase-rsgroup/src/test/java/org/apache/hadoop/hbase/rsgroup/TestRSGroupsBase.java
@@ -1087,4 +1087,32 @@ public abstract class TestRSGroupsBase {
       }
     });
   }
+  @Test
+  public void testClearNotProcessedDeadServer() throws Exception {
+    LOG.info("testClearNotProcessedDeadServer");
+    NUM_DEAD_SERVERS = cluster.getClusterMetrics().getDeadServerNames().size();
+    RSGroupInfo appInfo = addGroup("deadServerGroup", 1);
+    ServerName targetServer =
+        
ServerName.parseServerName(appInfo.getServers().iterator().next().toString());
+    AdminProtos.AdminService.BlockingInterface targetRS =
+        ((ClusterConnection) admin.getConnection()).getAdmin(targetServer);
+    try {
+      targetServer = ProtobufUtil.toServerName(targetRS.getServerInfo(null,
+          
AdminProtos.GetServerInfoRequest.newBuilder().build()).getServerInfo().getServerName());
+      //stopping may cause an exception
+      //due to the connection loss
+      targetRS.stopServer(null,
+          AdminProtos.StopServerRequest.newBuilder().setReason("Die").build());
+      NUM_DEAD_SERVERS ++;
+    } catch(Exception e) {
+    }
+    TEST_UTIL.waitFor(WAIT_TIMEOUT, new Waiter.Predicate<Exception>() {
+      @Override
+      public boolean evaluate() throws Exception {
+        return cluster.getClusterMetrics().getDeadServerNames().size() == 
NUM_DEAD_SERVERS;
+      }
+    });
+    List<ServerName> notClearedServers = 
admin.clearDeadServers(Lists.newArrayList(targetServer));
+    assertEquals(1, notClearedServers.size());
+  }
 }

Reply via email to