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 2019/12/16 21:43:08 UTC

[GitHub] [hadoop-ozone] cxorm commented on a change in pull request #261: HDDS-2610. Fix the ObjectStore#listVolumes failure when argument is null

cxorm commented on a change in pull request #261: HDDS-2610. Fix the ObjectStore#listVolumes failure when argument is null
URL: https://github.com/apache/hadoop-ozone/pull/261#discussion_r358480646
 
 

 ##########
 File path: hadoop-ozone/ozone-manager/src/main/java/org/apache/hadoop/ozone/om/OmMetadataManagerImpl.java
 ##########
 @@ -805,51 +805,73 @@ public boolean isBucketEmpty(String volume, String bucket)
     return deletedKeys;
   }
 
+  /**
+   * @param userName volume owner, null for listing all volumes.
+   * @throws IOException
+   */
   @Override
   public List<OmVolumeArgs> listVolumes(String userName,
       String prefix, String startKey, int maxKeys) throws IOException {
     List<OmVolumeArgs> result = Lists.newArrayList();
-    UserVolumeInfo volumes;
+    List<UserVolumeInfo> volumes = Lists.newArrayList();
+
     if (StringUtil.isBlank(userName)) {
-      throw new OMException("User name is required to list Volumes.",
-          ResultCodes.USER_NOT_FOUND);
+      // null userName represents listing all volumes in cluster.
+      for (String user : getAllUsers()) {
+        volumes.add(getVolumesByUser(user));
+      }
+    } else {
+      volumes.add(getVolumesByUser(userName));
     }
-    volumes = getVolumesByUser(userName);
 
-    if (volumes == null || volumes.getVolumeNamesCount() == 0) {
+    if (volumes.size() == 0) {
       return result;
     }
 
     boolean startKeyFound = Strings.isNullOrEmpty(startKey);
-    for (String volumeName : volumes.getVolumeNamesList()) {
-      if (!Strings.isNullOrEmpty(prefix)) {
-        if (!volumeName.startsWith(prefix)) {
-          continue;
+    for (UserVolumeInfo volInfo : volumes) {
 
 Review comment:
   Thanks @bharatviswa504 for the review.
   I handle the ```listAllVolumes``` separately, and updated.
   UT ran well.

----------------------------------------------------------------
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.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

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