hbase-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jerry...@apache.org
Subject [3/3] hbase git commit: HBASE-16010 Put draining function through Admin API (Matt Warhaftig)
Date Fri, 23 Dec 2016 21:41:59 GMT
HBASE-16010 Put draining function through Admin API (Matt Warhaftig)


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

Branch: refs/heads/master
Commit: 992e5717d4e4deeef46836acea323a312b1e0851
Parents: 8fb9a91
Author: Jerry He <jerryjch@apache.org>
Authored: Fri Dec 23 13:41:36 2016 -0800
Committer: Jerry He <jerryjch@apache.org>
Committed: Fri Dec 23 13:41:36 2016 -0800

----------------------------------------------------------------------
 .../org/apache/hadoop/hbase/client/Admin.java   |   19 +
 .../hbase/client/ConnectionImplementation.java  |   25 +
 .../apache/hadoop/hbase/client/HBaseAdmin.java  |   58 +
 .../shaded/protobuf/generated/MasterProtos.java | 3995 +++++++++++++++++-
 .../src/main/protobuf/Master.proto              |   33 +
 .../org/apache/hadoop/hbase/master/HMaster.java |   50 +
 .../hadoop/hbase/master/MasterRpcServices.java  |   51 +
 .../hadoop/hbase/master/MasterServices.java     |   20 +
 .../apache/hadoop/hbase/client/TestAdmin2.java  |   77 +
 .../hbase/master/MockNoopMasterServices.java    |   15 +
 .../hbase/zookeeper/TestZooKeeperACL.java       |   21 +
 11 files changed, 4217 insertions(+), 147 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/hbase/blob/992e5717/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 e7ea4d9..fe3960f 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
@@ -1858,4 +1858,23 @@ public interface Admin extends Abortable, Closeable {
    */
   default void disableReplicationPeer(final String peerId) throws IOException {
   }
+
+  /**
+   * Mark a region server as draining to prevent additional regions from getting assigned
to it.
+   * @param servers List of region servers to drain.
+   */
+  void drainRegionServers(List<ServerName> servers) throws IOException;
+
+  /**
+   * List region servers marked as draining to not get additional regions assigned to them.
+   * @return List of draining region servers.
+   */
+  List<ServerName> listDrainingRegionServers() throws IOException;
+
+  /**
+   * Remove drain from a region server to allow additional regions assignments.
+   * @param servers List of region servers to remove drain from.
+   */
+  void removeDrainFromRegionServers(List<ServerName> servers) throws IOException;
+
 }

http://git-wip-us.apache.org/repos/asf/hbase/blob/992e5717/hbase-client/src/main/java/org/apache/hadoop/hbase/client/ConnectionImplementation.java
----------------------------------------------------------------------
diff --git a/hbase-client/src/main/java/org/apache/hadoop/hbase/client/ConnectionImplementation.java
b/hbase-client/src/main/java/org/apache/hadoop/hbase/client/ConnectionImplementation.java
index ff939aa..a597be3 100644
--- a/hbase-client/src/main/java/org/apache/hadoop/hbase/client/ConnectionImplementation.java
+++ b/hbase-client/src/main/java/org/apache/hadoop/hbase/client/ConnectionImplementation.java
@@ -78,12 +78,18 @@ import org.apache.hadoop.hbase.shaded.protobuf.generated.AdminProtos;
 import org.apache.hadoop.hbase.shaded.protobuf.generated.ClientProtos;
 import org.apache.hadoop.hbase.shaded.protobuf.generated.ClientProtos.ClientService.BlockingInterface;
 import org.apache.hadoop.hbase.shaded.protobuf.generated.MasterProtos;
