Skip to content

Commit 6f5963a

Browse files
committed
Initial commit to deprecate and remove listTrash and recoverTrash API
1 parent 609b178 commit 6f5963a

14 files changed

Lines changed: 33 additions & 357 deletions

File tree

hadoop-ozone/client/src/main/java/org/apache/hadoop/ozone/client/protocol/ClientProtocol.java

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -527,7 +527,11 @@ List<OzoneKey> listKeys(String volumeName, String bucketName,
527527
* the cluster level set by admins.
528528
* @return The list of keys that are deleted from the deleted table.
529529
* @throws IOException
530+
* @deprecated New trash APIs have been introduced as a part of HDDS-2416,
531+
* and being integrated in HDDS-HDDS-3367.
532+
* Please avoid using this as it will be removed in a future release
530533
*/
534+
@Deprecated
531535
List<RepeatedOmKeyInfo> listTrash(String volumeName, String bucketName,
532536
String startKeyName, String keyPrefix,
533537
int maxKeys)
@@ -542,7 +546,11 @@ List<RepeatedOmKeyInfo> listTrash(String volumeName, String bucketName,
542546
* @param destinationBucket - The bucket user want to recover to.
543547
* @return The result of recovering operation is success or not.
544548
* @throws IOException
549+
* @deprecated New trash APIs have been introduced as a part of HDDS-2416,
550+
* and being integrated in HDDS-HDDS-3367.
551+
* Please avoid using this as it will be removed in a future release
545552
*/
553+
@Deprecated
546554
boolean recoverTrash(String volumeName, String bucketName, String keyName,
547555
String destinationBucket) throws IOException;
548556

hadoop-ozone/client/src/main/java/org/apache/hadoop/ozone/client/rpc/RpcClient.java

Lines changed: 0 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1759,25 +1759,6 @@ public List<OzoneKey> listKeys(String volumeName, String bucketName,
17591759
}
17601760
}
17611761

1762-
@Override
1763-
public List<RepeatedOmKeyInfo> listTrash(String volumeName, String bucketName,
1764-
String startKeyName, String keyPrefix, int maxKeys) throws IOException {
1765-
1766-
Preconditions.checkNotNull(volumeName);
1767-
Preconditions.checkNotNull(bucketName);
1768-
1769-
return ozoneManagerClient.listTrash(volumeName, bucketName, startKeyName,
1770-
keyPrefix, maxKeys);
1771-
}
1772-
1773-
@Override
1774-
public boolean recoverTrash(String volumeName, String bucketName,
1775-
String keyName, String destinationBucket) throws IOException {
1776-
1777-
return ozoneManagerClient.recoverTrash(volumeName, bucketName, keyName,
1778-
destinationBucket);
1779-
}
1780-
17811762
@Override
17821763
public OzoneKeyDetails getKeyDetails(
17831764
String volumeName, String bucketName, String keyName)

hadoop-ozone/common/src/main/java/org/apache/hadoop/ozone/om/protocol/OzoneManagerProtocol.java

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1067,8 +1067,12 @@ DBUpdates getDBUpdates(
10671067
* @param maxKeys - The number of keys to be returned. This must be below
10681068
* the cluster level set by admins.
10691069
* @return The list of keys that are deleted from the deleted table.
1070-
* @throws IOException
1070+
* @throws IOException
1071+
* @deprecated New trash APIs have been introduced as a part of HDDS-2416,
1072+
* and being integrated in HDDS-HDDS-3367.
1073+
* Please avoid using this as it will be removed in a future release
10711074
*/
1075+
@Deprecated
10721076
List<RepeatedOmKeyInfo> listTrash(String volumeName, String bucketName,
10731077
String startKeyName, String keyPrefix, int maxKeys) throws IOException;
10741078

@@ -1081,7 +1085,11 @@ List<RepeatedOmKeyInfo> listTrash(String volumeName, String bucketName,
10811085
* @param destinationBucket - The bucket user want to recover to.
10821086
* @return The result of recovering operation is success or not.
10831087
* @throws IOException
1088+
* @deprecated New trash APIs have been introduced as a part of HDDS-2416,
1089+
* and being integrated in HDDS-HDDS-3367.
1090+
* Please avoid using this as it will be removed in a future release
10841091
*/
1092+
@Deprecated
10851093
default boolean recoverTrash(String volumeName, String bucketName,
10861094
String keyName, String destinationBucket) throws IOException {
10871095
return false;

hadoop-ozone/common/src/main/java/org/apache/hadoop/ozone/om/protocolPB/OzoneManagerProtocolClientSideTranslatorPB.java

Lines changed: 0 additions & 79 deletions
Original file line numberDiff line numberDiff line change
@@ -2439,85 +2439,6 @@ public List<OzoneFileStatus> listStatus(OmKeyArgs args, boolean recursive,
24392439
return listStatus(args, recursive, startKey, numEntries, false);
24402440
}
24412441

2442-
@Override
2443-
public List<RepeatedOmKeyInfo> listTrash(String volumeName,
2444-
String bucketName, String startKeyName, String keyPrefix, int maxKeys)
2445-
throws IOException {
2446-
2447-
Preconditions.checkArgument(Strings.isNullOrEmpty(volumeName),
2448-
"The volume name cannot be null or " +
2449-
"empty. Please enter a valid volume name or use '*' as a wild card");
2450-
2451-
Preconditions.checkArgument(Strings.isNullOrEmpty(bucketName),
2452-
"The bucket name cannot be null or " +
2453-
"empty. Please enter a valid bucket name or use '*' as a wild card");
2454-
2455-
ListTrashRequest trashRequest = ListTrashRequest.newBuilder()
2456-
.setVolumeName(volumeName)
2457-
.setBucketName(bucketName)
2458-
.setStartKeyName(startKeyName)
2459-
.setKeyPrefix(keyPrefix)
2460-
.setMaxKeys(maxKeys)
2461-
.build();
2462-
2463-
OMRequest omRequest = createOMRequest(Type.ListTrash)
2464-
.setListTrashRequest(trashRequest)
2465-
.build();
2466-
2467-
ListTrashResponse trashResponse =
2468-
handleError(submitRequest(omRequest)).getListTrashResponse();
2469-
2470-
List<RepeatedOmKeyInfo> deletedKeyList =
2471-
new ArrayList<>(trashResponse.getDeletedKeysCount());
2472-
2473-
List<RepeatedOmKeyInfo> list = new ArrayList<>();
2474-
for (OzoneManagerProtocolProtos.RepeatedKeyInfo
2475-
repeatedKeyInfo : trashResponse.getDeletedKeysList()) {
2476-
RepeatedOmKeyInfo fromProto =
2477-
RepeatedOmKeyInfo.getFromProto(repeatedKeyInfo);
2478-
list.add(fromProto);
2479-
}
2480-
deletedKeyList.addAll(list);
2481-
2482-
return deletedKeyList;
2483-
}
2484-
2485-
@Override
2486-
public boolean recoverTrash(String volumeName, String bucketName,
2487-
String keyName, String destinationBucket) throws IOException {
2488-
2489-
Preconditions.checkArgument(Strings.isNullOrEmpty(volumeName),
2490-
"The volume name cannot be null or empty. " +
2491-
"Please enter a valid volume name.");
2492-
2493-
Preconditions.checkArgument(Strings.isNullOrEmpty(bucketName),
2494-
"The bucket name cannot be null or empty. " +
2495-
"Please enter a valid bucket name.");
2496-
2497-
Preconditions.checkArgument(Strings.isNullOrEmpty(keyName),
2498-
"The key name cannot be null or empty. " +
2499-
"Please enter a valid key name.");
2500-
2501-
Preconditions.checkArgument(Strings.isNullOrEmpty(destinationBucket),
2502-
"The destination bucket name cannot be null or empty. " +
2503-
"Please enter a valid destination bucket name.");
2504-
2505-
RecoverTrashRequest.Builder req = RecoverTrashRequest.newBuilder()
2506-
.setVolumeName(volumeName)
2507-
.setBucketName(bucketName)
2508-
.setKeyName(keyName)
2509-
.setDestinationBucket(destinationBucket);
2510-
2511-
OMRequest omRequest = createOMRequest(Type.RecoverTrash)
2512-
.setRecoverTrashRequest(req)
2513-
.build();
2514-
2515-
RecoverTrashResponse recoverResponse =
2516-
handleError(submitRequest(omRequest)).getRecoverTrashResponse();
2517-
2518-
return recoverResponse.getResponse();
2519-
}
2520-
25212442
@Override
25222443
public long prepareOzoneManager(
25232444
long txnApplyWaitTimeoutSeconds, long txnApplyCheckIntervalSeconds)

hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/ozone/om/TestOmMetrics.java

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -409,8 +409,6 @@ public void testKeyOps() throws Exception {
409409
doThrow(exception).when(mockKm).lookupKey(any(), any(), any());
410410
doThrow(exception).when(mockKm).listKeys(
411411
any(), any(), any(), any(), anyInt());
412-
doThrow(exception).when(mockKm).listTrash(
413-
any(), any(), any(), any(), anyInt());
414412
OmMetadataReader omMetadataReader =
415413
(OmMetadataReader) ozoneManager.getOmMetadataReader().get();
416414
HddsWhiteboxTestUtils.setInternalState(
@@ -843,12 +841,6 @@ private void doKeyOps(OmKeyArgs keyArgs) {
843841
} catch (IOException ignored) {
844842
}
845843

846-
try {
847-
ozoneManager.listTrash(keyArgs.getVolumeName(),
848-
keyArgs.getBucketName(), null, null, 0);
849-
} catch (IOException ignored) {
850-
}
851-
852844
try {
853845
writeClient.deleteKey(keyArgs);
854846
} catch (IOException ignored) {

hadoop-ozone/interface-client/src/main/proto/OmClientProtocol.proto

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -232,8 +232,8 @@ message OMRequest {
232232
optional UpdateGetS3SecretRequest updateGetS3SecretRequest = 82;
233233
optional ListMultipartUploadsRequest listMultipartUploadsRequest = 83;
234234

235-
optional ListTrashRequest listTrashRequest = 91;
236-
optional RecoverTrashRequest RecoverTrashRequest = 92;
235+
optional ListTrashRequest listTrashRequest = 91 [deprecated = true];
236+
optional RecoverTrashRequest RecoverTrashRequest = 92 [deprecated = true];
237237

238238
optional RevokeS3SecretRequest RevokeS3SecretRequest = 93;
239239

@@ -360,8 +360,8 @@ message OMResponse {
360360

361361
optional ListMultipartUploadsResponse listMultipartUploadsResponse = 82;
362362

363-
optional ListTrashResponse listTrashResponse = 91;
364-
optional RecoverTrashResponse RecoverTrashResponse = 92;
363+
optional ListTrashResponse listTrashResponse = 91 [deprecated = true];
364+
optional RecoverTrashResponse RecoverTrashResponse = 92 [deprecated = true];
365365
optional PurgePathsResponse purgePathsResponse = 93 [deprecated = true];
366366
optional PurgeDirectoriesResponse purgeDirectoriesResponse = 108;
367367

hadoop-ozone/interface-storage/src/main/java/org/apache/hadoop/ozone/om/OMMetadataManager.java

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -276,7 +276,11 @@ ListKeysResult listKeys(String volumeName,
276276
* the cluster level set by admins.
277277
* @return The list of keys that are deleted from the deleted table.
278278
* @throws IOException
279+
* @deprecated New trash APIs have been introduced as a part of HDDS-2416,
280+
* and being integrated in HDDS-HDDS-3367.
281+
* Please avoid using this as it will be removed in a future release
279282
*/
283+
@Deprecated
280284
List<RepeatedOmKeyInfo> listTrash(String volumeName, String bucketName,
281285
String startKeyName, String keyPrefix, int maxKeys) throws IOException;
282286

@@ -312,7 +316,11 @@ ListSnapshotResponse listSnapshot(
312316
* @param keyName - The key user want to recover.
313317
* @param destinationBucket - The bucket user want to recover to.
314318
* @return The result of recovering operation is success or not.
319+
* @deprecated New trash APIs have been introduced as a part of HDDS-2416,
320+
* and being integrated in HDDS-HDDS-3367.
321+
* Please avoid using this as it will be removed in a future release
315322
*/
323+
@Deprecated
316324
boolean recoverTrash(String volumeName, String bucketName,
317325
String keyName, String destinationBucket) throws IOException;
318326

hadoop-ozone/ozone-manager/src/main/java/org/apache/hadoop/ozone/om/KeyManager.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,11 @@ ListKeysResult listKeys(String volumeName, String bucketName, String startKey,
121121
* the cluster level set by admins.
122122
* @return The list of keys that are deleted from the deleted table.
123123
* @throws IOException
124+
* @deprecated New trash APIs have been introduced as a part of HDDS-2416,
125+
* and being integrated in HDDS-HDDS-3367.
126+
* Please avoid using this as it will be removed in a future release
124127
*/
128+
@Deprecated
125129
List<RepeatedOmKeyInfo> listTrash(String volumeName, String bucketName,
126130
String startKeyName, String keyPrefix, int maxKeys) throws IOException;
127131

hadoop-ozone/ozone-manager/src/main/java/org/apache/hadoop/ozone/om/KeyManagerImpl.java

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -660,21 +660,6 @@ public ListKeysResult listKeys(String volumeName, String bucketName,
660660
return listKeysResult;
661661
}
662662

663-
@Override
664-
public List<RepeatedOmKeyInfo> listTrash(String volumeName,
665-
String bucketName, String startKeyName, String keyPrefix,
666-
int maxKeys) throws IOException {
667-
668-
Preconditions.checkNotNull(volumeName);
669-
Preconditions.checkNotNull(bucketName);
670-
Preconditions.checkArgument(maxKeys <= listTrashKeysMax,
671-
"The max keys limit specified is not less than the cluster " +
672-
"allowed maximum limit.");
673-
674-
return metadataManager.listTrash(volumeName, bucketName,
675-
startKeyName, keyPrefix, maxKeys);
676-
}
677-
678663
@Override
679664
public PendingKeysDeletion getPendingDeletionKeys(final int count)
680665
throws IOException {

hadoop-ozone/ozone-manager/src/main/java/org/apache/hadoop/ozone/om/OmMetadataManagerImpl.java

Lines changed: 0 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1385,15 +1385,6 @@ public ListKeysResult listKeys(String volumeName, String bucketName,
13851385
return new ListKeysResult(result, isTruncated);
13861386
}
13871387

1388-
// TODO: HDDS-2419 - Complete stub below for core logic
1389-
@Override
1390-
public List<RepeatedOmKeyInfo> listTrash(String volumeName, String bucketName,
1391-
String startKeyName, String keyPrefix, int maxKeys) throws IOException {
1392-
1393-
List<RepeatedOmKeyInfo> deletedKeys = new ArrayList<>();
1394-
return deletedKeys;
1395-
}
1396-
13971388
@Override
13981389
public SnapshotInfo getSnapshotInfo(String volumeName, String bucketName,
13991390
String snapshotName) throws IOException {
@@ -1470,18 +1461,6 @@ public ListSnapshotResponse listSnapshot(
14701461
return new ListSnapshotResponse(snapshotInfos, lastSnapshot);
14711462
}
14721463

1473-
@Override
1474-
public boolean recoverTrash(String volumeName, String bucketName,
1475-
String keyName, String destinationBucket) throws IOException {
1476-
1477-
/* TODO: HDDS-2425 and HDDS-2426
1478-
core logic stub would be added in later patch.
1479-
*/
1480-
1481-
boolean recoverOperation = true;
1482-
return recoverOperation;
1483-
}
1484-
14851464
/**
14861465
* @param userName volume owner, null for listing all volumes.
14871466
*/

0 commit comments

Comments
 (0)