ashishkumar50 commented on code in PR #4675:
URL: https://github.com/apache/ozone/pull/4675#discussion_r1192280059
##########
hadoop-ozone/tools/src/main/java/org/apache/hadoop/ozone/shell/keys/DeleteKeyHandler.java:
##########
@@ -35,16 +48,117 @@
description = "deletes an existing key")
public class DeleteKeyHandler extends KeyHandler {
+ @CommandLine.Option(names = "--skipTrash",
+ description = "Specify whether to skip Trash ")
+ private boolean skipTrash = false;
+
+ private static final Path CURRENT = new Path("Current");
+
@Override
protected void execute(OzoneClient client, OzoneAddress address)
throws IOException, OzoneClientException {
String volumeName = address.getVolumeName();
String bucketName = address.getBucketName();
- String keyName = address.getKeyName();
-
OzoneVolume vol = client.getObjectStore().getVolume(volumeName);
OzoneBucket bucket = vol.getBucket(bucketName);
- bucket.deleteKey(keyName);
+ String keyName = address.getKeyName();
+
+ if (bucket.getBucketLayout().isFileSystemOptimized()) {
+ // Handle FSO delete key which supports trash also
+ deleteFSOKey(bucket, keyName);
+ } else {
+ bucket.deleteKey(keyName);
+ }
+ }
+
+ private void deleteFSOKey(OzoneBucket bucket, String keyName)
+ throws IOException {
+ float hadoopTrashInterval = getConf().getFloat(
+ FS_TRASH_INTERVAL_KEY, FS_TRASH_INTERVAL_DEFAULT);
+ long trashInterval =
+ (long) (getConf().getFloat(
+ OMConfigKeys.OZONE_FS_TRASH_INTERVAL_KEY,
+ hadoopTrashInterval) * 10000);
+
+ // If Bucket layout is FSO and Trash is enabled
+ // In this case during delete operation move key to trash
+ if (trashInterval > 0 && !skipTrash &&
Review Comment:
trashInterval is used to determine whether trash is enabled or not, So I
think first we should check whether trash enabled or not then we can check
trash related configs.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]