hbase-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From te...@apache.org
Subject [3/3] hbase git commit: HBASE-18131 Add an hbase shell command to clear deadserver list in ServerManager
Date Sat, 16 Sep 2017 16:33:30 GMT
HBASE-18131 Add an hbase shell command to clear deadserver list in ServerManager

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


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

Branch: refs/heads/branch-1
Commit: 815673f7e4b837b525655bf5c6a2597d67c9bcad
Parents: 7dc0a63
Author: andrewcheng <andrewcheng@tencent.com>
Authored: Wed Sep 13 10:13:12 2017 +0800
Committer: tedyu <yuzhihong@gmail.com>
Committed: Sat Sep 16 09:33:08 2017 -0700

----------------------------------------------------------------------
 .../org/apache/hadoop/hbase/client/Admin.java   |   14 +
 .../hadoop/hbase/client/ConnectionManager.java  |   15 +
 .../apache/hadoop/hbase/client/HBaseAdmin.java  |   30 +
 .../hadoop/hbase/protobuf/ProtobufUtil.java     |   14 +
 .../hadoop/hbase/protobuf/RequestConverter.java |    9 +
 .../hbase/protobuf/generated/MasterProtos.java  | 2998 +++++++++++++++++-
 hbase-protocol/src/main/protobuf/Master.proto   |   24 +
 .../BaseMasterAndRegionObserver.java            |   20 +
 .../hbase/coprocessor/BaseMasterObserver.java   |   20 +
 .../hbase/coprocessor/MasterObserver.java       |   21 +
 .../apache/hadoop/hbase/master/DeadServer.java  |   13 +
 .../hbase/master/MasterCoprocessorHost.java     |   41 +
 .../hadoop/hbase/master/MasterRpcServices.java  |   64 +
 .../hbase/security/access/AccessController.java |   18 +
 .../hbase/coprocessor/TestMasterObserver.java   |   20 +
 .../hadoop/hbase/master/TestDeadServer.java     |   18 +
 hbase-shell/src/main/ruby/hbase/admin.rb        |   22 +
 hbase-shell/src/main/ruby/shell.rb              |    2 +
 .../ruby/shell/commands/clear_deadservers.rb    |   52 +
 .../ruby/shell/commands/list_deadservers.rb     |   43 +
 20 files changed, 3316 insertions(+), 142 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/hbase/blob/815673f7/hbase-client/src/main/java/org/apache/hadoop/hbase/client/Admin.java
----------------------------------------------------------------------
diff --git a/hbase-client/src/main/java/org/apache/hadoop/hbase/client/Admin.java b/hbase-client/src/main/java/org/apache/hadoop/hbase/client/Admin.java
index fa9594a..4aadd30 100644
--- a/hbase-client/src/main/java/org/apache/hadoop/hbase/client/Admin.java
+++ b/hbase-client/src/main/java/org/apache/hadoop/hbase/client/Admin.java
@@ -1583,4 +1583,18 @@ public interface Admin extends Abortable, Closeable {
     SPLIT,
     MERGE
   }
+
+  /**
+   * List dead region servers.
+   * @return List of dead region servers.
+   */
+  List<ServerName> listDeadServers() throws IOException;
+
+  /**
+   * Clear dead region servers from master.
+   * @param servers list of dead region servers.
+   * @throws IOException if a remote or network exception occurs
+   * @return List of servers that not cleared
+   */
+  List<ServerName> clearDeadServers(final List<ServerName> servers) throws IOException;
 }

http://git-wip-us.apache.org/repos/asf/hbase/blob/815673f7/hbase-client/src/main/java/org/apache/hadoop/hbase/client/ConnectionManager.java
----------------------------------------------------------------------
diff --git a/hbase-client/src/main/java/org/apache/hadoop/hbase/client/ConnectionManager.java
b/hbase-client/src/main/java/org/apache/hadoop/hbase/client/ConnectionManager.java
index 5e670a3..6227a15 100644
--- a/hbase-client/src/main/java/org/apache/hadoop/hbase/client/ConnectionManager.java
+++ b/hbase-client/src/main/java/org/apache/hadoop/hbase/client/ConnectionManager.java
@@ -1798,6 +1798,21 @@ class ConnectionManager {
             MasterProtos.ListProceduresRequest request) throws ServiceException {
           return stub.listProcedures(controller, request);
         }