+import org.apache.hadoop.hbase.shaded.protobuf.generated.MasterProtos.DrainRegionServersRequest;
+import org.apache.hadoop.hbase.shaded.protobuf.generated.MasterProtos.DrainRegionServersResponse;
+import org.apache.hadoop.hbase.shaded.protobuf.generated.MasterProtos.ListDrainingRegionServersRequest;
+import org.apache.hadoop.hbase.shaded.protobuf.generated.MasterProtos.ListDrainingRegionServersResponse;
 import org.apache.hadoop.hbase.shaded.protobuf.generated.MasterProtos.IsBalancerEnabledRequest;
 import org.apache.hadoop.hbase.shaded.protobuf.generated.MasterProtos.IsBalancerEnabledResponse;
 import org.apache.hadoop.hbase.shaded.protobuf.generated.MasterProtos.IsNormalizerEnabledRequest;
 import org.apache.hadoop.hbase.shaded.protobuf.generated.MasterProtos.IsNormalizerEnabledResponse;
 import org.apache.hadoop.hbase.shaded.protobuf.generated.MasterProtos.NormalizeRequest;
 import org.apache.hadoop.hbase.shaded.protobuf.generated.MasterProtos.NormalizeResponse;
+import org.apache.hadoop.hbase.shaded.protobuf.generated.MasterProtos.RemoveDrainFromRegionServersRequest;
+import org.apache.hadoop.hbase.shaded.protobuf.generated.MasterProtos.RemoveDrainFromRegionServersResponse;
 import org.apache.hadoop.hbase.shaded.protobuf.generated.MasterProtos.SecurityCapabilitiesRequest;
 import org.apache.hadoop.hbase.shaded.protobuf.generated.MasterProtos.SecurityCapabilitiesResponse;
 import org.apache.hadoop.hbase.shaded.protobuf.generated.MasterProtos.SetNormalizerRunningRequest;
@@ -1669,6 +1675,25 @@ class ConnectionImplementation implements ClusterConnection, Closeable
{
           DisableReplicationPeerRequest request) throws ServiceException {
         return stub.disableReplicationPeer(controller, request);
       }
+
+      @Override
+      public ListDrainingRegionServersResponse listDrainingRegionServers(RpcController controller,
+          ListDrainingRegionServersRequest request) throws ServiceException {
+        return stub.listDrainingRegionServers(controller, request);
+      }
+
+      @Override
+      public DrainRegionServersResponse drainRegionServers(RpcController controller,
+          DrainRegionServersRequest request) throws ServiceException {
+        return stub.drainRegionServers(controller, request);
+      }
+
+      @Override
+      public RemoveDrainFromRegionServersResponse removeDrainFromRegionServers(
+          RpcController controller, RemoveDrainFromRegionServersRequest request)
+          throws ServiceException {
+        return stub.removeDrainFromRegionServers(controller, request);
+      }
     };
   }
 

http://git-wip-us.apache.org/repos/asf/hbase/blob/992e5717/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 61f7435..ec4a5c1 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
@@ -120,6 +120,7 @@ import org.apache.hadoop.hbase.shaded.protobuf.generated.MasterProtos.DeleteTabl
 import org.apache.hadoop.hbase.shaded.protobuf.generated.MasterProtos.DeleteTableResponse;
 import org.apache.hadoop.hbase.shaded.protobuf.generated.MasterProtos.DisableTableRequest;
 import org.apache.hadoop.hbase.shaded.protobuf.generated.MasterProtos.DisableTableResponse;
+import org.apache.hadoop.hbase.shaded.protobuf.generated.MasterProtos.DrainRegionServersRequest;
 import org.apache.hadoop.hbase.shaded.protobuf.generated.MasterProtos.EnableTableRequest;
 import org.apache.hadoop.hbase.shaded.protobuf.generated.MasterProtos.EnableTableResponse;
 import org.apache.hadoop.hbase.shaded.protobuf.generated.MasterProtos.ExecProcedureRequest;
@@ -140,6 +141,7 @@ import org.apache.hadoop.hbase.shaded.protobuf.generated.MasterProtos.IsProcedur
 import org.apache.hadoop.hbase.shaded.protobuf.generated.MasterProtos.IsProcedureDoneResponse;
 import org.apache.hadoop.hbase.shaded.protobuf.generated.MasterProtos.IsSnapshotDoneRequest;
 import org.apache.hadoop.hbase.shaded.protobuf.generated.MasterProtos.IsSnapshotDoneResponse;
