adoroszlai commented on code in PR #4865:
URL: https://github.com/apache/ozone/pull/4865#discussion_r1231519008
##########
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:
Filed HDDS-8858 to avoid mixing these messages with the JSON output. I was
thinking about showing only in `--verbose` mode, but `stderr` seems a better
idea.
##########
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:
Filed HDDS-8858 to avoid mixing these messages with the JSON output. I was
thinking about showing only in `--verbose` mode, but `stderr` seems like a
better idea.
--
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]