From 0b75cb00beb6fa7df7467bcc89054d567be39ff5 Mon Sep 17 00:00:00 2001 From: Abhishek Pal <43001336+devabhishekpal@users.noreply.github.com> Date: Tue, 27 Aug 2024 15:00:41 +0530 Subject: [PATCH] HDDS-11251. Deprecate definitions and remove listTrash and recoverTrash APIs (#7060) --- .../apache/hadoop/ozone/OzoneConfigKeys.java | 4 - .../src/main/resources/ozone-default.xml | 8 - .../ozone/client/protocol/ClientProtocol.java | 34 ----- .../hadoop/ozone/client/rpc/RpcClient.java | 20 --- .../java/org/apache/hadoop/ozone/OmUtils.java | 8 + .../om/protocol/OzoneManagerProtocol.java | 34 ----- ...ManagerProtocolClientSideTranslatorPB.java | 84 ----------- .../apache/hadoop/ozone/om/TestOmMetrics.java | 19 +-- .../src/main/proto/OmClientProtocol.proto | 44 +++--- .../hadoop/ozone/om/OMMetadataManager.java | 30 ---- .../apache/hadoop/ozone/om/KeyManager.java | 19 --- .../hadoop/ozone/om/KeyManagerImpl.java | 22 --- .../org/apache/hadoop/ozone/om/OMMetrics.java | 21 --- .../ozone/om/OmMetadataManagerImpl.java | 21 --- .../apache/hadoop/ozone/om/OzoneManager.java | 34 ----- .../OzoneManagerRequestHandler.java | 28 ---- .../hadoop/ozone/om/TestTrashService.java | 137 ------------------ .../ozone/client/ClientProtocolStub.java | 16 -- 18 files changed, 38 insertions(+), 545 deletions(-) delete mode 100644 hadoop-ozone/ozone-manager/src/test/java/org/apache/hadoop/ozone/om/TestTrashService.java diff --git a/hadoop-hdds/common/src/main/java/org/apache/hadoop/ozone/OzoneConfigKeys.java b/hadoop-hdds/common/src/main/java/org/apache/hadoop/ozone/OzoneConfigKeys.java index c61502ff4a8..c2cdb4d0d84 100644 --- a/hadoop-hdds/common/src/main/java/org/apache/hadoop/ozone/OzoneConfigKeys.java +++ b/hadoop-hdds/common/src/main/java/org/apache/hadoop/ozone/OzoneConfigKeys.java @@ -535,10 +535,6 @@ public final class OzoneConfigKeys { public static final int OZONE_MANAGER_STRIPED_LOCK_SIZE_DEFAULT = 512; - public static final String OZONE_CLIENT_LIST_TRASH_KEYS_MAX = - "ozone.client.list.trash.keys.max"; - public static final int OZONE_CLIENT_LIST_TRASH_KEYS_MAX_DEFAULT = 1000; - public static final String OZONE_HTTP_BASEDIR = "ozone.http.basedir"; public static final String OZONE_HTTP_POLICY_KEY = diff --git a/hadoop-hdds/common/src/main/resources/ozone-default.xml b/hadoop-hdds/common/src/main/resources/ozone-default.xml index 20c1bed89be..e72b718e9f5 100644 --- a/hadoop-hdds/common/src/main/resources/ozone-default.xml +++ b/hadoop-hdds/common/src/main/resources/ozone-default.xml @@ -3406,14 +3406,6 @@ unhealthy will each have their own limit. - - ozone.client.list.trash.keys.max - 1000 - OZONE, CLIENT - - The maximum number of keys to return for a list trash request. - - ozone.http.basedir diff --git a/hadoop-ozone/client/src/main/java/org/apache/hadoop/ozone/client/protocol/ClientProtocol.java b/hadoop-ozone/client/src/main/java/org/apache/hadoop/ozone/client/protocol/ClientProtocol.java index 16211ebbb8e..8d9614b554a 100644 --- a/hadoop-ozone/client/src/main/java/org/apache/hadoop/ozone/client/protocol/ClientProtocol.java +++ b/hadoop-ozone/client/src/main/java/org/apache/hadoop/ozone/client/protocol/ClientProtocol.java @@ -59,7 +59,6 @@ import org.apache.hadoop.ozone.om.helpers.OmVolumeArgs; import org.apache.hadoop.ozone.om.helpers.OzoneFileStatus; import org.apache.hadoop.ozone.om.helpers.OzoneFileStatusLight; -import org.apache.hadoop.ozone.om.helpers.RepeatedOmKeyInfo; import org.apache.hadoop.ozone.om.helpers.S3SecretValue; import org.apache.hadoop.ozone.om.helpers.S3VolumeContext; import org.apache.hadoop.ozone.om.helpers.TenantStateList; @@ -514,39 +513,6 @@ List listKeys(String volumeName, String bucketName, String keyPrefix, String prevKey, int maxListResult) throws IOException; - /** - * List trash allows the user to list the keys that were marked as deleted, - * but not actually deleted by Ozone Manager. This allows a user to recover - * keys within a configurable window. - * @param volumeName - The volume name, which can also be a wild card - * using '*'. - * @param bucketName - The bucket name, which can also be a wild card - * using '*'. - * @param startKeyName - List keys from a specific key name. - * @param keyPrefix - List keys using a specific prefix. - * @param maxKeys - The number of keys to be returned. This must be below - * the cluster level set by admins. - * @return The list of keys that are deleted from the deleted table. - * @throws IOException - */ - List listTrash(String volumeName, String bucketName, - String startKeyName, String keyPrefix, - int maxKeys) - throws IOException; - - /** - * Recover trash allows the user to recover keys that were marked as deleted, - * but not actually deleted by Ozone Manager. - * @param volumeName - The volume name. - * @param bucketName - The bucket name. - * @param keyName - The key user want to recover. - * @param destinationBucket - The bucket user want to recover to. - * @return The result of recovering operation is success or not. - * @throws IOException - */ - boolean recoverTrash(String volumeName, String bucketName, String keyName, - String destinationBucket) throws IOException; - /** * Get OzoneKey. * @param volumeName Name of the Volume diff --git a/hadoop-ozone/client/src/main/java/org/apache/hadoop/ozone/client/rpc/RpcClient.java b/hadoop-ozone/client/src/main/java/org/apache/hadoop/ozone/client/rpc/RpcClient.java index bfeb9c1e6c1..f01fddf40f7 100644 --- a/hadoop-ozone/client/src/main/java/org/apache/hadoop/ozone/client/rpc/RpcClient.java +++ b/hadoop-ozone/client/src/main/java/org/apache/hadoop/ozone/client/rpc/RpcClient.java @@ -123,7 +123,6 @@ import org.apache.hadoop.ozone.om.helpers.OzoneAclUtil; import org.apache.hadoop.ozone.om.helpers.OzoneFileStatus; import org.apache.hadoop.ozone.om.helpers.OzoneFileStatusLight; -import org.apache.hadoop.ozone.om.helpers.RepeatedOmKeyInfo; import org.apache.hadoop.ozone.om.helpers.S3SecretValue; import org.apache.hadoop.ozone.om.helpers.S3VolumeContext; import org.apache.hadoop.ozone.om.helpers.ServiceInfo; @@ -1771,25 +1770,6 @@ public List listKeys(String volumeName, String bucketName, } } - @Override - public List listTrash(String volumeName, String bucketName, - String startKeyName, String keyPrefix, int maxKeys) throws IOException { - - Preconditions.checkNotNull(volumeName); - Preconditions.checkNotNull(bucketName); - - return ozoneManagerClient.listTrash(volumeName, bucketName, startKeyName, - keyPrefix, maxKeys); - } - - @Override - public boolean recoverTrash(String volumeName, String bucketName, - String keyName, String destinationBucket) throws IOException { - - return ozoneManagerClient.recoverTrash(volumeName, bucketName, keyName, - destinationBucket); - } - @Override public OzoneKeyDetails getKeyDetails( String volumeName, String bucketName, String keyName) diff --git a/hadoop-ozone/common/src/main/java/org/apache/hadoop/ozone/OmUtils.java b/hadoop-ozone/common/src/main/java/org/apache/hadoop/ozone/OmUtils.java index 11f176362a6..27015d34a35 100644 --- a/hadoop-ozone/common/src/main/java/org/apache/hadoop/ozone/OmUtils.java +++ b/hadoop-ozone/common/src/main/java/org/apache/hadoop/ozone/OmUtils.java @@ -243,6 +243,10 @@ public static boolean isReadOnly( case ListKeys: case ListKeysLight: case ListTrash: + // ListTrash is deprecated by HDDS-11251. Keeping this in here + // As protobuf currently doesn't support deprecating enum fields + // TODO: Remove once migrated to proto3 and mark fields in proto + // as deprecated case ServiceList: case ListOpenFiles: case ListMultiPartUploadParts: @@ -304,6 +308,10 @@ public static boolean isReadOnly( case AddAcl: case PurgeKeys: case RecoverTrash: + // RecoverTrash is deprecated by HDDS-11251. Keeping this in here + // As protobuf currently doesn't support deprecating enum fields + // TODO: Remove once migrated to proto3 and mark fields in proto + // as deprecated case FinalizeUpgrade: case Prepare: case CancelPrepare: diff --git a/hadoop-ozone/common/src/main/java/org/apache/hadoop/ozone/om/protocol/OzoneManagerProtocol.java b/hadoop-ozone/common/src/main/java/org/apache/hadoop/ozone/om/protocol/OzoneManagerProtocol.java index 45922c107cb..0f01761b17b 100644 --- a/hadoop-ozone/common/src/main/java/org/apache/hadoop/ozone/om/protocol/OzoneManagerProtocol.java +++ b/hadoop-ozone/common/src/main/java/org/apache/hadoop/ozone/om/protocol/OzoneManagerProtocol.java @@ -56,7 +56,6 @@ import org.apache.hadoop.ozone.om.helpers.OpenKeySession; import org.apache.hadoop.ozone.om.helpers.OzoneFileStatus; import org.apache.hadoop.ozone.om.helpers.OzoneFileStatusLight; -import org.apache.hadoop.ozone.om.helpers.RepeatedOmKeyInfo; import org.apache.hadoop.ozone.om.helpers.S3SecretValue; import org.apache.hadoop.ozone.om.helpers.S3VolumeContext; import org.apache.hadoop.ozone.om.helpers.ServiceInfo; @@ -1055,39 +1054,6 @@ DBUpdates getDBUpdates( OzoneManagerProtocolProtos.DBUpdatesRequest dbUpdatesRequest) throws IOException; - /** - * List trash allows the user to list the keys that were marked as deleted, - * but not actually deleted by Ozone Manager. This allows a user to recover - * keys within a configurable window. - * @param volumeName - The volume name, which can also be a wild card - * using '*'. - * @param bucketName - The bucket name, which can also be a wild card - * using '*'. - * @param startKeyName - List keys from a specific key name. - * @param keyPrefix - List keys using a specific prefix. - * @param maxKeys - The number of keys to be returned. This must be below - * the cluster level set by admins. - * @return The list of keys that are deleted from the deleted table. - * @throws IOException - */ - List listTrash(String volumeName, String bucketName, - String startKeyName, String keyPrefix, int maxKeys) throws IOException; - - /** - * Recover trash allows the user to recover keys that were marked as deleted, - * but not actually deleted by Ozone Manager. - * @param volumeName - The volume name. - * @param bucketName - The bucket name. - * @param keyName - The key user want to recover. - * @param destinationBucket - The bucket user want to recover to. - * @return The result of recovering operation is success or not. - * @throws IOException - */ - default boolean recoverTrash(String volumeName, String bucketName, - String keyName, String destinationBucket) throws IOException { - return false; - } - /** * * @param txnApplyWaitTimeoutSeconds Max time in SECONDS to wait for all diff --git a/hadoop-ozone/common/src/main/java/org/apache/hadoop/ozone/om/protocolPB/OzoneManagerProtocolClientSideTranslatorPB.java b/hadoop-ozone/common/src/main/java/org/apache/hadoop/ozone/om/protocolPB/OzoneManagerProtocolClientSideTranslatorPB.java index f70beed5f25..d3e39550dfb 100644 --- a/hadoop-ozone/common/src/main/java/org/apache/hadoop/ozone/om/protocolPB/OzoneManagerProtocolClientSideTranslatorPB.java +++ b/hadoop-ozone/common/src/main/java/org/apache/hadoop/ozone/om/protocolPB/OzoneManagerProtocolClientSideTranslatorPB.java @@ -72,7 +72,6 @@ import org.apache.hadoop.ozone.om.helpers.OpenKeySession; import org.apache.hadoop.ozone.om.helpers.OzoneFileStatus; import org.apache.hadoop.ozone.om.helpers.OzoneFileStatusLight; -import org.apache.hadoop.ozone.om.helpers.RepeatedOmKeyInfo; import org.apache.hadoop.ozone.om.helpers.S3SecretValue; import org.apache.hadoop.ozone.om.helpers.S3VolumeContext; import org.apache.hadoop.ozone.om.helpers.ServiceInfo; @@ -150,8 +149,6 @@ import org.apache.hadoop.ozone.protocol.proto.OzoneManagerProtocolProtos.ListStatusResponse; import org.apache.hadoop.ozone.protocol.proto.OzoneManagerProtocolProtos.ListTenantRequest; import org.apache.hadoop.ozone.protocol.proto.OzoneManagerProtocolProtos.ListTenantResponse; -import org.apache.hadoop.ozone.protocol.proto.OzoneManagerProtocolProtos.ListTrashRequest; -import org.apache.hadoop.ozone.protocol.proto.OzoneManagerProtocolProtos.ListTrashResponse; import org.apache.hadoop.ozone.protocol.proto.OzoneManagerProtocolProtos.ListVolumeRequest; import org.apache.hadoop.ozone.protocol.proto.OzoneManagerProtocolProtos.ListVolumeResponse; import org.apache.hadoop.ozone.protocol.proto.OzoneManagerProtocolProtos.LookupFileRequest; @@ -182,8 +179,6 @@ import org.apache.hadoop.ozone.protocol.proto.OzoneManagerProtocolProtos.RangerBGSyncResponse; import org.apache.hadoop.ozone.protocol.proto.OzoneManagerProtocolProtos.RecoverLeaseRequest; import org.apache.hadoop.ozone.protocol.proto.OzoneManagerProtocolProtos.RecoverLeaseResponse; -import org.apache.hadoop.ozone.protocol.proto.OzoneManagerProtocolProtos.RecoverTrashRequest; -import org.apache.hadoop.ozone.protocol.proto.OzoneManagerProtocolProtos.RecoverTrashResponse; import org.apache.hadoop.ozone.protocol.proto.OzoneManagerProtocolProtos.RefetchSecretKeyRequest; import org.apache.hadoop.ozone.protocol.proto.OzoneManagerProtocolProtos.RefetchSecretKeyResponse; import org.apache.hadoop.ozone.protocol.proto.OzoneManagerProtocolProtos.RemoveAclRequest; @@ -2442,85 +2437,6 @@ public List listStatus(OmKeyArgs args, boolean recursive, return listStatus(args, recursive, startKey, numEntries, false); } - @Override - public List listTrash(String volumeName, - String bucketName, String startKeyName, String keyPrefix, int maxKeys) - throws IOException { - - Preconditions.checkArgument(Strings.isNullOrEmpty(volumeName), - "The volume name cannot be null or " + - "empty. Please enter a valid volume name or use '*' as a wild card"); - - Preconditions.checkArgument(Strings.isNullOrEmpty(bucketName), - "The bucket name cannot be null or " + - "empty. Please enter a valid bucket name or use '*' as a wild card"); - - ListTrashRequest trashRequest = ListTrashRequest.newBuilder() - .setVolumeName(volumeName) - .setBucketName(bucketName) - .setStartKeyName(startKeyName) - .setKeyPrefix(keyPrefix) - .setMaxKeys(maxKeys) - .build(); - - OMRequest omRequest = createOMRequest(Type.ListTrash) - .setListTrashRequest(trashRequest) - .build(); - - ListTrashResponse trashResponse = - handleError(submitRequest(omRequest)).getListTrashResponse(); - - List deletedKeyList = - new ArrayList<>(trashResponse.getDeletedKeysCount()); - - List list = new ArrayList<>(); - for (OzoneManagerProtocolProtos.RepeatedKeyInfo - repeatedKeyInfo : trashResponse.getDeletedKeysList()) { - RepeatedOmKeyInfo fromProto = - RepeatedOmKeyInfo.getFromProto(repeatedKeyInfo); - list.add(fromProto); - } - deletedKeyList.addAll(list); - - return deletedKeyList; - } - - @Override - public boolean recoverTrash(String volumeName, String bucketName, - String keyName, String destinationBucket) throws IOException { - - Preconditions.checkArgument(Strings.isNullOrEmpty(volumeName), - "The volume name cannot be null or empty. " + - "Please enter a valid volume name."); - - Preconditions.checkArgument(Strings.isNullOrEmpty(bucketName), - "The bucket name cannot be null or empty. " + - "Please enter a valid bucket name."); - - Preconditions.checkArgument(Strings.isNullOrEmpty(keyName), - "The key name cannot be null or empty. " + - "Please enter a valid key name."); - - Preconditions.checkArgument(Strings.isNullOrEmpty(destinationBucket), - "The destination bucket name cannot be null or empty. " + - "Please enter a valid destination bucket name."); - - RecoverTrashRequest.Builder req = RecoverTrashRequest.newBuilder() - .setVolumeName(volumeName) - .setBucketName(bucketName) - .setKeyName(keyName) - .setDestinationBucket(destinationBucket); - - OMRequest omRequest = createOMRequest(Type.RecoverTrash) - .setRecoverTrashRequest(req) - .build(); - - RecoverTrashResponse recoverResponse = - handleError(submitRequest(omRequest)).getRecoverTrashResponse(); - - return recoverResponse.getResponse(); - } - @Override public long prepareOzoneManager( long txnApplyWaitTimeoutSeconds, long txnApplyCheckIntervalSeconds) diff --git a/hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/ozone/om/TestOmMetrics.java b/hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/ozone/om/TestOmMetrics.java index 4619af1baa2..0481ee4a867 100644 --- a/hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/ozone/om/TestOmMetrics.java +++ b/hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/ozone/om/TestOmMetrics.java @@ -338,7 +338,6 @@ public void testKeyOps() throws Exception { long initialNumKeyLookup = getLongCounter("NumKeyLookup", omMetrics); long initialNumKeyDeletes = getLongCounter("NumKeyDeletes", omMetrics); long initialNumKeyLists = getLongCounter("NumKeyLists", omMetrics); - long initialNumTrashKeyLists = getLongCounter("NumTrashKeyLists", omMetrics); long initialNumKeys = getLongCounter("NumKeys", omMetrics); long initialNumInitiateMultipartUploads = getLongCounter("NumInitiateMultipartUploads", omMetrics); @@ -346,7 +345,6 @@ public void testKeyOps() throws Exception { long initialNumKeyAllocateFails = getLongCounter("NumKeyAllocateFails", omMetrics); long initialNumKeyLookupFails = getLongCounter("NumKeyLookupFails", omMetrics); long initialNumKeyDeleteFails = getLongCounter("NumKeyDeleteFails", omMetrics); - long initialNumTrashKeyListFails = getLongCounter("NumTrashKeyListFails", omMetrics); long initialNumInitiateMultipartUploadFails = getLongCounter("NumInitiateMultipartUploadFails", omMetrics); long initialNumBlockAllocationFails = getLongCounter("NumBlockAllocationFails", omMetrics); long initialNumKeyListFails = getLongCounter("NumKeyListFails", omMetrics); @@ -356,16 +354,15 @@ public void testKeyOps() throws Exception { TestDataUtil.createVolumeAndBucket(client, volumeName, bucketName, BucketLayout.LEGACY); OmKeyArgs keyArgs = createKeyArgs(volumeName, bucketName, RatisReplicationConfig.getInstance(HddsProtos.ReplicationFactor.THREE)); - doKeyOps(keyArgs); + doKeyOps(keyArgs); // This will perform 7 different operations on the key omMetrics = getMetrics("OMMetrics"); - assertEquals(initialNumKeyOps + 8, getLongCounter("NumKeyOps", omMetrics)); + assertEquals(initialNumKeyOps + 7, getLongCounter("NumKeyOps", omMetrics)); assertEquals(initialNumKeyAllocate + 1, getLongCounter("NumKeyAllocate", omMetrics)); assertEquals(initialNumKeyLookup + 1, getLongCounter("NumKeyLookup", omMetrics)); assertEquals(initialNumKeyDeletes + 1, getLongCounter("NumKeyDeletes", omMetrics)); assertEquals(initialNumKeyLists + 1, getLongCounter("NumKeyLists", omMetrics)); - assertEquals(initialNumTrashKeyLists + 1, getLongCounter("NumTrashKeyLists", omMetrics)); assertEquals(initialNumKeys, getLongCounter("NumKeys", omMetrics)); assertEquals(initialNumInitiateMultipartUploads + 1, getLongCounter("NumInitiateMultipartUploads", omMetrics)); @@ -409,8 +406,6 @@ public void testKeyOps() throws Exception { doThrow(exception).when(mockKm).lookupKey(any(), any(), any()); doThrow(exception).when(mockKm).listKeys( any(), any(), any(), any(), anyInt()); - doThrow(exception).when(mockKm).listTrash( - any(), any(), any(), any(), anyInt()); OmMetadataReader omMetadataReader = (OmMetadataReader) ozoneManager.getOmMetadataReader().get(); HddsWhiteboxTestUtils.setInternalState( @@ -426,19 +421,17 @@ public void testKeyOps() throws Exception { doKeyOps(keyArgs); omMetrics = getMetrics("OMMetrics"); - assertEquals(initialNumKeyOps + 31, getLongCounter("NumKeyOps", omMetrics)); + assertEquals(initialNumKeyOps + 28, getLongCounter("NumKeyOps", omMetrics)); assertEquals(initialNumKeyAllocate + 6, getLongCounter("NumKeyAllocate", omMetrics)); assertEquals(initialNumKeyLookup + 3, getLongCounter("NumKeyLookup", omMetrics)); assertEquals(initialNumKeyDeletes + 4, getLongCounter("NumKeyDeletes", omMetrics)); assertEquals(initialNumKeyLists + 3, getLongCounter("NumKeyLists", omMetrics)); - assertEquals(initialNumTrashKeyLists + 3, getLongCounter("NumTrashKeyLists", omMetrics)); assertEquals(initialNumInitiateMultipartUploads + 3, getLongCounter("NumInitiateMultipartUploads", omMetrics)); assertEquals(initialNumKeyAllocateFails + 1, getLongCounter("NumKeyAllocateFails", omMetrics)); assertEquals(initialNumKeyLookupFails + 1, getLongCounter("NumKeyLookupFails", omMetrics)); assertEquals(initialNumKeyDeleteFails + 1, getLongCounter("NumKeyDeleteFails", omMetrics)); assertEquals(initialNumKeyListFails + 1, getLongCounter("NumKeyListFails", omMetrics)); - assertEquals(initialNumTrashKeyListFails + 1, getLongCounter("NumTrashKeyListFails", omMetrics)); assertEquals(initialNumInitiateMultipartUploadFails + 1, getLongCounter( "NumInitiateMultipartUploadFails", omMetrics)); assertEquals(initialNumKeys + 2, getLongCounter("NumKeys", omMetrics)); @@ -843,12 +836,6 @@ private void doKeyOps(OmKeyArgs keyArgs) { } catch (IOException ignored) { } - try { - ozoneManager.listTrash(keyArgs.getVolumeName(), - keyArgs.getBucketName(), null, null, 0); - } catch (IOException ignored) { - } - try { writeClient.deleteKey(keyArgs); } catch (IOException ignored) { diff --git a/hadoop-ozone/interface-client/src/main/proto/OmClientProtocol.proto b/hadoop-ozone/interface-client/src/main/proto/OmClientProtocol.proto index 9e0f729be40..eeddc550052 100644 --- a/hadoop-ozone/interface-client/src/main/proto/OmClientProtocol.proto +++ b/hadoop-ozone/interface-client/src/main/proto/OmClientProtocol.proto @@ -97,8 +97,9 @@ enum Type { ListMultipartUploads = 82; - ListTrash = 91; - RecoverTrash = 92; + // Not used anymore due to HDDS-11251 + ListTrash = 91; // [deprecated = true] + RecoverTrash = 92; // [deprecated = true] RevokeS3Secret = 93; @@ -233,8 +234,9 @@ message OMRequest { optional UpdateGetS3SecretRequest updateGetS3SecretRequest = 82; optional ListMultipartUploadsRequest listMultipartUploadsRequest = 83; - optional ListTrashRequest listTrashRequest = 91; - optional RecoverTrashRequest RecoverTrashRequest = 92; + // Not used anymore due to HDDS-11251 + optional ListTrashRequest listTrashRequest = 91 [deprecated = true]; + optional RecoverTrashRequest RecoverTrashRequest = 92 [deprecated = true]; optional RevokeS3SecretRequest RevokeS3SecretRequest = 93; @@ -362,8 +364,10 @@ message OMResponse { optional ListMultipartUploadsResponse listMultipartUploadsResponse = 82; - optional ListTrashResponse listTrashResponse = 91; - optional RecoverTrashResponse RecoverTrashResponse = 92; + // Not used anymore due to HDDS-11251 + optional ListTrashResponse listTrashResponse = 91 [deprecated = true]; + optional RecoverTrashResponse RecoverTrashResponse = 92 [deprecated = true]; + optional PurgePathsResponse purgePathsResponse = 93 [deprecated = true]; optional PurgeDirectoriesResponse purgeDirectoriesResponse = 108; @@ -548,33 +552,39 @@ enum Status { /** This command acts as a list command for deleted keys that are still present in the deleted table on Ozone Manager. + Not used anymore due to HDDS-11251 */ message ListTrashRequest { - required string volumeName = 1; - required string bucketName = 2; - optional string startKeyName = 3; - optional string keyPrefix = 4; - optional int32 maxKeys = 5; + // option deprecated = true; + required string volumeName = 1 [deprecated = true]; + required string bucketName = 2 [deprecated = true]; + optional string startKeyName = 3 [deprecated = true]; + optional string keyPrefix = 4 [deprecated = true]; + optional int32 maxKeys = 5 [deprecated = true]; } message ListTrashResponse { - repeated RepeatedKeyInfo deletedKeys = 1; + // option deprecated = true; + repeated RepeatedKeyInfo deletedKeys = 1 [deprecated = true]; } /** This command acts as a recover command for deleted keys that are still in deleted table on Ozone Manager. + Not used anymore due to HDDS-11251 */ message RecoverTrashRequest { - required string volumeName = 1; - required string bucketName = 2; - required string keyName = 3; - required string destinationBucket = 4; + // option deprecated = true; + required string volumeName = 1 [deprecated = true]; + required string bucketName = 2 [deprecated = true]; + required string keyName = 3 [deprecated = true]; + required string destinationBucket = 4 [deprecated = true]; } message RecoverTrashResponse { - required bool response = 1; + // option deprecated = true; + required bool response = 1 [deprecated = true]; } message VolumeInfo { diff --git a/hadoop-ozone/interface-storage/src/main/java/org/apache/hadoop/ozone/om/OMMetadataManager.java b/hadoop-ozone/interface-storage/src/main/java/org/apache/hadoop/ozone/om/OMMetadataManager.java index fb34d19a8bb..cf0819ca527 100644 --- a/hadoop-ozone/interface-storage/src/main/java/org/apache/hadoop/ozone/om/OMMetadataManager.java +++ b/hadoop-ozone/interface-storage/src/main/java/org/apache/hadoop/ozone/om/OMMetadataManager.java @@ -262,24 +262,6 @@ ListKeysResult listKeys(String volumeName, int maxKeys) throws IOException; - /** - * List trash allows the user to list the keys that were marked as deleted, - * but not actually deleted by Ozone Manager. This allows a user to recover - * keys within a configurable window. - * @param volumeName - The volume name, which can also be a wild card - * using '*'. - * @param bucketName - The bucket name, which can also be a wild card - * using '*'. - * @param startKeyName - List keys from a specific key name. - * @param keyPrefix - List keys using a specific prefix. - * @param maxKeys - The number of keys to be returned. This must be below - * the cluster level set by admins. - * @return The list of keys that are deleted from the deleted table. - * @throws IOException - */ - List listTrash(String volumeName, String bucketName, - String startKeyName, String keyPrefix, int maxKeys) throws IOException; - /** * Returns snapshot info for volume/bucket snapshot path. * @param volumeName volume name @@ -304,18 +286,6 @@ ListSnapshotResponse listSnapshot( String volumeName, String bucketName, String snapshotPrefix, String prevSnapshot, int maxListResult) throws IOException; - /** - * Recover trash allows the user to recover the keys - * that were marked as deleted, but not actually deleted by Ozone Manager. - * @param volumeName - The volume name. - * @param bucketName - The bucket name. - * @param keyName - The key user want to recover. - * @param destinationBucket - The bucket user want to recover to. - * @return The result of recovering operation is success or not. - */ - boolean recoverTrash(String volumeName, String bucketName, - String keyName, String destinationBucket) throws IOException; - /** * Returns a list of volumes owned by a given user; if user is null, returns * all volumes. diff --git a/hadoop-ozone/ozone-manager/src/main/java/org/apache/hadoop/ozone/om/KeyManager.java b/hadoop-ozone/ozone-manager/src/main/java/org/apache/hadoop/ozone/om/KeyManager.java index 7a3312c0685..b7fa5d746fb 100644 --- a/hadoop-ozone/ozone-manager/src/main/java/org/apache/hadoop/ozone/om/KeyManager.java +++ b/hadoop-ozone/ozone-manager/src/main/java/org/apache/hadoop/ozone/om/KeyManager.java @@ -28,7 +28,6 @@ import org.apache.hadoop.ozone.om.helpers.OmMultipartUploadListParts; import org.apache.hadoop.ozone.om.fs.OzoneManagerFS; import org.apache.hadoop.hdds.utils.BackgroundService; -import org.apache.hadoop.ozone.om.helpers.RepeatedOmKeyInfo; import org.apache.hadoop.ozone.om.service.KeyDeletingService; import org.apache.hadoop.ozone.om.service.SnapshotDeletingService; import org.apache.hadoop.ozone.om.service.SnapshotDirectoryCleaningService; @@ -107,24 +106,6 @@ ListKeysResult listKeys(String volumeName, String bucketName, String startKey, String keyPrefix, int maxKeys) throws IOException; - /** - * List trash allows the user to list the keys that were marked as deleted, - * but not actually deleted by Ozone Manager. This allows a user to recover - * keys within a configurable window. - * @param volumeName - The volume name, which can also be a wild card - * using '*'. - * @param bucketName - The bucket name, which can also be a wild card - * using '*'. - * @param startKeyName - List keys from a specific key name. - * @param keyPrefix - List keys using a specific prefix. - * @param maxKeys - The number of keys to be returned. This must be below - * the cluster level set by admins. - * @return The list of keys that are deleted from the deleted table. - * @throws IOException - */ - List listTrash(String volumeName, String bucketName, - String startKeyName, String keyPrefix, int maxKeys) throws IOException; - /** * Returns a PendingKeysDeletion. It has a list of pending deletion key info * that ups to the given count.Each entry is a {@link BlockGroup}, which diff --git a/hadoop-ozone/ozone-manager/src/main/java/org/apache/hadoop/ozone/om/KeyManagerImpl.java b/hadoop-ozone/ozone-manager/src/main/java/org/apache/hadoop/ozone/om/KeyManagerImpl.java index 2cb55135294..6d276d95284 100644 --- a/hadoop-ozone/ozone-manager/src/main/java/org/apache/hadoop/ozone/om/KeyManagerImpl.java +++ b/hadoop-ozone/ozone-manager/src/main/java/org/apache/hadoop/ozone/om/KeyManagerImpl.java @@ -85,7 +85,6 @@ import org.apache.hadoop.ozone.om.helpers.OzoneAclUtil; import org.apache.hadoop.ozone.om.helpers.OzoneFSUtils; import org.apache.hadoop.ozone.om.helpers.OzoneFileStatus; -import org.apache.hadoop.ozone.om.helpers.RepeatedOmKeyInfo; import org.apache.hadoop.ozone.om.helpers.BucketLayout; import org.apache.hadoop.ozone.om.request.OMClientRequest; import org.apache.hadoop.ozone.om.request.file.OMFileRequest; @@ -122,8 +121,6 @@ import static org.apache.hadoop.ozone.OzoneConfigKeys.OZONE_BLOCK_DELETING_SERVICE_INTERVAL_DEFAULT; import static org.apache.hadoop.ozone.OzoneConfigKeys.OZONE_BLOCK_DELETING_SERVICE_TIMEOUT; import static org.apache.hadoop.ozone.OzoneConfigKeys.OZONE_BLOCK_DELETING_SERVICE_TIMEOUT_DEFAULT; -import static org.apache.hadoop.ozone.OzoneConfigKeys.OZONE_CLIENT_LIST_TRASH_KEYS_MAX; -import static org.apache.hadoop.ozone.OzoneConfigKeys.OZONE_CLIENT_LIST_TRASH_KEYS_MAX_DEFAULT; import static org.apache.hadoop.ozone.OzoneConfigKeys.OZONE_SCM_BLOCK_SIZE; import static org.apache.hadoop.ozone.OzoneConfigKeys.OZONE_SCM_BLOCK_SIZE_DEFAULT; import static org.apache.hadoop.ozone.OzoneConfigKeys.OZONE_SNAPSHOT_DELETING_SERVICE_INTERVAL; @@ -182,7 +179,6 @@ public class KeyManagerImpl implements KeyManager { private final ScmClient scmClient; private final OMMetadataManager metadataManager; private final long scmBlockSize; - private final int listTrashKeysMax; private final OzoneBlockTokenSecretManager secretManager; private final boolean grpcBlockTokenEnabled; @@ -218,9 +214,6 @@ public KeyManagerImpl(OzoneManager om, ScmClient scmClient, this.grpcBlockTokenEnabled = conf.getBoolean( HDDS_BLOCK_TOKEN_ENABLED, HDDS_BLOCK_TOKEN_ENABLED_DEFAULT); - this.listTrashKeysMax = conf.getInt( - OZONE_CLIENT_LIST_TRASH_KEYS_MAX, - OZONE_CLIENT_LIST_TRASH_KEYS_MAX_DEFAULT); this.enableFileSystemPaths = conf.getBoolean(OMConfigKeys.OZONE_OM_ENABLE_FILESYSTEM_PATHS, OMConfigKeys.OZONE_OM_ENABLE_FILESYSTEM_PATHS_DEFAULT); @@ -660,21 +653,6 @@ public ListKeysResult listKeys(String volumeName, String bucketName, return listKeysResult; } - @Override - public List listTrash(String volumeName, - String bucketName, String startKeyName, String keyPrefix, - int maxKeys) throws IOException { - - Preconditions.checkNotNull(volumeName); - Preconditions.checkNotNull(bucketName); - Preconditions.checkArgument(maxKeys <= listTrashKeysMax, - "The max keys limit specified is not less than the cluster " + - "allowed maximum limit."); - - return metadataManager.listTrash(volumeName, bucketName, - startKeyName, keyPrefix, maxKeys); - } - @Override public PendingKeysDeletion getPendingDeletionKeys(final int count) throws IOException { diff --git a/hadoop-ozone/ozone-manager/src/main/java/org/apache/hadoop/ozone/om/OMMetrics.java b/hadoop-ozone/ozone-manager/src/main/java/org/apache/hadoop/ozone/om/OMMetrics.java index 1c0ec78cfb2..cbe5205c10b 100644 --- a/hadoop-ozone/ozone-manager/src/main/java/org/apache/hadoop/ozone/om/OMMetrics.java +++ b/hadoop-ozone/ozone-manager/src/main/java/org/apache/hadoop/ozone/om/OMMetrics.java @@ -61,7 +61,6 @@ public class OMMetrics implements OmMetadataReaderMetrics { private @Metric MutableCounterLong numKeyDeletes; private @Metric MutableCounterLong numBucketLists; private @Metric MutableCounterLong numKeyLists; - private @Metric MutableCounterLong numTrashKeyLists; private @Metric MutableCounterLong numVolumeLists; private @Metric MutableCounterLong numKeyCommits; private @Metric MutableCounterLong numKeyHSyncs; @@ -120,7 +119,6 @@ public class OMMetrics implements OmMetadataReaderMetrics { private @Metric MutableCounterLong numKeyDeleteFails; private @Metric MutableCounterLong numBucketListFails; private @Metric MutableCounterLong numKeyListFails; - private @Metric MutableCounterLong numTrashKeyListFails; private @Metric MutableCounterLong numVolumeListFails; private @Metric MutableCounterLong numKeyCommitFails; private @Metric MutableCounterLong numBlockAllocationFails; @@ -420,11 +418,6 @@ public void incNumKeyLists() { numKeyLists.incr(); } - public void incNumTrashKeyLists() { - numKeyOps.incr(); - numTrashKeyLists.incr(); - } - public void incNumVolumeLists() { numVolumeOps.incr(); numVolumeLists.incr(); @@ -836,10 +829,6 @@ public void incNumKeyListFails() { numKeyListFails.incr(); } - public void incNumTrashKeyListFails() { - numTrashKeyListFails.incr(); - } - public void incNumVolumeListFails() { numVolumeListFails.incr(); } @@ -994,11 +983,6 @@ public long getNumKeyLists() { return numKeyLists.value(); } - @VisibleForTesting - public long getNumTrashKeyLists() { - return numTrashKeyLists.value(); - } - @VisibleForTesting public long getNumGetServiceLists() { return numGetServiceLists.value(); @@ -1099,11 +1083,6 @@ public long getNumKeyListFails() { return numKeyListFails.value(); } - @VisibleForTesting - public long getNumTrashKeyListFails() { - return numTrashKeyListFails.value(); - } - @VisibleForTesting public long getNumFSOps() { return numFSOps.value(); diff --git a/hadoop-ozone/ozone-manager/src/main/java/org/apache/hadoop/ozone/om/OmMetadataManagerImpl.java b/hadoop-ozone/ozone-manager/src/main/java/org/apache/hadoop/ozone/om/OmMetadataManagerImpl.java index 22d2b1e50b2..ee92dbc2fde 100644 --- a/hadoop-ozone/ozone-manager/src/main/java/org/apache/hadoop/ozone/om/OmMetadataManagerImpl.java +++ b/hadoop-ozone/ozone-manager/src/main/java/org/apache/hadoop/ozone/om/OmMetadataManagerImpl.java @@ -1385,15 +1385,6 @@ public ListKeysResult listKeys(String volumeName, String bucketName, return new ListKeysResult(result, isTruncated); } - // TODO: HDDS-2419 - Complete stub below for core logic - @Override - public List listTrash(String volumeName, String bucketName, - String startKeyName, String keyPrefix, int maxKeys) throws IOException { - - List deletedKeys = new ArrayList<>(); - return deletedKeys; - } - @Override public SnapshotInfo getSnapshotInfo(String volumeName, String bucketName, String snapshotName) throws IOException { @@ -1470,18 +1461,6 @@ public ListSnapshotResponse listSnapshot( return new ListSnapshotResponse(snapshotInfos, lastSnapshot); } - @Override - public boolean recoverTrash(String volumeName, String bucketName, - String keyName, String destinationBucket) throws IOException { - - /* TODO: HDDS-2425 and HDDS-2426 - core logic stub would be added in later patch. - */ - - boolean recoverOperation = true; - return recoverOperation; - } - /** * @param userName volume owner, null for listing all volumes. */ diff --git a/hadoop-ozone/ozone-manager/src/main/java/org/apache/hadoop/ozone/om/OzoneManager.java b/hadoop-ozone/ozone-manager/src/main/java/org/apache/hadoop/ozone/om/OzoneManager.java index a514262cae2..2fb15ec3d60 100644 --- a/hadoop-ozone/ozone-manager/src/main/java/org/apache/hadoop/ozone/om/OzoneManager.java +++ b/hadoop-ozone/ozone-manager/src/main/java/org/apache/hadoop/ozone/om/OzoneManager.java @@ -172,7 +172,6 @@ import org.apache.hadoop.ozone.om.helpers.OmVolumeArgs; import org.apache.hadoop.ozone.om.helpers.OzoneFileStatus; import org.apache.hadoop.ozone.om.helpers.OzoneFileStatusLight; -import org.apache.hadoop.ozone.om.helpers.RepeatedOmKeyInfo; import org.apache.hadoop.ozone.om.helpers.S3VolumeContext; import org.apache.hadoop.ozone.om.helpers.ServiceInfo; import org.apache.hadoop.ozone.om.helpers.ServiceInfoEx; @@ -2969,39 +2968,6 @@ public ListKeysLightResult listKeysLight(String volumeName, return new ListKeysLightResult(basicKeysList, listKeysResult.isTruncated()); } - @Override - public List listTrash(String volumeName, - String bucketName, String startKeyName, String keyPrefix, int maxKeys) - throws IOException { - boolean auditSuccess = true; - Map auditMap = buildAuditMap(volumeName); - auditMap.put(OzoneConsts.BUCKET, bucketName); - auditMap.put(OzoneConsts.START_KEY, startKeyName); - auditMap.put(OzoneConsts.KEY_PREFIX, keyPrefix); - auditMap.put(OzoneConsts.MAX_KEYS, String.valueOf(maxKeys)); - try { - if (isAclEnabled) { - omMetadataReader.checkAcls(ResourceType.BUCKET, - StoreType.OZONE, ACLType.LIST, - volumeName, bucketName, keyPrefix); - } - metrics.incNumTrashKeyLists(); - return keyManager.listTrash(volumeName, bucketName, - startKeyName, keyPrefix, maxKeys); - } catch (IOException ex) { - metrics.incNumTrashKeyListFails(); - auditSuccess = false; - AUDIT.logReadFailure(buildAuditMessageForFailure(OMAction.LIST_TRASH, - auditMap, ex)); - throw ex; - } finally { - if (auditSuccess) { - AUDIT.logReadSuccess(buildAuditMessageForSuccess(OMAction.LIST_TRASH, - auditMap)); - } - } - } - @Override public SnapshotInfo getSnapshotInfo(String volumeName, String bucketName, String snapshotName) throws IOException { diff --git a/hadoop-ozone/ozone-manager/src/main/java/org/apache/hadoop/ozone/protocolPB/OzoneManagerRequestHandler.java b/hadoop-ozone/ozone-manager/src/main/java/org/apache/hadoop/ozone/protocolPB/OzoneManagerRequestHandler.java index a5e94689aee..f6bd7cca139 100644 --- a/hadoop-ozone/ozone-manager/src/main/java/org/apache/hadoop/ozone/protocolPB/OzoneManagerRequestHandler.java +++ b/hadoop-ozone/ozone-manager/src/main/java/org/apache/hadoop/ozone/protocolPB/OzoneManagerRequestHandler.java @@ -63,7 +63,6 @@ import org.apache.hadoop.ozone.om.helpers.OpenKeySession; import org.apache.hadoop.ozone.om.helpers.OzoneFileStatus; import org.apache.hadoop.ozone.om.helpers.OzoneFileStatusLight; -import org.apache.hadoop.ozone.om.helpers.RepeatedOmKeyInfo; import org.apache.hadoop.ozone.om.helpers.ServiceInfo; import org.apache.hadoop.ozone.om.helpers.ServiceInfoEx; import org.apache.hadoop.ozone.om.helpers.SnapshotDiffJob; @@ -113,8 +112,6 @@ import org.apache.hadoop.ozone.protocol.proto.OzoneManagerProtocolProtos.ListKeysLightResponse; import org.apache.hadoop.ozone.protocol.proto.OzoneManagerProtocolProtos.ListTenantRequest; import org.apache.hadoop.ozone.protocol.proto.OzoneManagerProtocolProtos.ListTenantResponse; -import org.apache.hadoop.ozone.protocol.proto.OzoneManagerProtocolProtos.ListTrashRequest; -import org.apache.hadoop.ozone.protocol.proto.OzoneManagerProtocolProtos.ListTrashResponse; import org.apache.hadoop.ozone.protocol.proto.OzoneManagerProtocolProtos.ListVolumeRequest; import org.apache.hadoop.ozone.protocol.proto.OzoneManagerProtocolProtos.ListVolumeResponse; import org.apache.hadoop.ozone.protocol.proto.OzoneManagerProtocolProtos.LookupKeyRequest; @@ -238,11 +235,6 @@ public OMResponse handleReadRequest(OMRequest request) { request.getListKeysRequest()); responseBuilder.setListKeysLightResponse(listKeysLightResponse); break; - case ListTrash: - ListTrashResponse listTrashResponse = listTrash( - request.getListTrashRequest(), request.getVersion()); - responseBuilder.setListTrashResponse(listTrashResponse); - break; case ListMultiPartUploadParts: MultipartUploadListPartsResponse listPartsResponse = listParts(request.getListMultipartUploadPartsRequest()); @@ -835,26 +827,6 @@ public static OMResponse disallowListKeysWithBucketLayout( return resp; } - private ListTrashResponse listTrash(ListTrashRequest request, - int clientVersion) throws IOException { - - ListTrashResponse.Builder resp = - ListTrashResponse.newBuilder(); - - List deletedKeys = impl.listTrash( - request.getVolumeName(), - request.getBucketName(), - request.getStartKeyName(), - request.getKeyPrefix(), - request.getMaxKeys()); - - for (RepeatedOmKeyInfo key: deletedKeys) { - resp.addDeletedKeys(key.getProto(false, clientVersion)); - } - - return resp.build(); - } - @RequestFeatureValidator( conditions = ValidationCondition.OLDER_CLIENT_REQUESTS, processingPhase = RequestProcessingPhase.POST_PROCESS, diff --git a/hadoop-ozone/ozone-manager/src/test/java/org/apache/hadoop/ozone/om/TestTrashService.java b/hadoop-ozone/ozone-manager/src/test/java/org/apache/hadoop/ozone/om/TestTrashService.java deleted file mode 100644 index 4f0c15f15e5..00000000000 --- a/hadoop-ozone/ozone-manager/src/test/java/org/apache/hadoop/ozone/om/TestTrashService.java +++ /dev/null @@ -1,137 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -package org.apache.hadoop.ozone.om; - - -import static org.junit.jupiter.api.Assertions.assertTrue; -import org.apache.hadoop.hdds.client.StandaloneReplicationConfig; -import org.apache.hadoop.hdds.conf.OzoneConfiguration; -import org.apache.hadoop.hdds.protocol.proto.HddsProtos; -import org.apache.hadoop.hdds.server.ServerUtils; -import org.apache.hadoop.hdds.utils.db.DBConfigFromFile; -import org.apache.hadoop.ozone.om.helpers.OmBucketInfo; -import org.apache.hadoop.ozone.om.helpers.OmKeyArgs; -import org.apache.hadoop.ozone.om.helpers.OmVolumeArgs; -import org.apache.hadoop.ozone.om.helpers.OpenKeySession; -import org.apache.hadoop.ozone.om.protocol.OzoneManagerProtocol; -import org.apache.hadoop.ozone.om.request.OMRequestTestUtils; -import org.apache.hadoop.security.UserGroupInformation; -import org.apache.ratis.util.ExitUtils; -import org.junit.jupiter.api.AfterEach; -import org.junit.jupiter.api.BeforeEach; -import org.junit.jupiter.api.Test; -import org.junit.jupiter.api.io.TempDir; - -import java.io.File; -import java.io.IOException; -import java.nio.file.Path; -import java.util.ArrayList; -import java.util.Collections; - -/** - * Test Key Trash Service. - *

- * This test does the things including: - * 1. UTs for list trash. - * 2. UTs for recover trash. - * 3. UTs for empty trash. - *

- */ -public class TestTrashService { - - @TempDir - private Path tempFolder; - - private KeyManager keyManager; - private OzoneManagerProtocol writeClient; - private OzoneManager om; - private String volumeName; - private String bucketName; - - @BeforeEach - void setup() throws Exception { - ExitUtils.disableSystemExit(); - OzoneConfiguration configuration = new OzoneConfiguration(); - - File folder = tempFolder.toFile(); - if (!folder.exists()) { - assertTrue(folder.mkdirs()); - } - System.setProperty(DBConfigFromFile.CONFIG_DIR, "/"); - ServerUtils.setOzoneMetaDirPath(configuration, folder.toString()); - - OmTestManagers omTestManagers - = new OmTestManagers(configuration); - keyManager = omTestManagers.getKeyManager(); - writeClient = omTestManagers.getWriteClient(); - om = omTestManagers.getOzoneManager(); - volumeName = "volume"; - bucketName = "bucket"; - } - - @AfterEach - public void cleanup() throws Exception { - om.stop(); - } - - @Test - public void testRecoverTrash() throws IOException { - String keyName = "testKey"; - String destinationBucket = "destBucket"; - createAndDeleteKey(keyName); - - boolean recoverOperation = keyManager.getMetadataManager() - .recoverTrash(volumeName, bucketName, keyName, destinationBucket); - assertTrue(recoverOperation); - } - - private void createAndDeleteKey(String keyName) throws IOException { - - OMRequestTestUtils.addVolumeToOM(keyManager.getMetadataManager(), - OmVolumeArgs.newBuilder() - .setOwnerName("owner") - .setAdminName("admin") - .setVolume(volumeName) - .build()); - - OMRequestTestUtils.addBucketToOM(keyManager.getMetadataManager(), - OmBucketInfo.newBuilder() - .setVolumeName(volumeName) - .setBucketName(bucketName) - .build()); - - OmKeyArgs keyArgs = new OmKeyArgs.Builder() - .setVolumeName(volumeName) - .setBucketName(bucketName) - .setKeyName(keyName) - .setAcls(Collections.emptyList()) - .setLocationInfoList(new ArrayList<>()) - .setReplicationConfig(StandaloneReplicationConfig - .getInstance(HddsProtos.ReplicationFactor.ONE)) - .setOwnerName(UserGroupInformation.getCurrentUser().getShortUserName()) - .build(); - - /* Create and delete key in the Key Manager. */ - OpenKeySession session = writeClient.openKey(keyArgs); - writeClient.commitKey(keyArgs, session.getId()); - writeClient.deleteKey(keyArgs); - } - -} diff --git a/hadoop-ozone/s3gateway/src/test/java/org/apache/hadoop/ozone/client/ClientProtocolStub.java b/hadoop-ozone/s3gateway/src/test/java/org/apache/hadoop/ozone/client/ClientProtocolStub.java index 41876c6e245..e3e3537b1c3 100644 --- a/hadoop-ozone/s3gateway/src/test/java/org/apache/hadoop/ozone/client/ClientProtocolStub.java +++ b/hadoop-ozone/s3gateway/src/test/java/org/apache/hadoop/ozone/client/ClientProtocolStub.java @@ -43,7 +43,6 @@ import org.apache.hadoop.ozone.om.helpers.OmVolumeArgs; import org.apache.hadoop.ozone.om.helpers.OzoneFileStatus; import org.apache.hadoop.ozone.om.helpers.OzoneFileStatusLight; -import org.apache.hadoop.ozone.om.helpers.RepeatedOmKeyInfo; import org.apache.hadoop.ozone.om.helpers.S3SecretValue; import org.apache.hadoop.ozone.om.helpers.S3VolumeContext; import org.apache.hadoop.ozone.om.helpers.TenantStateList; @@ -301,21 +300,6 @@ public List listKeys(String volumeName, String bucketName, return null; } - @Override - public List listTrash(String volumeName, String bucketName, - String startKeyName, - String keyPrefix, int maxKeys) - throws IOException { - return null; - } - - @Override - public boolean recoverTrash(String volumeName, String bucketName, - String keyName, String destinationBucket) - throws IOException { - return false; - } - @Override public OzoneKeyDetails getKeyDetails(String volumeName, String bucketName, String keyName) throws IOException {