hbase-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From te...@apache.org
Subject hbase git commit: HBASE-15488 Add ACL for setting split merge switch
Date Tue, 05 Apr 2016 17:23:34 GMT
Repository: hbase
Updated Branches:
  refs/heads/HBASE-7912 b37cc7606 -> f202b8beb


HBASE-15488 Add ACL for setting split merge switch


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

Branch: refs/heads/HBASE-7912
Commit: f202b8beb78983581480b0c4d8d11a70ec69c8f2
Parents: b37cc76
Author: tedyu <yuzhihong@gmail.com>
Authored: Tue Apr 5 10:23:14 2016 -0700
Committer: tedyu <yuzhihong@gmail.com>
Committed: Tue Apr 5 10:23:14 2016 -0700

----------------------------------------------------------------------
 .../hbase/coprocessor/BaseMasterObserver.java   | 12 ++++++++++
 .../hbase/coprocessor/MasterObserver.java       | 19 ++++++++++++++++
 .../hbase/master/MasterCoprocessorHost.java     | 23 ++++++++++++++++++++
 .../hadoop/hbase/master/MasterRpcServices.java  | 11 +++++++++-
 .../hbase/security/access/AccessController.java | 13 +++++++++++
 .../visibility/VisibilityController.java        | 12 ++++++++++
 .../hbase/coprocessor/TestMasterObserver.java   | 11 ++++++++++
 .../security/access/TestAccessController.java   | 16 ++++++++++++++
 8 files changed, 116 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/hbase/blob/f202b8be/hbase-server/src/main/java/org/apache/hadoop/hbase/coprocessor/BaseMasterObserver.java
----------------------------------------------------------------------
diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/coprocessor/BaseMasterObserver.java
b/hbase-server/src/main/java/org/apache/hadoop/hbase/coprocessor/BaseMasterObserver.java
index 0cdf0ad..7da63bf 100644
--- a/hbase-server/src/main/java/org/apache/hadoop/hbase/coprocessor/BaseMasterObserver.java
+++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/coprocessor/BaseMasterObserver.java
@@ -33,6 +33,7 @@ import org.apache.hadoop.hbase.ServerName;
 import org.apache.hadoop.hbase.TableName;
 import org.apache.hadoop.hbase.classification.InterfaceAudience;
 import org.apache.hadoop.hbase.classification.InterfaceStability;
+import org.apache.hadoop.hbase.client.Admin;
 import org.apache.hadoop.hbase.master.RegionPlan;
 import org.apache.hadoop.hbase.master.procedure.MasterProcedureEnv;
 import org.apache.hadoop.hbase.procedure2.ProcedureExecutor;
@@ -437,6 +438,17 @@ public class BaseMasterObserver implements MasterObserver {
   }
 
   @Override
+  public boolean preSetSplitOrMergeEnabled(final ObserverContext<MasterCoprocessorEnvironment>
ctx,
+      final boolean newValue, final Admin.MasterSwitchType switchType) throws IOException
{
+    return false;
+  }
+
+  @Override
+  public void postSetSplitOrMergeEnabled(final ObserverContext<MasterCoprocessorEnvironment>
ctx,
+      final boolean newValue, final Admin.MasterSwitchType switchType) throws IOException
{
+  }
+
+  @Override
   public void preBalance(ObserverContext<MasterCoprocessorEnvironment> ctx)
       throws IOException {
   }

http://git-wip-us.apache.org/repos/asf/hbase/blob/f202b8be/hbase-server/src/main/java/org/apache/hadoop/hbase/coprocessor/MasterObserver.java
----------------------------------------------------------------------
diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/coprocessor/MasterObserver.java
b/hbase-server/src/main/java/org/apache/hadoop/hbase/coprocessor/MasterObserver.java
index b7a535b..230f4ce 100644
--- a/hbase-server/src/main/java/org/apache/hadoop/hbase/coprocessor/MasterObserver.java
+++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/coprocessor/MasterObserver.java
@@ -33,6 +33,7 @@ import org.apache.hadoop.hbase.ServerName;
 import org.apache.hadoop.hbase.TableName;
 import org.apache.hadoop.hbase.classification.InterfaceAudience;
 import org.apache.hadoop.hbase.classification.InterfaceStability;
