adoroszlai commented on code in PR #4865:
URL: https://github.com/apache/ozone/pull/4865#discussion_r1231997612
##########
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:
> I will create another Jira and handle -1 to override list all keys.
How about adding a `--all` option in `ListOptions`? If it is set, then
`limit` could be set to `MAX_VALUE` or `-1` (whichever works) _internally_. I
think that would be more user-friendly than using a special value publicly.
--
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]