errose28 commented on code in PR #4865:
URL: https://github.com/apache/ozone/pull/4865#discussion_r1231468080
##########
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:
Should we print these to stderr instead? If stdout is piped to jq this will
cause jq to fail and the user will also not see the message. If it goes to
stderr then jq will succeed and the user will see the message as well.
--
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]