+import org.apache.hadoop.hbase.client.Admin;
 import org.apache.hadoop.hbase.master.RegionPlan;
 import org.apache.hadoop.hbase.master.procedure.MasterProcedureEnv;
 import org.apache.hadoop.hbase.procedure2.ProcedureExecutor;
@@ -797,6 +798,24 @@ public interface MasterObserver extends Coprocessor {
       throws IOException;
 
   /**
+   * Called prior to setting split / merge switch
+   * @param ctx the coprocessor instance's environment
+   * @param newValue the new value submitted in the call
+   * @param switchType type of switch
+   */
+  boolean preSetSplitOrMergeEnabled(final ObserverContext<MasterCoprocessorEnvironment>
ctx,
+      final boolean newValue, final Admin.MasterSwitchType switchType) throws IOException;
+
+  /**
+   * Called after setting split / merge switch
+   * @param ctx the coprocessor instance's environment
+   * @param newValue the new value submitted in the call
+   * @param switchType type of switch
+   */
+  void postSetSplitOrMergeEnabled(final ObserverContext<MasterCoprocessorEnvironment>
ctx,
+      final boolean newValue, final Admin.MasterSwitchType switchType) throws IOException;
+
+  /**
    * Called prior to modifying the flag used to enable/disable region balancing.
    * @param ctx the coprocessor instance's environment
    * @param newValue the new flag value submitted in the call

http://git-wip-us.apache.org/repos/asf/hbase/blob/f202b8be/hbase-server/src/main/java/org/apache/hadoop/hbase/master/MasterCoprocessorHost.java
----------------------------------------------------------------------
diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/master/MasterCoprocessorHost.java
b/hbase-server/src/main/java/org/apache/hadoop/hbase/master/MasterCoprocessorHost.java
index 5888b3e..53582cd 100644
--- a/hbase-server/src/main/java/org/apache/hadoop/hbase/master/MasterCoprocessorHost.java
+++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/master/MasterCoprocessorHost.java
@@ -35,6 +35,7 @@ import org.apache.hadoop.hbase.ProcedureInfo;
 import org.apache.hadoop.hbase.ServerName;
 import org.apache.hadoop.hbase.TableName;
 import org.apache.hadoop.hbase.classification.InterfaceAudience;
+import org.apache.hadoop.hbase.client.Admin;
 import org.apache.hadoop.hbase.coprocessor.CoprocessorHost;
 import org.apache.hadoop.hbase.coprocessor.CoprocessorService;
 import org.apache.hadoop.hbase.coprocessor.MasterCoprocessorEnvironment;
@@ -771,6 +772,28 @@ public class MasterCoprocessorHost
     });
   }
 
+  public boolean preSetSplitOrMergeEnabled(final boolean newValue,
+      final Admin.MasterSwitchType switchType) throws IOException {
+    return execOperation(coprocessors.isEmpty() ? null : new CoprocessorOperation() {
+      @Override
+      public void call(MasterObserver oserver, ObserverContext<MasterCoprocessorEnvironment>
ctx)
+          throws IOException {
+        oserver.preSetSplitOrMergeEnabled(ctx, newValue, switchType);
+      }
+    });
+  }
+
+  public void postSetSplitOrMergeEnabled(final boolean newValue,
+      final Admin.MasterSwitchType switchType) throws IOException {
+    execOperation(coprocessors.isEmpty() ? null : new CoprocessorOperation() {
+      @Override
+      public void call(MasterObserver oserver, ObserverContext<MasterCoprocessorEnvironment>
ctx)
+          throws IOException {
+        oserver.postSetSplitOrMergeEnabled(ctx, newValue, switchType);
+      }
+    });
+  }
+
   public boolean preBalanceSwitch(final boolean b) throws IOException {
     return execOperationWithResult(b, coprocessors.isEmpty() ? null :
         new CoprocessorOperationWithResult<Boolean>() {

http://git-wip-us.apache.org/repos/asf/hbase/blob/f202b8be/hbase-server/src/main/java/org/apache/hadoop/hbase/master/MasterRpcServices.java
----------------------------------------------------------------------
diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/master/MasterRpcServices.java
b/hbase-server/src/main/java/org/apache/hadoop/hbase/master/MasterRpcServices.java
index e3004bb..930bfd6 100644
--- a/hbase-server/src/main/java/org/apache/hadoop/hbase/master/MasterRpcServices.java
+++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/master/MasterRpcServices.java
@@ -1536,8 +1536,17 @@ public class MasterRpcServices extends RSRpcServices
       for (MasterSwitchType masterSwitchType : request.getSwitchTypesList()) {
         Admin.MasterSwitchType switchType = convert(masterSwitchType);
         boolean oldValue = master.isSplitOrMergeEnabled(switchType);
-        master.getSplitOrMergeTracker().setSplitOrMergeEnabled(newValue, switchType);
         response.addPrevValue(oldValue);
+        boolean bypass = false;
+        if (master.cpHost != null) {
+          bypass = master.cpHost.preSetSplitOrMergeEnabled(newValue, switchType);
+        }
+        if (!bypass) {
+          master.getSplitOrMergeTracker().setSplitOrMergeEnabled(newValue, switchType);
+        }
+        if (master.cpHost != null) {
+          master.cpHost.postSetSplitOrMergeEnabled(newValue, switchType);
+        }
       }
     } catch (IOException e) {
       throw new ServiceException(e);

http://git-wip-us.apache.org/repos/asf/hbase/blob/f202b8be/hbase-server/src/main/java/org/apache/hadoop/hbase/security/access/AccessController.java
----------------------------------------------------------------------
diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/security/access/AccessController.java
b/hbase-server/src/main/java/org/apache/hadoop/hbase/security/access/AccessController.java
index 43f9833..f81ab8c 100644
--- a/hbase-server/src/main/java/org/apache/hadoop/hbase/security/access/AccessController.java
+++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/security/access/AccessController.java
@@ -58,6 +58,7 @@ import org.apache.hadoop.hbase.Tag;
 import org.apache.hadoop.hbase.TagRewriteCell;
 import org.apache.hadoop.hbase.TagUtil;
 import org.apache.hadoop.hbase.classification.InterfaceAudience;
+import org.apache.hadoop.hbase.client.Admin;
 import org.apache.hadoop.hbase.client.Append;
 import org.apache.hadoop.hbase.client.Delete;
 import org.apache.hadoop.hbase.client.Durability;
@@ -1258,6 +1259,18 @@ public class AccessController extends BaseMasterAndRegionObserver
   }
 
   @Override
+  public boolean preSetSplitOrMergeEnabled(final ObserverContext<MasterCoprocessorEnvironment>
ctx,
+      final boolean newValue, final Admin.MasterSwitchType switchType) throws IOException
{
+    requirePermission("setSplitOrMergeEnabled", Action.ADMIN);
+    return false;
+  }
+
+  @Override
+  public void postSetSplitOrMergeEnabled(final ObserverContext<MasterCoprocessorEnvironment>
ctx,
+      final boolean newValue, final Admin.MasterSwitchType switchType) throws IOException
{
+  }
+
+  @Override
   public void preBalance(ObserverContext<MasterCoprocessorEnvironment> c)
       throws IOException {
     requirePermission("balance", Action.ADMIN);

http://git-wip-us.apache.org/repos/asf/hbase/blob/f202b8be/hbase-server/src/main/java/org/apache/hadoop/hbase/security/visibility/VisibilityController.java
----------------------------------------------------------------------
diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/security/visibility/VisibilityController.java
b/hbase-server/src/main/java/org/apache/hadoop/hbase/security/visibility/VisibilityController.java
index 347f3da..6e2f8ed 100644
--- a/hbase-server/src/main/java/org/apache/hadoop/hbase/security/visibility/VisibilityController.java
+++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/security/visibility/VisibilityController.java
@@ -51,6 +51,7 @@ import org.apache.hadoop.hbase.TagRewriteCell;
 import org.apache.hadoop.hbase.TagType;
 import org.apache.hadoop.hbase.TagUtil;
 import org.apache.hadoop.hbase.classification.InterfaceAudience;
+import org.apache.hadoop.hbase.client.Admin;
 import org.apache.hadoop.hbase.client.Append;
 import org.apache.hadoop.hbase.client.Delete;
 import org.apache.hadoop.hbase.client.Get;
@@ -308,6 +309,17 @@ public class VisibilityController extends BaseMasterAndRegionObserver
implements
   }
 
   @Override
+  public boolean preSetSplitOrMergeEnabled(final ObserverContext<MasterCoprocessorEnvironment>
ctx,
+      final boolean newValue, final Admin.MasterSwitchType switchType) throws IOException
{
+    return false;
+  }
+
+  @Override
+  public void postSetSplitOrMergeEnabled(final ObserverContext<MasterCoprocessorEnvironment>
ctx,
+      final boolean newValue, final Admin.MasterSwitchType switchType) throws IOException
{
+  }
+
+  @Override
   public void preBatchMutate(ObserverContext<RegionCoprocessorEnvironment> c,
       MiniBatchOperationInProgress<Mutation> miniBatchOp) throws IOException {
     if (c.getEnvironment().getRegion().getRegionInfo().getTable().isSystemTable()) {

http://git-wip-us.apache.org/repos/asf/hbase/blob/f202b8be/hbase-server/src/test/java/org/apache/hadoop/hbase/coprocessor/TestMasterObserver.java
----------------------------------------------------------------------
diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/coprocessor/TestMasterObserver.java
b/hbase-server/src/test/java/org/apache/hadoop/hbase/coprocessor/TestMasterObserver.java
index b244101..5b0d202 100644
--- a/hbase-server/src/test/java/org/apache/hadoop/hbase/coprocessor/TestMasterObserver.java
+++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/coprocessor/TestMasterObserver.java
@@ -345,6 +345,17 @@ public class TestMasterObserver {
     }
 
     @Override
+    public boolean preSetSplitOrMergeEnabled(final ObserverContext<MasterCoprocessorEnvironment>
ctx,
+        final boolean newValue, final Admin.MasterSwitchType switchType) throws IOException
{
+      return false;
+    }
+
+    @Override
+    public void postSetSplitOrMergeEnabled(final ObserverContext<MasterCoprocessorEnvironment>
ctx,
+        final boolean newValue, final Admin.MasterSwitchType switchType) throws IOException
{
+    }
+
+    @Override
     public void preModifyTable(ObserverContext<MasterCoprocessorEnvironment> env,
         TableName tableName, HTableDescriptor htd) throws IOException {
       if (bypass) {

http://git-wip-us.apache.org/repos/asf/hbase/blob/f202b8be/hbase-server/src/test/java/org/apache/hadoop/hbase/security/access/TestAccessController.java
----------------------------------------------------------------------
diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/security/access/TestAccessController.java
b/hbase-server/src/test/java/org/apache/hadoop/hbase/security/access/TestAccessController.java
index 081663d..7317abb 100644
--- a/hbase-server/src/test/java/org/apache/hadoop/hbase/security/access/TestAccessController.java
+++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/security/access/TestAccessController.java
@@ -707,6 +707,22 @@ public class TestAccessController extends SecureTestUtil {
   }
 
   @Test (timeout=180000)
+  public void testSetSplitOrMergeEnabled() throws Exception {
+    AccessTestAction action = new AccessTestAction() {
+      @Override
+      public Object run() throws Exception {
+        ACCESS_CONTROLLER.preSetSplitOrMergeEnabled(ObserverContext.createAndPrepare(CP_ENV,
null),
+          true, Admin.MasterSwitchType.MERGE);
+        return null;
+      }
+    };
+
+    verifyAllowed(action, SUPERUSER, USER_ADMIN, USER_GROUP_ADMIN);
+    verifyDenied(action, USER_CREATE, USER_OWNER, USER_RW, USER_RO, USER_NONE, USER_GROUP_READ,
+      USER_GROUP_WRITE, USER_GROUP_CREATE);
+  }
+
+  @Test (timeout=180000)
   public void testBalance() throws Exception {
     AccessTestAction action = new AccessTestAction() {
       @Override


Mime
View raw message