+
+        @Override
+        public MasterProtos.ClearDeadServersResponse clearDeadServers(
+            RpcController controller,
+            MasterProtos.ClearDeadServersRequest request) throws ServiceException {
+          return stub.clearDeadServers(controller, request);
+        }
+
+        @Override
+        public MasterProtos.ListDeadServersResponse listDeadServers(
+            RpcController controller,
+            MasterProtos.ListDeadServersRequest request) throws ServiceException {
+          return stub.listDeadServers(controller, request);
+        }
+
         @Override
         public AddColumnResponse addColumn(RpcController controller, AddColumnRequest request)
         throws ServiceException {

http://git-wip-us.apache.org/repos/asf/hbase/blob/815673f7/hbase-client/src/main/java/org/apache/hadoop/hbase/client/HBaseAdmin.java
----------------------------------------------------------------------
diff --git a/hbase-client/src/main/java/org/apache/hadoop/hbase/client/HBaseAdmin.java b/hbase-client/src/main/java/org/apache/hadoop/hbase/client/HBaseAdmin.java
index 84871ed..d543ddb 100644
--- a/hbase-client/src/main/java/org/apache/hadoop/hbase/client/HBaseAdmin.java
+++ b/hbase-client/src/main/java/org/apache/hadoop/hbase/client/HBaseAdmin.java
@@ -102,6 +102,7 @@ import org.apache.hadoop.hbase.protobuf.generated.MasterProtos.AbortProcedureReq
 import org.apache.hadoop.hbase.protobuf.generated.MasterProtos.AbortProcedureResponse;
 import org.apache.hadoop.hbase.protobuf.generated.MasterProtos.AddColumnRequest;
 import org.apache.hadoop.hbase.protobuf.generated.MasterProtos.AssignRegionRequest;
+import org.apache.hadoop.hbase.protobuf.generated.MasterProtos.ClearDeadServersRequest;
 import org.apache.hadoop.hbase.protobuf.generated.MasterProtos.CreateNamespaceRequest;
 import org.apache.hadoop.hbase.protobuf.generated.MasterProtos.CreateTableRequest;
 import org.apache.hadoop.hbase.protobuf.generated.MasterProtos.CreateTableResponse;
@@ -135,6 +136,7 @@ import org.apache.hadoop.hbase.protobuf.generated.MasterProtos.IsRestoreSnapshot
 import org.apache.hadoop.hbase.protobuf.generated.MasterProtos.IsRestoreSnapshotDoneResponse;
 import org.apache.hadoop.hbase.protobuf.generated.MasterProtos.IsSnapshotDoneRequest;
 import org.apache.hadoop.hbase.protobuf.generated.MasterProtos.IsSnapshotDoneResponse;
+import org.apache.hadoop.hbase.protobuf.generated.MasterProtos.ListDeadServersRequest;
 import org.apache.hadoop.hbase.protobuf.generated.MasterProtos.ListNamespaceDescriptorsRequest;
 import org.apache.hadoop.hbase.protobuf.generated.MasterProtos.ListProceduresRequest;
 import org.apache.hadoop.hbase.protobuf.generated.MasterProtos.ListTableDescriptorsByNamespaceRequest;
@@ -4899,6 +4901,34 @@ public class HBaseAdmin implements Admin {
     });
   }
 
+  @Override
+  public List<ServerName> listDeadServers() throws IOException {
+    return executeCallable(new MasterCallable<List<ServerName>>(getConnection())
{
+      @Override
+      public List<ServerName> call(int callTimeout) throws ServiceException {
+        ListDeadServersRequest req = ListDeadServersRequest.newBuilder().build();
+        return ProtobufUtil.toServerNameList(
+                master.listDeadServers(null, req).getServerNameList());
+      }
+    });
+  }
+
+  @Override
+  public List<ServerName> clearDeadServers(final List<ServerName> servers) throws
IOException {
+    if (servers == null || servers.size() == 0) {
+      throw new IllegalArgumentException("servers cannot be null or empty");
+    }
+    return executeCallable(new MasterCallable<List<ServerName>>(getConnection())
{
+      @Override
+      public List<ServerName> call(int callTimeout) throws Exception {
+        ClearDeadServersRequest req = RequestConverter.buildClearDeadServersRequest(servers);
+        return ProtobufUtil.toServerNameList(
+                master.clearDeadServers(null, req).getServerNameList());
+      }
+    });
+  }
+
+
   private RpcControllerFactory getRpcControllerFactory() {
     return rpcControllerFactory;
   }

