This is an automated email from the ASF dual-hosted git repository.
adoroszlai pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/ozone.git
The following commit(s) were added to refs/heads/master by this push:
new 23a0f743bc HDDS-7219. Remove not applicable info from ozone bucket
list for links (#3777)
23a0f743bc is described below
commit 23a0f743bc753048bbfa9ae7220bda198507b343
Author: Chung En Lee <[email protected]>
AuthorDate: Thu Oct 6 00:41:20 2022 +0800
HDDS-7219. Remove not applicable info from ozone bucket list for links
(#3777)
---
.../hadoop/ozone/shell/bucket/InfoBucketHandler.java | 2 +-
.../hadoop/ozone/shell/bucket/ListBucketHandler.java | 17 ++++++++++++++---
2 files changed, 15 insertions(+), 4 deletions(-)
diff --git
a/hadoop-ozone/tools/src/main/java/org/apache/hadoop/ozone/shell/bucket/InfoBucketHandler.java
b/hadoop-ozone/tools/src/main/java/org/apache/hadoop/ozone/shell/bucket/InfoBucketHandler.java
index cfb9f5a8e7..ac70ddb75f 100644
---
a/hadoop-ozone/tools/src/main/java/org/apache/hadoop/ozone/shell/bucket/InfoBucketHandler.java
+++
b/hadoop-ozone/tools/src/main/java/org/apache/hadoop/ozone/shell/bucket/InfoBucketHandler.java
@@ -51,7 +51,7 @@ public class InfoBucketHandler extends BucketHandler {
/**
* Class used for link buckets.
*/
- private static class LinkBucket {
+ public static class LinkBucket {
private String volumeName;
private String bucketName;
private String sourceVolume;
diff --git
a/hadoop-ozone/tools/src/main/java/org/apache/hadoop/ozone/shell/bucket/ListBucketHandler.java
b/hadoop-ozone/tools/src/main/java/org/apache/hadoop/ozone/shell/bucket/ListBucketHandler.java
index c3178fb889..5590ae9cc7 100644
---
a/hadoop-ozone/tools/src/main/java/org/apache/hadoop/ozone/shell/bucket/ListBucketHandler.java
+++
b/hadoop-ozone/tools/src/main/java/org/apache/hadoop/ozone/shell/bucket/ListBucketHandler.java
@@ -19,7 +19,9 @@
package org.apache.hadoop.ozone.shell.bucket;
import java.io.IOException;
+import java.util.ArrayList;
import java.util.Iterator;
+import java.util.List;
import org.apache.hadoop.ozone.client.OzoneBucket;
import org.apache.hadoop.ozone.client.OzoneClient;
@@ -50,9 +52,18 @@ public class ListBucketHandler extends VolumeHandler {
OzoneVolume vol = client.getObjectStore().getVolume(volumeName);
Iterator<? extends OzoneBucket> bucketIterator =
vol.listBuckets(listOptions.getPrefix(), listOptions.getStartItem());
-
- int counter = printAsJsonArray(bucketIterator, listOptions.getLimit());
-
+ List<Object> bucketList = new ArrayList<>();
+ int counter = 0;
+ while (bucketIterator.hasNext() && counter < listOptions.getLimit()) {
+ OzoneBucket bucket = bucketIterator.next();
+ if (bucket.isLink()) {
+ bucketList.add(new InfoBucketHandler.LinkBucket(bucket));
+ } else {
+ bucketList.add(bucket);
+ }
+ counter++;
+ }
+ printAsJsonArray(bucketList.iterator(), listOptions.getLimit());
if (isVerbose()) {
out().printf("Found : %d buckets for volume : %s ", counter, volumeName);
}
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]