hbase-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From chenh...@apache.org
Subject [3/3] hbase git commit: HBASE-15406 Split / merge switch left disabled after early termination of hbck
Date Fri, 15 Apr 2016 07:45:41 GMT
HBASE-15406 Split / merge switch left disabled after early termination of hbck

Conflicts:
        hbase-client/src/main/java/org/apache/hadoop/hbase/client/Admin.java
        hbase-client/src/main/java/org/apache/hadoop/hbase/client/ConnectionImplementation.java
        hbase-client/src/main/java/org/apache/hadoop/hbase/client/HBaseAdmin.java
        hbase-protocol/src/main/java/org/apache/hadoop/hbase/protobuf/generated/MasterProtos.java
        hbase-protocol/src/main/java/org/apache/hadoop/hbase/protobuf/generated/ZooKeeperProtos.java
        hbase-server/src/main/java/org/apache/hadoop/hbase/master/MasterRpcServices.java
        hbase-server/src/main/java/org/apache/hadoop/hbase/util/HBaseFsck.java
        hbase-server/src/test/java/org/apache/hadoop/hbase/client/TestSplitOrMergeStatus.java
        hbase-server/src/test/java/org/apache/hadoop/hbase/util/TestHBaseFsckOneRS.java


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

Branch: refs/heads/branch-1.3
Commit: 438739dc15ac17c7d0f8b85fa42aceaa33c5b6cc
Parents: 6d2dc2a
Author: chenheng <chenheng@apache.org>
Authored: Fri Apr 15 15:24:20 2016 +0800
Committer: chenheng <chenheng@apache.org>
Committed: Fri Apr 15 15:36:40 2016 +0800

----------------------------------------------------------------------
 .../org/apache/hadoop/hbase/client/Admin.java   |   13 +
 .../hadoop/hbase/client/ConnectionManager.java  |    7 +
 .../apache/hadoop/hbase/client/HBaseAdmin.java  |   18 +-
 .../hadoop/hbase/protobuf/RequestConverter.java |   11 +-
 .../hbase/zookeeper/ZooKeeperWatcher.java       |   10 +
 .../hbase/protobuf/generated/MasterProtos.java  | 1891 +++++++++++++-----
 .../protobuf/generated/ZooKeeperProtos.java     |  553 ++++-
 hbase-protocol/src/main/protobuf/Master.proto   |   13 +
 .../src/main/protobuf/ZooKeeper.proto           |   10 +-
 .../hadoop/hbase/master/MasterRpcServices.java  |   24 +
 .../org/apache/hadoop/hbase/util/HBaseFsck.java |  160 +-
 .../hbase/zookeeper/SplitOrMergeTracker.java    |   85 +
 .../hbase/client/TestSplitOrMergeStatus.java    |   39 +-
 .../apache/hadoop/hbase/util/TestHBaseFsck.java |   59 +-
 hbase-shell/src/main/ruby/hbase/admin.rb        |    2 +-
 15 files changed, 2273 insertions(+), 622 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/hbase/blob/438739dc/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 d9361b3..8fd855c 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
