adoroszlai commented on code in PR #3777:
URL: https://github.com/apache/ozone/pull/3777#discussion_r984711851


##########
hadoop-ozone/tools/src/main/java/org/apache/hadoop/ozone/shell/bucket/ListBucketHandler.java:
##########
@@ -50,13 +53,33 @@ protected void execute(OzoneClient client, OzoneAddress 
address)
     OzoneVolume vol = client.getObjectStore().getVolume(volumeName);
     Iterator<? extends OzoneBucket> bucketIterator =
         vol.listBuckets(listOptions.getPrefix(), listOptions.getStartItem());
-
-    int counter = printAsJsonArray(bucketIterator, listOptions.getLimit());
+    int counter = printBuckets(bucketIterator, listOptions.getLimit());
 
     if (isVerbose()) {
       out().printf("Found : %d buckets for volume : %s ", counter, volumeName);
     }
   }
 
+  private int printBuckets(Iterator<? extends OzoneBucket> bucketIterator,
+                           int limit) {
+    int counter = 0;
+    final ArrayNode arrayNode = JsonUtils.createArrayNode();
+    ObjectNode jsonNode;
+    while (limit > counter && bucketIterator.hasNext()) {
+      OzoneBucket bucket = bucketIterator.next();
+      if (bucket.getSourceBucket() != null &&
+          bucket.getSourceVolume() != null) {

Review Comment:
   ```suggestion
         if (bucket.isLink()) {
   ```



##########
hadoop-ozone/tools/src/main/java/org/apache/hadoop/ozone/shell/bucket/ListBucketHandler.java:
##########
@@ -50,13 +53,33 @@ protected void execute(OzoneClient client, OzoneAddress 
address)
     OzoneVolume vol = client.getObjectStore().getVolume(volumeName);
     Iterator<? extends OzoneBucket> bucketIterator =
         vol.listBuckets(listOptions.getPrefix(), listOptions.getStartItem());
-
-    int counter = printAsJsonArray(bucketIterator, listOptions.getLimit());
+    int counter = printBuckets(bucketIterator, listOptions.getLimit());
 
     if (isVerbose()) {
       out().printf("Found : %d buckets for volume : %s ", counter, volumeName);
     }
   }
 
+  private int printBuckets(Iterator<? extends OzoneBucket> bucketIterator,
+                           int limit) {
+    int counter = 0;
+    final ArrayNode arrayNode = JsonUtils.createArrayNode();

Review Comment:
   We don't need to manually create JSON-specific objects.  Can create a 
`List<Object>` instead, and depending on whether each item is a bucket or a 
link, can add `bucket` itself or `new LinkBucket(bucket)`.  Then the list can 
be printed via `printObjectAsJson(list)`.



-- 
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]

Reply via email to