You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@ozone.apache.org by "ashishkumar50 (via GitHub)" <gi...@apache.org> on 2023/06/16 09:09:38 UTC
[GitHub] [ozone] ashishkumar50 commented on a diff in pull request #4865: HDDS-8800. Let `ozone sh key list` support listing all keys of a volume
ashishkumar50 commented on code in PR #4865:
URL: https://github.com/apache/ozone/pull/4865#discussion_r1231993713
##########
hadoop-ozone/tools/src/main/java/org/apache/hadoop/ozone/shell/keys/ListKeyHandler.java:
##########
@@ -94,4 +103,40 @@ protected void execute(OzoneClient client, OzoneAddress address)
}
}
+ private void listKeysInsideVolume(OzoneClient client, OzoneAddress address)
+ throws IOException {
+ String volumeName = address.getVolumeName();
+ OzoneVolume vol = client.getObjectStore().getVolume(volumeName);
+
+ Iterator<? extends OzoneBucket> bucketIterator =
+ vol.listBuckets(null);
+ int maxKeyLimit = listOptions.getLimit();
+ String keyPrefix = "";
+ if (!Strings.isNullOrEmpty(listOptions.getPrefix())) {
+ keyPrefix += listOptions.getPrefix();
+ }
+
+ int totalKeys = 0;
+ while (bucketIterator.hasNext()) {
+ OzoneBucket bucket = bucketIterator.next();
+ Iterator<? extends OzoneKey> keyIterator = bucket.listKeys(keyPrefix,
+ listOptions.getStartItem());
+
+ int counter = printAsJsonArray(keyIterator, maxKeyLimit);
+ totalKeys += counter;
+ maxKeyLimit -= counter;
+
+ // More keys were returned notify about max length
+ if (keyIterator.hasNext() || (bucketIterator.hasNext()
+ && maxKeyLimit <= 0)) {
+ out().println("Listing first " + totalKeys + " entries of the " +
+ "result. Use --length (-l) to override max returned keys.");
+ return;
+ }
+ }
+ if (isVerbose()) {
+ out().printf("Found : %d keys in volume : %s %n",
+ totalKeys, volumeName);
+ }
Review Comment:
Thanks @errose28 @adoroszlai, We can handle stderr in [HDDS-8858](https://issues.apache.org/jira/browse/HDDS-8858). I will create another Jira and handle -1 to override list all keys.
--
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