You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@ozone.apache.org by GitBox <gi...@apache.org> on 2022/09/24 10:42:47 UTC

[GitHub] [ozone] chungen0126 opened a new pull request, #3777: HDDS-7219. Ozone bucket list for links displays default layout for al…

chungen0126 opened a new pull request, #3777:
URL: https://github.com/apache/ozone/pull/3777

   ## What changes were proposed in this pull request?
   
   Fix the information of linked bucket, while listing buckets.
   
   ## What is the link to the Apache JIRA
   https://issues.apache.org/jira/browse/HDDS-7219?jql=project%20%3D%20HDDS%20AND%20status%20%3D%20Open%20AND%20resolution%20%3D%20Unresolved%20AND%20assignee%20in%20(EMPTY)%20ORDER%20BY%20created%20DESC%2C%20priority%20DESC%2C%20updated%20DESC
   
   ## How was this patch tested?
   
   ```
   {
     "metadata" : { },
     "volumeName" : "vol1",
     "name" : "bucket2",
     "storageType" : "DISK",
     "versioning" : false,
     "usedBytes" : 0,
     "usedNamespace" : 0,
     "creationTime" : "2022-09-22T14:35:44.912Z",
     "modificationTime" : "2022-09-22T14:35:44.912Z",
     "quotaInBytes" : -1,
     "quotaInNamespace" : -1,
     "bucketLayout" : "LEGACY",
     "owner" : "leechungen",
     "link" : false
   }
   {
     "volumeName" : "vol1",
     "bucketName" : "bucket3",
     "sourceVolume" : "vol1",
     "sourceBucket" : "bucket1",
     "creationTime" : "2022-09-22T14:37:03.207Z",
     "modificationTime" : "2022-09-22T14:37:03.207Z",
     "owner" : "leechungen"
   }
   ```
   


-- 
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: issues-unsubscribe@ozone.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@ozone.apache.org
For additional commands, e-mail: issues-help@ozone.apache.org


[GitHub] [ozone] adoroszlai commented on a diff in pull request #3777: HDDS-7219. Ozone bucket list for links displays default layout for all linked buckets

Posted by GitBox <gi...@apache.org>.
adoroszlai commented on code in PR #3777:
URL: https://github.com/apache/ozone/pull/3777#discussion_r985589271


##########
hadoop-ozone/tools/src/main/java/org/apache/hadoop/ozone/shell/bucket/ListBucketHandler.java:
##########
@@ -50,9 +52,17 @@ 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());
-
+    List<Object> bucketList = new ArrayList<>();
+    while (bucketIterator.hasNext()) {

Review Comment:
   Please keep `limit > counter` from earlier version of the patch.  Limiting the size of the list while it is being populated is better than while printing it.
   
   (Sorry, I was going to make this comment in previous round of review, but somehow forgot to submit.)



-- 
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: issues-unsubscribe@ozone.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@ozone.apache.org
For additional commands, e-mail: issues-help@ozone.apache.org


[GitHub] [ozone] adoroszlai commented on a diff in pull request #3777: HDDS-7219. Ozone bucket list for links displays default layout for all linked buckets

Posted by GitBox <gi...@apache.org>.
adoroszlai commented on code in PR #3777:
URL: https://github.com/apache/ozone/pull/3777#discussion_r979439540


##########
hadoop-ozone/tools/src/main/java/org/apache/hadoop/ozone/shell/bucket/ListBucketHandler.java:
##########
@@ -51,7 +51,18 @@ protected void execute(OzoneClient client, OzoneAddress address)
     Iterator<? extends OzoneBucket> bucketIterator =
         vol.listBuckets(listOptions.getPrefix(), listOptions.getStartItem());
 
-    int counter = printAsJsonArray(bucketIterator, listOptions.getLimit());
+    int counter = 0;
+    printMsg("[");
+    while (bucketIterator.hasNext() && counter < listOptions.getLimit()) {
+      OzoneBucket entry = bucketIterator.next();
+      if (entry.getSourceBucket() != null && entry.getSourceVolume() != null) {
+        printObjectAsJson(new InfoBucketHandler.LinkBucket(entry));
+      } else {
+        printObjectAsJson(entry);
+      }
+      counter++;
+    }
+    printMsg("]");

Review Comment:
   I don't think this is outputs a valid json list, as items are not separated by comma (`,`).
   
   Instead of manually printing each item and trying to imitate a list, I think it would be better to replace link items with `LinkBucket` objects in-place, and let `printAsJsonArray` do the rest.



-- 
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: issues-unsubscribe@ozone.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@ozone.apache.org
For additional commands, e-mail: issues-help@ozone.apache.org


[GitHub] [ozone] adoroszlai commented on a diff in pull request #3777: HDDS-7219. Ozone bucket list for links displays default layout for all linked buckets

Posted by GitBox <gi...@apache.org>.
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: issues-unsubscribe@ozone.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@ozone.apache.org
For additional commands, e-mail: issues-help@ozone.apache.org


[GitHub] [ozone] sadanand48 commented on a diff in pull request #3777: HDDS-7219. Ozone bucket list for links displays default layout for all linked buckets

Posted by GitBox <gi...@apache.org>.
sadanand48 commented on code in PR #3777:
URL: https://github.com/apache/ozone/pull/3777#discussion_r979284786


##########
hadoop-ozone/tools/src/main/java/org/apache/hadoop/ozone/shell/bucket/ListBucketHandler.java:
##########
@@ -51,12 +52,72 @@ protected void execute(OzoneClient client, OzoneAddress address)
     Iterator<? extends OzoneBucket> bucketIterator =
         vol.listBuckets(listOptions.getPrefix(), listOptions.getStartItem());
 
-    int counter = printAsJsonArray(bucketIterator, listOptions.getLimit());
+    int counter = 0;
+    while (bucketIterator.hasNext() && counter < listOptions.getLimit()) {
+      OzoneBucket entry = bucketIterator.next();
+      if (entry.getSourceBucket() != null && entry.getSourceVolume() != null) {
+        printObjectAsJson(new LinkBucket(entry));
+      } else {
+        printObjectAsJson(entry);
+      }
+      counter++;
+    }
 
     if (isVerbose()) {
       out().printf("Found : %d buckets for volume : %s ", counter, volumeName);
     }
   }
 
+  /**
+   * Class used for link buckets.
+   */
+  private static class LinkBucket {

Review Comment:
   We can avoid duplicating the class from InfoBucketHandler.



-- 
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: issues-unsubscribe@ozone.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@ozone.apache.org
For additional commands, e-mail: issues-help@ozone.apache.org