Repository: hbase Updated Branches: refs/heads/master 2ceeb54c9 -> 410368b84
HBASE-18859 Purge PB from BulkLoadObserver Signed-off-by: Michael Stack <st...@apache.org> Project: http://git-wip-us.apache.org/repos/asf/hbase/repo Commit: http://git-wip-us.apache.org/repos/asf/hbase/commit/410368b8 Tree: http://git-wip-us.apache.org/repos/asf/hbase/tree/410368b8 Diff: http://git-wip-us.apache.org/repos/asf/hbase/diff/410368b8 Branch: refs/heads/master Commit: 410368b84eeaa31e6e21c69df8361a32763a1c57 Parents: 2ceeb54 Author: Michael Stack <st...@apache.org> Authored: Thu Sep 21 16:28:33 2017 -0700 Committer: Michael Stack <st...@apache.org> Committed: Mon Sep 25 21:14:33 2017 -0700 ---------------------------------------------------------------------- .../security/access/SecureBulkLoadEndpoint.java | 5 +++++ .../hadoop/hbase/coprocessor/BulkLoadObserver.java | 15 +++++++++++---- .../hadoop/hbase/regionserver/RowProcessor.java | 2 +- .../hbase/regionserver/SecureBulkLoadManager.java | 5 +++-- .../hbase/security/access/AccessController.java | 10 ++++------ .../hbase/security/access/TestAccessController.java | 6 ++---- 6 files changed, 26 insertions(+), 17 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/hbase/blob/410368b8/hbase-endpoint/src/main/java/org/apache/hadoop/hbase/security/access/SecureBulkLoadEndpoint.java ---------------------------------------------------------------------- diff --git a/hbase-endpoint/src/main/java/org/apache/hadoop/hbase/security/access/SecureBulkLoadEndpoint.java b/hbase-endpoint/src/main/java/org/apache/hadoop/hbase/security/access/SecureBulkLoadEndpoint.java index f24583d..2a4b4f3 100644 --- a/hbase-endpoint/src/main/java/org/apache/hadoop/hbase/security/access/SecureBulkLoadEndpoint.java +++ b/hbase-endpoint/src/main/java/org/apache/hadoop/hbase/security/access/SecureBulkLoadEndpoint.java @@ -80,6 +80,7 @@ public class SecureBulkLoadEndpoint extends SecureBulkLoadService try { SecureBulkLoadManager secureBulkLoadManager = this.env.getRegionServerServices().getSecureBulkLoadManager(); + String bulkToken = secureBulkLoadManager.prepareBulkLoad(this.env.getRegion(), convert(request)); done.run(PrepareBulkLoadResponse.newBuilder().setBulkToken(bulkToken).build()); @@ -115,6 +116,10 @@ public class SecureBulkLoadEndpoint extends SecureBulkLoadService done.run(null); } + /** + * Convert from CPEP protobuf 2.5 to internal protobuf 3.3. + * @throws org.apache.hadoop.hbase.shaded.com.google.protobuf.InvalidProtocolBufferException + */ org.apache.hadoop.hbase.shaded.protobuf.generated.ClientProtos.CleanupBulkLoadRequest convert(CleanupBulkLoadRequest request) throws org.apache.hadoop.hbase.shaded.com.google.protobuf.InvalidProtocolBufferException { http://git-wip-us.apache.org/repos/asf/hbase/blob/410368b8/hbase-server/src/main/java/org/apache/hadoop/hbase/coprocessor/BulkLoadObserver.java ---------------------------------------------------------------------- diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/coprocessor/BulkLoadObserver.java b/hbase-server/src/main/java/org/apache/hadoop/hbase/coprocessor/BulkLoadObserver.java index e9cd493..e891cc0 100644 --- a/hbase-server/src/main/java/org/apache/hadoop/hbase/coprocessor/BulkLoadObserver.java +++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/coprocessor/BulkLoadObserver.java @@ -23,6 +23,7 @@ import java.io.IOException; import org.apache.hadoop.hbase.Coprocessor; import org.apache.hadoop.hbase.HBaseInterfaceAudience; +import org.apache.hadoop.hbase.TableName; import org.apache.yetus.audience.InterfaceAudience; import org.apache.yetus.audience.InterfaceStability; import org.apache.hadoop.hbase.shaded.protobuf.generated.ClientProtos.PrepareBulkLoadRequest; @@ -52,16 +53,22 @@ public interface BulkLoadObserver extends Coprocessor { /** * Called as part of SecureBulkLoadEndpoint.prepareBulkLoad() RPC call. * It can't bypass the default action, e.g., ctx.bypass() won't have effect. + * If you need to get the region or table name, get it from the + * <code>ctx</code> as follows: <code>code>ctx.getEnvironment().getRegion()</code>. Use + * getRegionInfo to fetch the encodedName and use getTabldDescriptor() to get the tableName. * @param ctx the environment to interact with the framework and master */ - default void prePrepareBulkLoad(ObserverContext<RegionCoprocessorEnvironment> ctx, - PrepareBulkLoadRequest request) throws IOException {} + default void prePrepareBulkLoad(ObserverContext<RegionCoprocessorEnvironment> ctx) + throws IOException {} /** * Called as part of SecureBulkLoadEndpoint.cleanupBulkLoad() RPC call. * It can't bypass the default action, e.g., ctx.bypass() won't have effect. + * If you need to get the region or table name, get it from the + * <code>ctx</code> as follows: <code>code>ctx.getEnvironment().getRegion()</code>. Use + * getRegionInfo to fetch the encodedName and use getTabldDescriptor() to get the tableName. * @param ctx the environment to interact with the framework and master */ - default void preCleanupBulkLoad(ObserverContext<RegionCoprocessorEnvironment> ctx, - CleanupBulkLoadRequest request) throws IOException {} + default void preCleanupBulkLoad(ObserverContext<RegionCoprocessorEnvironment> ctx) + throws IOException {} } http://git-wip-us.apache.org/repos/asf/hbase/blob/410368b8/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/RowProcessor.java ---------------------------------------------------------------------- diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/RowProcessor.java b/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/RowProcessor.java index f0fae05..625d9a6 100644 --- a/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/RowProcessor.java +++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/RowProcessor.java @@ -32,7 +32,7 @@ import org.apache.hadoop.hbase.wal.WALEdit; import com.google.protobuf.Message; /** - * Defines the procedure to atomically perform multiple scans and mutations + * Defines the procedures to atomically perform multiple scans and mutations * on a HRegion. * * This is invoked by {@link Region#processRowsWithLocks(RowProcessor)}. http://git-wip-us.apache.org/repos/asf/hbase/blob/410368b8/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/SecureBulkLoadManager.java ---------------------------------------------------------------------- diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/SecureBulkLoadManager.java b/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/SecureBulkLoadManager.java index 66773d0..d2b8567 100644 --- a/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/SecureBulkLoadManager.java +++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/SecureBulkLoadManager.java @@ -29,6 +29,7 @@ import org.apache.hadoop.fs.permission.FsPermission; import org.apache.hadoop.hbase.DoNotRetryIOException; import org.apache.hadoop.hbase.HConstants; import org.apache.hadoop.hbase.TableName; +import org.apache.hadoop.hbase.shaded.protobuf.ProtobufUtil; import org.apache.yetus.audience.InterfaceAudience; import org.apache.hadoop.hbase.client.Connection; import org.apache.hadoop.hbase.coprocessor.BulkLoadObserver; @@ -145,7 +146,7 @@ public class SecureBulkLoadManager { .findCoprocessorEnvironment(BulkLoadObserver.class).get(0)); for (BulkLoadObserver bulkLoadObserver : bulkLoadObservers) { - bulkLoadObserver.prePrepareBulkLoad(ctx, request); + bulkLoadObserver.prePrepareBulkLoad(ctx); } } @@ -166,7 +167,7 @@ public class SecureBulkLoadManager { .findCoprocessorEnvironment(BulkLoadObserver.class).get(0)); for (BulkLoadObserver bulkLoadObserver : bulkLoadObservers) { - bulkLoadObserver.preCleanupBulkLoad(ctx, request); + bulkLoadObserver.preCleanupBulkLoad(ctx); } } http://git-wip-us.apache.org/repos/asf/hbase/blob/410368b8/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 e58b35e..5302baf 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 @@ -2155,12 +2155,11 @@ public class AccessController implements MasterObserver, RegionObserver, RegionS * Authorization check for * SecureBulkLoadProtocol.prepareBulkLoad() * @param ctx the context - * @param request the request * @throws IOException */ @Override - public void prePrepareBulkLoad(ObserverContext<RegionCoprocessorEnvironment> ctx, - PrepareBulkLoadRequest request) throws IOException { + public void prePrepareBulkLoad(ObserverContext<RegionCoprocessorEnvironment> ctx) + throws IOException { requireAccess(getActiveUser(ctx), "prePrepareBulkLoad", ctx.getEnvironment().getRegion().getTableDescriptor().getTableName(), Action.CREATE); } @@ -2169,12 +2168,11 @@ public class AccessController implements MasterObserver, RegionObserver, RegionS * Authorization security check for * SecureBulkLoadProtocol.cleanupBulkLoad() * @param ctx the context - * @param request the request * @throws IOException */ @Override - public void preCleanupBulkLoad(ObserverContext<RegionCoprocessorEnvironment> ctx, - CleanupBulkLoadRequest request) throws IOException { + public void preCleanupBulkLoad(ObserverContext<RegionCoprocessorEnvironment> ctx) + throws IOException { requireAccess(getActiveUser(ctx), "preCleanupBulkLoad", ctx.getEnvironment().getRegion().getTableDescriptor().getTableName(), Action.CREATE); } http://git-wip-us.apache.org/repos/asf/hbase/blob/410368b8/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 70e4e92..4fb26d6 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 @@ -2878,16 +2878,14 @@ public class TestAccessController extends SecureTestUtil { AccessTestAction prepareBulkLoadAction = new AccessTestAction() { @Override public Object run() throws Exception { - ACCESS_CONTROLLER.prePrepareBulkLoad(ObserverContext.createAndPrepare(RCP_ENV, null), - null); + ACCESS_CONTROLLER.prePrepareBulkLoad(ObserverContext.createAndPrepare(RCP_ENV, null)); return null; } }; AccessTestAction cleanupBulkLoadAction = new AccessTestAction() { @Override public Object run() throws Exception { - ACCESS_CONTROLLER.preCleanupBulkLoad(ObserverContext.createAndPrepare(RCP_ENV, null), - null); + ACCESS_CONTROLLER.preCleanupBulkLoad(ObserverContext.createAndPrepare(RCP_ENV, null)); return null; } };