From b6863d867d2081a26da4b9aa0214243a76ae9d03 Mon Sep 17 00:00:00 2001 From: anoopsamjohn Date: Tue, 26 Sep 2017 09:30:59 +0530 Subject: [PATCH] HBASE-16769 Deprecate/remove PB references from MasterObserver and RegionServerObserver --- .../backup/TestBackupDeleteWithFailures.java | 2 +- .../hbase/rsgroup/RSGroupAdminEndpoint.java | 2 +- .../hbase/coprocessor/MasterObserver.java | 2 +- .../coprocessor/RegionServerObserver.java | 25 +++++------ .../hbase/master/MasterCoprocessorHost.java | 2 +- .../master/snapshot/SnapshotManager.java | 43 ++++++++++++------- .../hbase/regionserver/RSRpcServices.java | 4 +- .../RegionServerCoprocessorHost.java | 10 ++--- .../security/access/AccessController.java | 12 ++---- .../snapshot/SnapshotDescriptionUtils.java | 6 +-- .../hbase/coprocessor/TestMasterObserver.java | 2 +- .../security/access/TestAccessController.java | 22 ++++------ .../access/TestWithDisabledAuthorization.java | 22 +++------- .../snapshot/TestSnapshotClientRetries.java | 2 +- 14 files changed, 73 insertions(+), 83 deletions(-) diff --git a/hbase-backup/src/test/java/org/apache/hadoop/hbase/backup/TestBackupDeleteWithFailures.java b/hbase-backup/src/test/java/org/apache/hadoop/hbase/backup/TestBackupDeleteWithFailures.java index 966f5198eb6..843ed38559c 100644 --- a/hbase-backup/src/test/java/org/apache/hadoop/hbase/backup/TestBackupDeleteWithFailures.java +++ b/hbase-backup/src/test/java/org/apache/hadoop/hbase/backup/TestBackupDeleteWithFailures.java @@ -34,12 +34,12 @@ import org.apache.hadoop.hbase.TableName; import org.apache.hadoop.hbase.backup.impl.BackupSystemTable; import org.apache.hadoop.hbase.client.Admin; import org.apache.hadoop.hbase.client.Connection; +import org.apache.hadoop.hbase.client.SnapshotDescription; import org.apache.hadoop.hbase.client.TableDescriptor; import org.apache.hadoop.hbase.coprocessor.CoprocessorHost; import org.apache.hadoop.hbase.coprocessor.MasterCoprocessorEnvironment; import org.apache.hadoop.hbase.coprocessor.MasterObserver; import org.apache.hadoop.hbase.coprocessor.ObserverContext; -import org.apache.hadoop.hbase.shaded.protobuf.generated.SnapshotProtos.SnapshotDescription; import org.apache.hadoop.hbase.testclassification.LargeTests; import org.apache.hadoop.util.ToolRunner; import org.junit.Before; diff --git a/hbase-rsgroup/src/main/java/org/apache/hadoop/hbase/rsgroup/RSGroupAdminEndpoint.java b/hbase-rsgroup/src/main/java/org/apache/hadoop/hbase/rsgroup/RSGroupAdminEndpoint.java index d861c2b84f7..da179e3a158 100644 --- a/hbase-rsgroup/src/main/java/org/apache/hadoop/hbase/rsgroup/RSGroupAdminEndpoint.java +++ b/hbase-rsgroup/src/main/java/org/apache/hadoop/hbase/rsgroup/RSGroupAdminEndpoint.java @@ -32,6 +32,7 @@ import org.apache.hadoop.hbase.HConstants; import org.apache.hadoop.hbase.NamespaceDescriptor; import org.apache.hadoop.hbase.TableName; import org.apache.hadoop.hbase.client.RegionInfo; +import org.apache.hadoop.hbase.client.SnapshotDescription; import org.apache.hadoop.hbase.client.TableDescriptor; import org.apache.hadoop.hbase.constraint.ConstraintException; import org.apache.hadoop.hbase.coprocessor.CoprocessorService; @@ -67,7 +68,6 @@ import org.apache.hadoop.hbase.protobuf.generated.RSGroupAdminProtos.RemoveRSGro import org.apache.hadoop.hbase.protobuf.generated.RSGroupAdminProtos.RemoveRSGroupResponse; import org.apache.hadoop.hbase.protobuf.generated.TableProtos; import org.apache.hadoop.hbase.shaded.com.google.common.collect.Sets; -import org.apache.hadoop.hbase.shaded.protobuf.generated.SnapshotProtos.SnapshotDescription; import org.apache.yetus.audience.InterfaceAudience; @InterfaceAudience.Private 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 16ea635a4af..87b9679471a 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.client.ColumnFamilyDescriptor; import org.apache.hadoop.hbase.client.MasterSwitchType; import org.apache.hadoop.hbase.client.Mutation; import org.apache.hadoop.hbase.client.RegionInfo; +import org.apache.hadoop.hbase.client.SnapshotDescription; import org.apache.hadoop.hbase.client.TableDescriptor; import org.apache.hadoop.hbase.master.RegionPlan; import org.apache.hadoop.hbase.master.locking.LockProcedure; @@ -44,7 +45,6 @@ import org.apache.hadoop.hbase.procedure2.Procedure; import org.apache.hadoop.hbase.procedure2.ProcedureExecutor; import org.apache.hadoop.hbase.quotas.GlobalQuotaSettings; import org.apache.hadoop.hbase.replication.ReplicationPeerConfig; -import org.apache.hadoop.hbase.shaded.protobuf.generated.SnapshotProtos.SnapshotDescription; import org.apache.yetus.audience.InterfaceAudience; import org.apache.yetus.audience.InterfaceStability; diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/coprocessor/RegionServerObserver.java b/hbase-server/src/main/java/org/apache/hadoop/hbase/coprocessor/RegionServerObserver.java index 4e31d1949e4..5d68eec54b7 100644 --- a/hbase-server/src/main/java/org/apache/hadoop/hbase/coprocessor/RegionServerObserver.java +++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/coprocessor/RegionServerObserver.java @@ -19,15 +19,12 @@ package org.apache.hadoop.hbase.coprocessor; import java.io.IOException; -import java.util.List; -import org.apache.hadoop.hbase.CellScanner; import org.apache.hadoop.hbase.Coprocessor; import org.apache.hadoop.hbase.HBaseInterfaceAudience; +import org.apache.hadoop.hbase.replication.ReplicationEndpoint; import org.apache.yetus.audience.InterfaceAudience; import org.apache.yetus.audience.InterfaceStability; -import org.apache.hadoop.hbase.shaded.protobuf.generated.AdminProtos.WALEntry; -import org.apache.hadoop.hbase.replication.ReplicationEndpoint; /** * Defines coprocessor hooks for interacting with operations on the @@ -91,24 +88,28 @@ public interface RegionServerObserver extends Coprocessor { return endpoint; } + // TODO remove below 2 hooks when we implement AC as a core impl than a CP impl. /** * This will be called before executing replication request to shipping log entries. * @param ctx the environment to interact with the framework and region server. - * @param entries list of WALEntries to replicate - * @param cells Cells that the WALEntries refer to (if cells is non-null) + * @deprecated As of release 2.0.0 with out any replacement. This is maintained for internal + * usage by AccessController. Do not use these hooks in custom co-processors. */ - default void preReplicateLogEntries(final ObserverContext ctx, - List entries, CellScanner cells) throws IOException {} + @Deprecated + default void preReplicateLogEntries(final ObserverContext ctx) + throws IOException { + } /** * This will be called after executing replication request to shipping log entries. * @param ctx the environment to interact with the framework and region server. - * @param entries list of WALEntries to replicate - * @param cells Cells that the WALEntries refer to (if cells is non-null) + * @deprecated As of release 2.0.0 with out any replacement. This is maintained for internal + * usage by AccessController. Do not use these hooks in custom co-processors. */ + @Deprecated default void postReplicateLogEntries( - final ObserverContext ctx, - List entries, CellScanner cells) throws IOException {} + final ObserverContext ctx) throws IOException { + } /** * This will be called before clearing compaction queues 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 8a65f0c8f1c..30d801585d5 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 @@ -36,6 +36,7 @@ import org.apache.hadoop.hbase.client.ColumnFamilyDescriptor; import org.apache.hadoop.hbase.client.MasterSwitchType; import org.apache.hadoop.hbase.client.Mutation; import org.apache.hadoop.hbase.client.RegionInfo; +import org.apache.hadoop.hbase.client.SnapshotDescription; import org.apache.hadoop.hbase.client.TableDescriptor; import org.apache.hadoop.hbase.coprocessor.CoprocessorHost; import org.apache.hadoop.hbase.coprocessor.CoprocessorService; @@ -55,7 +56,6 @@ import org.apache.hadoop.hbase.procedure2.ProcedureExecutor; import org.apache.hadoop.hbase.quotas.GlobalQuotaSettings; import org.apache.hadoop.hbase.replication.ReplicationPeerConfig; import org.apache.hadoop.hbase.security.User; -import org.apache.hadoop.hbase.shaded.protobuf.generated.SnapshotProtos.SnapshotDescription; import org.apache.yetus.audience.InterfaceAudience; /** diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/master/snapshot/SnapshotManager.java b/hbase-server/src/main/java/org/apache/hadoop/hbase/master/snapshot/SnapshotManager.java index 229e7da5097..7bd069ba64a 100644 --- a/hbase-server/src/main/java/org/apache/hadoop/hbase/master/snapshot/SnapshotManager.java +++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/master/snapshot/SnapshotManager.java @@ -199,16 +199,18 @@ public class SnapshotManager extends MasterProcedureManager implements Stoppable * @throws IOException File system exception */ public List getCompletedSnapshots() throws IOException { - return getCompletedSnapshots(SnapshotDescriptionUtils.getSnapshotsDir(rootDir)); + return getCompletedSnapshots(SnapshotDescriptionUtils.getSnapshotsDir(rootDir), true); } /** * Gets the list of all completed snapshots. * @param snapshotDir snapshot directory + * @param withCpCall Whether to call CP hooks * @return list of SnapshotDescriptions * @throws IOException File system exception */ - private List getCompletedSnapshots(Path snapshotDir) throws IOException { + private List getCompletedSnapshots(Path snapshotDir, boolean withCpCall) + throws IOException { List snapshotDescs = new ArrayList<>(); // first create the snapshot root path and check to see if it exists FileSystem fs = master.getMasterFileSystem().getFileSystem(); @@ -223,6 +225,7 @@ public class SnapshotManager extends MasterProcedureManager implements Stoppable FileStatus[] snapshots = fs.listStatus(snapshotDir, new SnapshotDescriptionUtils.CompletedSnaphotDirectoriesFilter(fs)); MasterCoprocessorHost cpHost = master.getMasterCoprocessorHost(); + withCpCall = withCpCall && cpHost != null; // loop through all the completed snapshots for (FileStatus snapshot : snapshots) { Path info = new Path(snapshot.getPath(), SnapshotDescriptionUtils.SNAPSHOTINFO_FILE); @@ -235,9 +238,11 @@ public class SnapshotManager extends MasterProcedureManager implements Stoppable try { in = fs.open(info); SnapshotDescription desc = SnapshotDescription.parseFrom(in); - if (cpHost != null) { + org.apache.hadoop.hbase.client.SnapshotDescription descPOJO = (withCpCall) + ? ProtobufUtil.createSnapshotDesc(desc) : null; + if (withCpCall) { try { - cpHost.preListSnapshot(desc); + cpHost.preListSnapshot(descPOJO); } catch (AccessDeniedException e) { LOG.warn("Current user does not have access to " + desc.getName() + " snapshot. " + "Either you should be owner of this snapshot or admin user."); @@ -248,8 +253,8 @@ public class SnapshotManager extends MasterProcedureManager implements Stoppable snapshotDescs.add(desc); // call coproc post hook - if (cpHost != null) { - cpHost.postListSnapshot(desc); + if (withCpCall) { + cpHost.postListSnapshot(descPOJO); } } catch (IOException e) { LOG.warn("Found a corrupted snapshot " + snapshot.getPath(), e); @@ -300,8 +305,10 @@ public class SnapshotManager extends MasterProcedureManager implements Stoppable // call coproc pre hook MasterCoprocessorHost cpHost = master.getMasterCoprocessorHost(); + org.apache.hadoop.hbase.client.SnapshotDescription snapshotPOJO = null; if (cpHost != null) { - cpHost.preDeleteSnapshot(snapshot); + snapshotPOJO = ProtobufUtil.createSnapshotDesc(snapshot); + cpHost.preDeleteSnapshot(snapshotPOJO); } LOG.debug("Deleting snapshot: " + snapshotName); @@ -312,7 +319,7 @@ public class SnapshotManager extends MasterProcedureManager implements Stoppable // call coproc post hook if (cpHost != null) { - cpHost.postDeleteSnapshot(snapshot); + cpHost.postDeleteSnapshot(snapshotPOJO); } } @@ -587,8 +594,10 @@ public class SnapshotManager extends MasterProcedureManager implements Stoppable // call pre coproc hook MasterCoprocessorHost cpHost = master.getMasterCoprocessorHost(); + org.apache.hadoop.hbase.client.SnapshotDescription snapshotPOJO = null; if (cpHost != null) { - cpHost.preSnapshot(snapshot, desc); + snapshotPOJO = ProtobufUtil.createSnapshotDesc(snapshot); + cpHost.preSnapshot(snapshotPOJO, desc); } // if the table is enabled, then have the RS run actually the snapshot work @@ -616,7 +625,7 @@ public class SnapshotManager extends MasterProcedureManager implements Stoppable // call post coproc hook if (cpHost != null) { - cpHost.postSnapshot(snapshot, desc); + cpHost.postSnapshot(snapshotPOJO, desc); } } @@ -684,8 +693,10 @@ public class SnapshotManager extends MasterProcedureManager implements Stoppable final NonceKey nonceKey, final boolean restoreAcl) throws IOException { MasterCoprocessorHost cpHost = master.getMasterCoprocessorHost(); TableDescriptor htd = TableDescriptorBuilder.copy(tableName, snapshotTableDesc); + org.apache.hadoop.hbase.client.SnapshotDescription snapshotPOJO = null; if (cpHost != null) { - cpHost.preCloneSnapshot(reqSnapshot, htd); + snapshotPOJO = ProtobufUtil.createSnapshotDesc(reqSnapshot); + cpHost.preCloneSnapshot(snapshotPOJO, htd); } long procId; try { @@ -698,7 +709,7 @@ public class SnapshotManager extends MasterProcedureManager implements Stoppable LOG.info("Clone snapshot=" + snapshot.getName() + " as table=" + tableName); if (cpHost != null) { - cpHost.postCloneSnapshot(reqSnapshot, htd); + cpHost.postCloneSnapshot(snapshotPOJO, htd); } return procId; } @@ -812,8 +823,10 @@ public class SnapshotManager extends MasterProcedureManager implements Stoppable } // call Coprocessor pre hook + org.apache.hadoop.hbase.client.SnapshotDescription snapshotPOJO = null; if (cpHost != null) { - cpHost.preRestoreSnapshot(reqSnapshot, snapshotTableDesc); + snapshotPOJO = ProtobufUtil.createSnapshotDesc(reqSnapshot); + cpHost.preRestoreSnapshot(snapshotPOJO, snapshotTableDesc); } long procId; @@ -827,7 +840,7 @@ public class SnapshotManager extends MasterProcedureManager implements Stoppable LOG.info("Restore snapshot=" + snapshot.getName() + " as table=" + tableName); if (cpHost != null) { - cpHost.postRestoreSnapshot(reqSnapshot, snapshotTableDesc); + cpHost.postRestoreSnapshot(snapshotPOJO, snapshotTableDesc); } return procId; @@ -1045,7 +1058,7 @@ public class SnapshotManager extends MasterProcedureManager implements Stoppable // check if an older version of snapshot directory was present Path oldSnapshotDir = new Path(mfs.getRootDir(), HConstants.OLD_SNAPSHOT_DIR_NAME); FileSystem fs = mfs.getFileSystem(); - List ss = getCompletedSnapshots(new Path(rootDir, oldSnapshotDir)); + List ss = getCompletedSnapshots(new Path(rootDir, oldSnapshotDir), false); if (ss != null && !ss.isEmpty()) { LOG.error("Snapshots from an earlier release were found under: " + oldSnapshotDir); LOG.error("Please rename the directory as " + HConstants.SNAPSHOT_DIR_NAME); diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/RSRpcServices.java b/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/RSRpcServices.java index 24281c7bed9..ebcdbb47f2d 100644 --- a/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/RSRpcServices.java +++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/RSRpcServices.java @@ -2177,11 +2177,11 @@ public class RSRpcServices implements HBaseRPCErrorHandler, requestCount.increment(); List entries = request.getEntryList(); CellScanner cellScanner = ((HBaseRpcController)controller).cellScanner(); - regionServer.getRegionServerCoprocessorHost().preReplicateLogEntries(entries, cellScanner); + regionServer.getRegionServerCoprocessorHost().preReplicateLogEntries(); regionServer.replicationSinkHandler.replicateLogEntries(entries, cellScanner, request.getReplicationClusterId(), request.getSourceBaseNamespaceDirPath(), request.getSourceHFileArchiveDirPath()); - regionServer.getRegionServerCoprocessorHost().postReplicateLogEntries(entries, cellScanner); + regionServer.getRegionServerCoprocessorHost().postReplicateLogEntries(); return ReplicateWALEntryResponse.newBuilder().build(); } else { throw new ServiceException("Replication services are not initialized yet"); diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/RegionServerCoprocessorHost.java b/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/RegionServerCoprocessorHost.java index 563e4a71612..2c80d54f581 100644 --- a/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/RegionServerCoprocessorHost.java +++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/RegionServerCoprocessorHost.java @@ -26,7 +26,6 @@ import org.apache.commons.lang3.ClassUtils; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.apache.hadoop.conf.Configuration; -import org.apache.hadoop.hbase.CellScanner; import org.apache.hadoop.hbase.Coprocessor; import org.apache.hadoop.hbase.CoprocessorEnvironment; import org.apache.hadoop.hbase.HBaseInterfaceAudience; @@ -42,7 +41,6 @@ import org.apache.hadoop.hbase.ipc.RpcServer; import org.apache.hadoop.hbase.metrics.MetricRegistry; import org.apache.hadoop.hbase.replication.ReplicationEndpoint; import org.apache.hadoop.hbase.security.User; -import org.apache.hadoop.hbase.shaded.protobuf.generated.AdminProtos.WALEntry; @InterfaceAudience.LimitedPrivate(HBaseInterfaceAudience.COPROC) @InterfaceStability.Evolving @@ -115,24 +113,24 @@ public class RegionServerCoprocessorHost extends }); } - public void preReplicateLogEntries(final List entries, final CellScanner cells) + public void preReplicateLogEntries() throws IOException { execOperation(coprocessors.isEmpty() ? null : new CoprocessorOperation() { @Override public void call(RegionServerObserver oserver, ObserverContext ctx) throws IOException { - oserver.preReplicateLogEntries(ctx, entries, cells); + oserver.preReplicateLogEntries(ctx); } }); } - public void postReplicateLogEntries(final List entries, final CellScanner cells) + public void postReplicateLogEntries() throws IOException { execOperation(coprocessors.isEmpty() ? null : new CoprocessorOperation() { @Override public void call(RegionServerObserver oserver, ObserverContext ctx) throws IOException { - oserver.postReplicateLogEntries(ctx, entries, cells); + oserver.postReplicateLogEntries(ctx); } }); } 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 ea5eb1c83ff..e58b35ec05f 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 @@ -69,6 +69,7 @@ import org.apache.hadoop.hbase.client.Query; import org.apache.hadoop.hbase.client.RegionInfo; import org.apache.hadoop.hbase.client.Result; import org.apache.hadoop.hbase.client.Scan; +import org.apache.hadoop.hbase.client.SnapshotDescription; import org.apache.hadoop.hbase.client.Table; import org.apache.hadoop.hbase.client.TableDescriptor; import org.apache.hadoop.hbase.coprocessor.BulkLoadObserver; @@ -121,10 +122,8 @@ import org.apache.hadoop.hbase.shaded.com.google.common.collect.Lists; import org.apache.hadoop.hbase.shaded.com.google.common.collect.MapMaker; import org.apache.hadoop.hbase.shaded.com.google.common.collect.Maps; import org.apache.hadoop.hbase.shaded.com.google.common.collect.Sets; -import org.apache.hadoop.hbase.shaded.protobuf.generated.AdminProtos.WALEntry; import org.apache.hadoop.hbase.shaded.protobuf.generated.ClientProtos.CleanupBulkLoadRequest; import org.apache.hadoop.hbase.shaded.protobuf.generated.ClientProtos.PrepareBulkLoadRequest; -import org.apache.hadoop.hbase.shaded.protobuf.generated.SnapshotProtos.SnapshotDescription; import org.apache.hadoop.hbase.snapshot.SnapshotDescriptionUtils; import org.apache.hadoop.hbase.util.ByteRange; import org.apache.hadoop.hbase.util.Bytes; @@ -2622,16 +2621,11 @@ public class AccessController implements MasterObserver, RegionObserver, RegionS } @Override - public void preReplicateLogEntries(ObserverContext ctx, - List entries, CellScanner cells) throws IOException { + public void preReplicateLogEntries(ObserverContext ctx) + throws IOException { requirePermission(getActiveUser(ctx), "replicateLogEntries", Action.WRITE); } - @Override - public void postReplicateLogEntries(ObserverContext ctx, - List entries, CellScanner cells) throws IOException { - } - @Override public void preClearCompactionQueues(ObserverContext ctx) throws IOException { diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/snapshot/SnapshotDescriptionUtils.java b/hbase-server/src/main/java/org/apache/hadoop/hbase/snapshot/SnapshotDescriptionUtils.java index c0ca409d532..61a4a85ed07 100644 --- a/hbase-server/src/main/java/org/apache/hadoop/hbase/snapshot/SnapshotDescriptionUtils.java +++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/snapshot/SnapshotDescriptionUtils.java @@ -373,10 +373,10 @@ public final class SnapshotDescriptionUtils { * @return true if the user is the owner of the snapshot, * false otherwise or the snapshot owner field is not present. */ - public static boolean isSnapshotOwner(final SnapshotDescription snapshot, final User user) { + public static boolean isSnapshotOwner(org.apache.hadoop.hbase.client.SnapshotDescription snapshot, + User user) { if (user == null) return false; - if (!snapshot.hasOwner()) return false; - return snapshot.getOwner().equals(user.getShortName()); + return user.getShortName().equals(snapshot.getOwner()); } public static boolean isSecurityAvailable(Configuration conf) throws IOException { 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 b4c85f1e112..1e36b0bbbca 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 @@ -47,6 +47,7 @@ import org.apache.hadoop.hbase.client.MasterSwitchType; import org.apache.hadoop.hbase.client.Mutation; import org.apache.hadoop.hbase.client.RegionInfo; import org.apache.hadoop.hbase.client.RegionLocator; +import org.apache.hadoop.hbase.client.SnapshotDescription; import org.apache.hadoop.hbase.client.Table; import org.apache.hadoop.hbase.client.TableDescriptor; import org.apache.hadoop.hbase.master.HMaster; @@ -66,7 +67,6 @@ import org.apache.hadoop.hbase.shaded.protobuf.ProtobufUtil; import org.apache.hadoop.hbase.shaded.protobuf.RequestConverter; import org.apache.hadoop.hbase.shaded.protobuf.generated.MasterProtos.GetTableDescriptorsRequest; import org.apache.hadoop.hbase.shaded.protobuf.generated.MasterProtos.GetTableNamesRequest; -import org.apache.hadoop.hbase.shaded.protobuf.generated.SnapshotProtos.SnapshotDescription; import org.apache.hadoop.hbase.testclassification.CoprocessorTests; import org.apache.hadoop.hbase.testclassification.MediumTests; import org.apache.hadoop.hbase.util.Bytes; 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 2c27e4d0030..70e4e92d516 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 @@ -72,6 +72,7 @@ import org.apache.hadoop.hbase.client.RegionLocator; import org.apache.hadoop.hbase.client.Result; import org.apache.hadoop.hbase.client.ResultScanner; import org.apache.hadoop.hbase.client.Scan; +import org.apache.hadoop.hbase.client.SnapshotDescription; import org.apache.hadoop.hbase.client.Table; import org.apache.hadoop.hbase.client.security.SecurityCapability; import org.apache.hadoop.hbase.coprocessor.CoprocessorHost; @@ -136,7 +137,6 @@ import org.junit.rules.TestName; import org.apache.hadoop.hbase.shaded.ipc.protobuf.generated.TestProcedureProtos; import org.apache.hadoop.hbase.shaded.protobuf.generated.ProcedureProtos.ProcedureState; -import org.apache.hadoop.hbase.shaded.protobuf.generated.SnapshotProtos.SnapshotDescription; /** * Performs authorization checks for common operations, according to different @@ -2001,10 +2001,8 @@ public class TestAccessController extends SecureTestUtil { public void testSnapshot() throws Exception { Admin admin = TEST_UTIL.getAdmin(); final HTableDescriptor htd = admin.getTableDescriptor(TEST_TABLE); - SnapshotDescription.Builder builder = SnapshotDescription.newBuilder(); - builder.setName(TEST_TABLE.getNameAsString() + "-snapshot"); - builder.setTable(TEST_TABLE.getNameAsString()); - final SnapshotDescription snapshot = builder.build(); + final SnapshotDescription snapshot = new SnapshotDescription( + TEST_TABLE.getNameAsString() + "-snapshot", TEST_TABLE); AccessTestAction snapshotAction = new AccessTestAction() { @Override public Object run() throws Exception { @@ -2062,11 +2060,9 @@ public class TestAccessController extends SecureTestUtil { public void testSnapshotWithOwner() throws Exception { Admin admin = TEST_UTIL.getAdmin(); final HTableDescriptor htd = admin.getTableDescriptor(TEST_TABLE); - SnapshotDescription.Builder builder = SnapshotDescription.newBuilder(); - builder.setName(TEST_TABLE.getNameAsString() + "-snapshot"); - builder.setTable(TEST_TABLE.getNameAsString()); - builder.setOwner(USER_OWNER.getName()); - final SnapshotDescription snapshot = builder.build(); + final SnapshotDescription snapshot = new SnapshotDescription( + TEST_TABLE.getNameAsString() + "-snapshot", TEST_TABLE, null, USER_OWNER.getName()); + AccessTestAction snapshotAction = new AccessTestAction() { @Override public Object run() throws Exception { @@ -2904,10 +2900,8 @@ public class TestAccessController extends SecureTestUtil { AccessTestAction replicateLogEntriesAction = new AccessTestAction() { @Override public Object run() throws Exception { - ACCESS_CONTROLLER.preReplicateLogEntries(ObserverContext.createAndPrepare(RSCP_ENV, null), - null, null); - ACCESS_CONTROLLER.postReplicateLogEntries(ObserverContext.createAndPrepare(RSCP_ENV, null), - null, null); + ACCESS_CONTROLLER.preReplicateLogEntries(ObserverContext.createAndPrepare(RSCP_ENV, null)); + ACCESS_CONTROLLER.postReplicateLogEntries(ObserverContext.createAndPrepare(RSCP_ENV, null)); return null; } }; diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/security/access/TestWithDisabledAuthorization.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/security/access/TestWithDisabledAuthorization.java index 0c072b8ebe5..7e61d241c83 100644 --- a/hbase-server/src/test/java/org/apache/hadoop/hbase/security/access/TestWithDisabledAuthorization.java +++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/security/access/TestWithDisabledAuthorization.java @@ -49,6 +49,7 @@ import org.apache.hadoop.hbase.client.Put; import org.apache.hadoop.hbase.client.Result; import org.apache.hadoop.hbase.client.ResultScanner; import org.apache.hadoop.hbase.client.Scan; +import org.apache.hadoop.hbase.client.SnapshotDescription; import org.apache.hadoop.hbase.client.Table; import org.apache.hadoop.hbase.client.TableDescriptor; import org.apache.hadoop.hbase.coprocessor.MasterCoprocessorEnvironment; @@ -65,7 +66,6 @@ import org.apache.hadoop.hbase.regionserver.RegionServerCoprocessorHost; import org.apache.hadoop.hbase.wal.WALEdit; import org.apache.hadoop.hbase.security.User; import org.apache.hadoop.hbase.security.access.Permission.Action; -import org.apache.hadoop.hbase.shaded.protobuf.generated.SnapshotProtos.SnapshotDescription; import org.apache.hadoop.hbase.testclassification.LargeTests; import org.apache.hadoop.hbase.testclassification.SecurityTests; import org.apache.hadoop.hbase.util.Bytes; @@ -633,9 +633,7 @@ public class TestWithDisabledAuthorization extends SecureTestUtil { verifyAllowed(new AccessTestAction() { @Override public Object run() throws Exception { - SnapshotDescription snapshot = SnapshotDescription.newBuilder() - .setName("foo") - .build(); + SnapshotDescription snapshot = new SnapshotDescription("foo"); HTableDescriptor htd = new HTableDescriptor(TEST_TABLE.getTableName()); ACCESS_CONTROLLER.preSnapshot(ObserverContext.createAndPrepare(CP_ENV, null), snapshot, htd); @@ -647,9 +645,7 @@ public class TestWithDisabledAuthorization extends SecureTestUtil { verifyAllowed(new AccessTestAction() { @Override public Object run() throws Exception { - SnapshotDescription snapshot = SnapshotDescription.newBuilder() - .setName("foo") - .build(); + SnapshotDescription snapshot = new SnapshotDescription("foo"); ACCESS_CONTROLLER.preListSnapshot(ObserverContext.createAndPrepare(CP_ENV, null), snapshot); return null; @@ -660,9 +656,7 @@ public class TestWithDisabledAuthorization extends SecureTestUtil { verifyAllowed(new AccessTestAction() { @Override public Object run() throws Exception { - SnapshotDescription snapshot = SnapshotDescription.newBuilder() - .setName("foo") - .build(); + SnapshotDescription snapshot = new SnapshotDescription("foo"); HTableDescriptor htd = new HTableDescriptor(TEST_TABLE.getTableName()); ACCESS_CONTROLLER.preCloneSnapshot(ObserverContext.createAndPrepare(CP_ENV, null), snapshot, htd); @@ -674,9 +668,7 @@ public class TestWithDisabledAuthorization extends SecureTestUtil { verifyAllowed(new AccessTestAction() { @Override public Object run() throws Exception { - SnapshotDescription snapshot = SnapshotDescription.newBuilder() - .setName("foo") - .build(); + SnapshotDescription snapshot = new SnapshotDescription("foo"); HTableDescriptor htd = new HTableDescriptor(TEST_TABLE.getTableName()); ACCESS_CONTROLLER.preRestoreSnapshot(ObserverContext.createAndPrepare(CP_ENV, null), snapshot, htd); @@ -688,9 +680,7 @@ public class TestWithDisabledAuthorization extends SecureTestUtil { verifyAllowed(new AccessTestAction() { @Override public Object run() throws Exception { - SnapshotDescription snapshot = SnapshotDescription.newBuilder() - .setName("foo") - .build(); + SnapshotDescription snapshot = new SnapshotDescription("foo"); ACCESS_CONTROLLER.preDeleteSnapshot(ObserverContext.createAndPrepare(CP_ENV, null), snapshot); return null; diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/snapshot/TestSnapshotClientRetries.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/snapshot/TestSnapshotClientRetries.java index 949915cab75..bb282284b35 100644 --- a/hbase-server/src/test/java/org/apache/hadoop/hbase/snapshot/TestSnapshotClientRetries.java +++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/snapshot/TestSnapshotClientRetries.java @@ -27,12 +27,12 @@ import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.apache.hadoop.hbase.HBaseTestingUtility; import org.apache.hadoop.hbase.TableName; +import org.apache.hadoop.hbase.client.SnapshotDescription; import org.apache.hadoop.hbase.client.TableDescriptor; import org.apache.hadoop.hbase.coprocessor.MasterObserver; import org.apache.hadoop.hbase.coprocessor.CoprocessorHost; import org.apache.hadoop.hbase.coprocessor.MasterCoprocessorEnvironment; import org.apache.hadoop.hbase.coprocessor.ObserverContext; -import org.apache.hadoop.hbase.shaded.protobuf.generated.SnapshotProtos.SnapshotDescription; import org.apache.hadoop.hbase.testclassification.MediumTests; import org.apache.hadoop.hbase.TestTableName; import org.junit.After;