+import org.apache.hadoop.hbase.shaded.protobuf.generated.MasterProtos.ListDrainingRegionServersRequest;
 import org.apache.hadoop.hbase.shaded.protobuf.generated.MasterProtos.ListNamespaceDescriptorsRequest;
 import org.apache.hadoop.hbase.shaded.protobuf.generated.MasterProtos.ListProceduresRequest;
 import org.apache.hadoop.hbase.shaded.protobuf.generated.MasterProtos.ListTableDescriptorsByNamespaceRequest;
@@ -155,6 +157,7 @@ import org.apache.hadoop.hbase.shaded.protobuf.generated.MasterProtos.ModifyName
 import org.apache.hadoop.hbase.shaded.protobuf.generated.MasterProtos.ModifyTableRequest;
 import org.apache.hadoop.hbase.shaded.protobuf.generated.MasterProtos.ModifyTableResponse;
 import org.apache.hadoop.hbase.shaded.protobuf.generated.MasterProtos.MoveRegionRequest;
+import org.apache.hadoop.hbase.shaded.protobuf.generated.MasterProtos.RemoveDrainFromRegionServersRequest;
 import org.apache.hadoop.hbase.shaded.protobuf.generated.MasterProtos.RestoreSnapshotRequest;
 import org.apache.hadoop.hbase.shaded.protobuf.generated.MasterProtos.RestoreSnapshotResponse;
 import org.apache.hadoop.hbase.shaded.protobuf.generated.MasterProtos.SecurityCapabilitiesRequest;
@@ -3794,4 +3797,59 @@ public class HBaseAdmin implements Admin {
       }
     });
   }
+
+  @Override
+  public void drainRegionServers(List<ServerName> servers) throws IOException {
+    final List<HBaseProtos.ServerName> pbServers = new ArrayList<HBaseProtos.ServerName>();
+    for (ServerName server : servers) {
+      // Parse to ServerName to do simple validation.
+      ServerName.parseServerName(server.toString());
+      pbServers.add(ProtobufUtil.toServerName(server));
+    }
+
+    executeCallable(new MasterCallable<Void>(getConnection(), getRpcControllerFactory())
{
+      @Override
+      public Void rpcCall() throws ServiceException {
+        DrainRegionServersRequest req =
+            DrainRegionServersRequest.newBuilder().addAllServerName(pbServers).build();
+        master.drainRegionServers(getRpcController(), req);
+        return null;
+      }
+    });
+  }
+
+  @Override
+  public List<ServerName> listDrainingRegionServers() throws IOException {
+    return executeCallable(new MasterCallable<List<ServerName>>(getConnection(),
+              getRpcControllerFactory()) {
+      @Override
+      public List<ServerName> rpcCall() throws ServiceException {
+        ListDrainingRegionServersRequest req = ListDrainingRegionServersRequest.newBuilder().build();
+        List<ServerName> servers = new ArrayList<ServerName>();
+        for (HBaseProtos.ServerName server : master.listDrainingRegionServers(null, req)
+            .getServerNameList()) {
+          servers.add(ProtobufUtil.toServerName(server));
+        }
+        return servers;
+      }
+    });
+  }
+
+  @Override
+  public void removeDrainFromRegionServers(List<ServerName> servers) throws IOException
{
+    final List<HBaseProtos.ServerName> pbServers = new ArrayList<HBaseProtos.ServerName>();
+    for (ServerName server : servers) {
+      pbServers.add(ProtobufUtil.toServerName(server));
+    }
+
+    executeCallable(new MasterCallable<Void>(getConnection(), getRpcControllerFactory())
{
+      @Override
+      public Void rpcCall() throws ServiceException {
+        RemoveDrainFromRegionServersRequest req = RemoveDrainFromRegionServersRequest.newBuilder()
+            .addAllServerName(pbServers).build();
+        master.removeDrainFromRegionServers(getRpcController(), req);
+        return null;
+      }
+    });
+  }
 }


Mime
View raw message