Skip to content

Commit

Permalink
HDDS-11251. Deprecate definitions and remove listTrash and recoverTra…
Browse files Browse the repository at this point in the history
…sh APIs (apache#7060)
  • Loading branch information
devabhishekpal authored Aug 27, 2024
1 parent be34303 commit 0b75cb0
Show file tree
Hide file tree
Showing 18 changed files with 38 additions and 545 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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 =
Expand Down
8 changes: 0 additions & 8 deletions hadoop-hdds/common/src/main/resources/ozone-default.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3406,14 +3406,6 @@
unhealthy will each have their own limit.
</description>
</property>
<property>
<name>ozone.client.list.trash.keys.max</name>
<value>1000</value>
<tag>OZONE, CLIENT</tag>
<description>
The maximum number of keys to return for a list trash request.
</description>
</property>
<property>
<name>ozone.http.basedir</name>
<value/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -514,39 +513,6 @@ List<OzoneKey> 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<RepeatedOmKeyInfo> 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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -1771,25 +1770,6 @@ public List<OzoneKey> listKeys(String volumeName, String bucketName,
}
}

@Override
public List<RepeatedOmKeyInfo> 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)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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<RepeatedOmKeyInfo> 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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -2442,85 +2437,6 @@ public List<OzoneFileStatus> listStatus(OmKeyArgs args, boolean recursive,
return listStatus(args, recursive, startKey, numEntries, false);
}

@Override
public List<RepeatedOmKeyInfo> 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<RepeatedOmKeyInfo> deletedKeyList =
new ArrayList<>(trashResponse.getDeletedKeysCount());

List<RepeatedOmKeyInfo> 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)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -338,15 +338,13 @@ 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);

long initialEcKeyCreateTotal = getLongCounter("EcKeyCreateTotal", omMetrics);
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);
Expand All @@ -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));

Expand Down Expand Up @@ -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(
Expand All @@ -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));
Expand Down Expand Up @@ -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) {
Expand Down
Loading

0 comments on commit 0b75cb0

Please sign in to comment.