You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@ozone.apache.org by GitBox <gi...@apache.org> on 2023/01/09 16:59:59 UTC

[GitHub] [ozone] xBis7 commented on a diff in pull request #4125: HDDS-7277. [Snapshot] ozone sh key list /vol1/bucket1/.snapshot/snap1 fails

xBis7 commented on code in PR #4125:
URL: https://github.com/apache/ozone/pull/4125#discussion_r1064866481


##########
hadoop-ozone/tools/src/main/java/org/apache/hadoop/ozone/shell/snapshot/ListSnapshotKeyHandler.java:
##########
@@ -0,0 +1,80 @@
+/**
+ * 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
+ * <p>
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * <p>
+ * 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.shell.snapshot;
+
+import com.google.common.base.Strings;
+import org.apache.hadoop.ozone.client.OzoneClient;
+import org.apache.hadoop.ozone.client.OzoneClientException;
+import org.apache.hadoop.ozone.client.OzoneVolume;
+import org.apache.hadoop.ozone.client.OzoneBucket;
+import org.apache.hadoop.ozone.client.OzoneKey;
+import org.apache.hadoop.ozone.shell.ListOptions;
+import org.apache.hadoop.ozone.shell.OzoneAddress;
+import picocli.CommandLine;
+
+import java.io.IOException;
+import java.util.Iterator;
+
+/**
+ * Executes List Keys for a Snapshot.
+ */
+@CommandLine.Command(name = "key-list",
+    aliases = "key-ls",
+    description = "list all keys in a given " +
+        "snapshot under a bucket")
+public class ListSnapshotKeyHandler extends SnapshotHandler {

Review Comment:
   > But couldn't you also fix the "ozone sh key list" command by changing this line to be extended from "SnapshotHandler" instead of BucketHandler?:
   
   @GeorgeJahad If we make that change then `ozone sh key list` will only work with snapshots and it will give us an error if we try to get the keys under a bucket.
   
   ```
   bash-4.2$ ozone sh key list /vol1/bucket1
   Invalid value for positional parameter at index 0 (<value>): cannot convert '/vol1/bucket1' to OzoneAddress (org.apache.hadoop.ozone.client.OzoneClientException: Snapshot name is missing.)
   Usage: ozone sh key list [-hV] [-l=<limit>] [-p=<prefix>] [-s=<startItem>]
                            <value>
   list all keys in a given bucket
   ...
   ```
   but it works for a snapshot
   
   ```
   bash-4.2$ ozone sh key list /vol1/bucket1/.snapshot/snap1
   [ {
     "volumeName" : "vol1",
     "bucketName" : "bucket1",
     "name" : "key1",
     "dataSize" : 3811,
     "creationTime" : "2023-01-09T16:56:04.248Z",
     "modificationTime" : "2023-01-09T16:56:05.308Z",
     "replicationConfig" : {
       "replicationFactor" : "THREE",
       "requiredNodes" : 3,
       "replicationType" : "RATIS"
     }
   } ]
   ```



-- 
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: issues-unsubscribe@ozone.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@ozone.apache.org
For additional commands, e-mail: issues-help@ozone.apache.org