http://git-wip-us.apache.org/repos/asf/hbase/blob/815673f7/hbase-client/src/main/java/org/apache/hadoop/hbase/protobuf/ProtobufUtil.java
----------------------------------------------------------------------
diff --git a/hbase-client/src/main/java/org/apache/hadoop/hbase/protobuf/ProtobufUtil.java
b/hbase-client/src/main/java/org/apache/hadoop/hbase/protobuf/ProtobufUtil.java
index f0715da..5945e5e 100644
--- a/hbase-client/src/main/java/org/apache/hadoop/hbase/protobuf/ProtobufUtil.java
+++ b/hbase-client/src/main/java/org/apache/hadoop/hbase/protobuf/ProtobufUtil.java
@@ -396,6 +396,20 @@ public final class ProtobufUtil {
     }
     return ServerName.valueOf(hostName, port, startCode);
   }
+  /**
+   * Convert a list of protocol buffer ServerName to a list of ServerName
+   * @param proto protocol buffer ServerNameList
+   * @return a list of ServerName
+   */
+  public static List<ServerName> toServerNameList(
+      List<HBaseProtos.ServerName> proto) {
+    List<ServerName> servers = new ArrayList<ServerName>();
+    for (HBaseProtos.ServerName pbServer : proto) {
+      servers.add(toServerName(pbServer));
+    }
+    return servers;
+  }
+
 
   /**
    * Get HTableDescriptor[] from GetTableDescriptorsResponse protobuf

http://git-wip-us.apache.org/repos/asf/hbase/blob/815673f7/hbase-client/src/main/java/org/apache/hadoop/hbase/protobuf/RequestConverter.java
----------------------------------------------------------------------
diff --git a/hbase-client/src/main/java/org/apache/hadoop/hbase/protobuf/RequestConverter.java
b/hbase-client/src/main/java/org/apache/hadoop/hbase/protobuf/RequestConverter.java
index 32bdcb9..b613b47 100644
--- a/hbase-client/src/main/java/org/apache/hadoop/hbase/protobuf/RequestConverter.java
+++ b/hbase-client/src/main/java/org/apache/hadoop/hbase/protobuf/RequestConverter.java
@@ -82,6 +82,7 @@ import org.apache.hadoop.hbase.protobuf.generated.MasterProtos;
 import org.apache.hadoop.hbase.protobuf.generated.MasterProtos.AddColumnRequest;
 import org.apache.hadoop.hbase.protobuf.generated.MasterProtos.AssignRegionRequest;
 import org.apache.hadoop.hbase.protobuf.generated.MasterProtos.BalanceRequest;
+import org.apache.hadoop.hbase.protobuf.generated.MasterProtos.ClearDeadServersRequest;
 import org.apache.hadoop.hbase.protobuf.generated.MasterProtos.CreateTableRequest;
 import org.apache.hadoop.hbase.protobuf.generated.MasterProtos.DeleteColumnRequest;
 import org.apache.hadoop.hbase.protobuf.generated.MasterProtos.DeleteTableRequest;
@@ -1810,6 +1811,14 @@ public final class RequestConverter {
     return builder.build();
   }
 
+  public static ClearDeadServersRequest buildClearDeadServersRequest(List<ServerName>
deadServers) {
+    ClearDeadServersRequest.Builder builder = ClearDeadServersRequest.newBuilder();
+    for(ServerName server: deadServers) {
+      builder.addServerName(ProtobufUtil.toServerName(server));
+    }
+    return builder.build();
+  }
+
   private static MasterProtos.MasterSwitchType convert(Admin.MasterSwitchType switchType)
{
     switch (switchType) {
       case SPLIT:


Mime
View raw message