@@ -1490,10 +1490,15 @@ public interface Admin extends Abortable, Closeable {
    *
    * @param enabled enabled or not
    * @param synchronous If true, it waits until current split() call, if outstanding, to
return.
+   * @param skipLock if false, we will do lock before change switch.
+   *                 with the lock, other requests to change the switch will be rejected!
+   *                 And when you set it to be false,
+   *                 you should call {@link #releaseSplitOrMergeLockAndRollback()} by yourself
    * @param switchTypes switchType list {@link MasterSwitchType}
    * @return Previous switch value array
    */
   boolean[] setSplitOrMergeEnabled(final boolean enabled, final boolean synchronous,
+                                   final boolean skipLock,
                                    final MasterSwitchType... switchTypes) throws IOException;
 
   /**
@@ -1503,6 +1508,14 @@ public interface Admin extends Abortable, Closeable {
    */
   boolean isSplitOrMergeEnabled(final MasterSwitchType switchType) throws IOException;
 
+  /**
+   *  You should call this method after you call
+   *  {@link #setSplitOrMergeEnabled(boolean, boolean, boolean, MasterSwitchType...)}
+   *  with skipLock be false, this method will release the lock created by above method
+   *  and rollback the switch state to be original state before you change switch
+   * */
+  void releaseSplitOrMergeLockAndRollback() throws IOException;
+
   @InterfaceAudience.Public
   @InterfaceStability.Evolving
   public enum MasterSwitchType {

http://git-wip-us.apache.org/repos/asf/hbase/blob/438739dc/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 dc4a7c9..15e0a39 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
@@ -2105,6 +2105,13 @@ class ConnectionManager {
         }
 
         @Override
+        public MasterProtos.ReleaseSplitOrMergeLockAndRollbackResponse
+          releaseSplitOrMergeLockAndRollback(RpcController controller,
+          MasterProtos.ReleaseSplitOrMergeLockAndRollbackRequest request) throws ServiceException
{
+          return stub.releaseSplitOrMergeLockAndRollback(controller, request);
+        }
+
+        @Override
         public IsNormalizerEnabledResponse isNormalizerEnabled(RpcController controller,
             IsNormalizerEnabledRequest request) throws ServiceException {
           return stub.isNormalizerEnabled(controller, request);

http://git-wip-us.apache.org/repos/asf/hbase/blob/438739dc/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 fe27a59..f0a212f 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
@@ -4804,13 +4804,13 @@ public class HBaseAdmin implements Admin {
 
   @Override
   public boolean[] setSplitOrMergeEnabled(final boolean enabled, final boolean synchronous,
-                                          final MasterSwitchType... switchTypes)
-    throws IOException {
+    final boolean skipLock, final MasterSwitchType... switchTypes) throws IOException {
     return executeCallable(new MasterCallable<boolean[]>(getConnection()) {
       @Override
       public boolean[] call(int callTimeout) throws ServiceException {
         MasterProtos.SetSplitOrMergeEnabledResponse response = master.setSplitOrMergeEnabled(null,
-          RequestConverter.buildSetSplitOrMergeEnabledRequest(enabled, synchronous, switchTypes));
+          RequestConverter.buildSetSplitOrMergeEnabledRequest(enabled, synchronous,
+            skipLock, switchTypes));
         boolean[] result = new boolean[switchTypes.length];
         int i = 0;
         for (Boolean prevValue : response.getPrevValueList()) {
@@ -4832,6 +4832,18 @@ public class HBaseAdmin implements Admin {
     });
   }
 
+  @Override
+  public void releaseSplitOrMergeLockAndRollback() throws IOException {
+    executeCallable(new MasterCallable<Void>(getConnection()) {
+      @Override
+      public Void call(int callTimeout) throws ServiceException {
+        master.releaseSplitOrMergeLockAndRollback(null,
+          RequestConverter.buildReleaseSplitOrMergeLockAndRollbackRequest());
+        return null;
+      }
+    });
+  }
+
   private RpcControllerFactory getRpcControllerFactory() {
     return rpcControllerFactory;
   }

http://git-wip-us.apache.org/repos/asf/hbase/blob/438739dc/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 3b9d366..337b0f3 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
@@ -104,6 +104,7 @@ import org.apache.hadoop.hbase.protobuf.generated.MasterProtos.MoveRegionRequest
 import org.apache.hadoop.hbase.protobuf.generated.MasterProtos.NormalizeRequest;
 import org.apache.hadoop.hbase.protobuf.generated.MasterProtos.OfflineRegionRequest;
 import org.apache.hadoop.hbase.protobuf.generated.MasterProtos.RunCatalogScanRequest;
+import org.apache.hadoop.hbase.protobuf.generated.MasterProtos.ReleaseSplitOrMergeLockAndRollbackRequest;
 import org.apache.hadoop.hbase.protobuf.generated.MasterProtos.SetBalancerRunningRequest;
 import org.apache.hadoop.hbase.protobuf.generated.MasterProtos.SetNormalizerRunningRequest;
 import org.apache.hadoop.hbase.protobuf.generated.MasterProtos.SetSplitOrMergeEnabledRequest;
@@ -1747,6 +1748,13 @@ public final class RequestConverter {
     return builder.build();
   }
 
+  public static ReleaseSplitOrMergeLockAndRollbackRequest
+    buildReleaseSplitOrMergeLockAndRollbackRequest() {
+    ReleaseSplitOrMergeLockAndRollbackRequest.Builder builder =
+      ReleaseSplitOrMergeLockAndRollbackRequest.newBuilder();
+    return builder.build();
+  }
+
   /**
    * Creates a protocol buffer SetSplitOrMergeEnabledRequest
    *
@@ -1757,10 +1765,11 @@ public final class RequestConverter {
    * @return a SetSplitOrMergeEnabledRequest
    */
   public static SetSplitOrMergeEnabledRequest buildSetSplitOrMergeEnabledRequest(boolean
enabled,
-    boolean synchronous, Admin.MasterSwitchType... switchTypes) {
+    boolean synchronous, boolean skipLock, Admin.MasterSwitchType... switchTypes) {
     SetSplitOrMergeEnabledRequest.Builder builder = SetSplitOrMergeEnabledRequest.newBuilder();
     builder.setEnabled(enabled);
     builder.setSynchronous(synchronous);
+    builder.setSkipLock(skipLock);
     for (Admin.MasterSwitchType switchType : switchTypes) {
       builder.addSwitchTypes(convert(switchType));
     }

http://git-wip-us.apache.org/repos/asf/hbase/blob/438739dc/hbase-client/src/main/java/org/apache/hadoop/hbase/zookeeper/ZooKeeperWatcher.java
----------------------------------------------------------------------
diff --git a/hbase-client/src/main/java/org/apache/hadoop/hbase/zookeeper/ZooKeeperWatcher.java
b/hbase-client/src/main/java/org/apache/hadoop/hbase/zookeeper/ZooKeeperWatcher.java
index 85749d3..f17acb8 100644
--- a/hbase-client/src/main/java/org/apache/hadoop/hbase/zookeeper/ZooKeeperWatcher.java
+++ b/hbase-client/src/main/java/org/apache/hadoop/hbase/zookeeper/ZooKeeperWatcher.java
@@ -120,6 +120,8 @@ public class ZooKeeperWatcher implements Watcher, Abortable, Closeable
{
   private String regionNormalizerZNode;
   // znode containing the state of all switches, currently there are split and merge child
node.
   private String switchZNode;
+  // znode containing the lock for the switches
+  private String switchLockZNode;
   // znode containing the lock for the tables
   public String tableLockZNode;
   // znode containing the state of recovering regions
@@ -448,6 +450,7 @@ public class ZooKeeperWatcher implements Watcher, Abortable, Closeable
{
     regionNormalizerZNode = ZKUtil.joinZNode(baseZNode,
       conf.get("zookeeper.znode.regionNormalizer", "normalizer"));
     switchZNode = ZKUtil.joinZNode(baseZNode, conf.get("zookeeper.znode.switch", "switch"));
+    switchLockZNode = ZKUtil.joinZNode(switchZNode, "locks");
     tableLockZNode = ZKUtil.joinZNode(baseZNode,
         conf.get("zookeeper.znode.tableLock", "table-lock"));
     recoveringRegionsZNode = ZKUtil.joinZNode(baseZNode,
@@ -814,4 +817,11 @@ public class ZooKeeperWatcher implements Watcher, Abortable, Closeable
{
   public String getSwitchZNode() {
     return switchZNode;
   }
+
+  /**
+   *  @return ZK node for switchLock node.
+   * */
+  public String getSwitchLockZNode() {
+    return switchLockZNode;
+  }
 }


Mime
View raw message