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 2020/01/03 12:08:13 UTC

[GitHub] [hadoop-ozone] nandakumar131 commented on a change in pull request #385: HDDS-2779. Fix list volume for --start parameter

nandakumar131 commented on a change in pull request #385: HDDS-2779. Fix list volume for --start parameter
URL: https://github.com/apache/hadoop-ozone/pull/385#discussion_r362787945
 
 

 ##########
 File path: hadoop-ozone/ozone-manager/src/main/java/org/apache/hadoop/ozone/om/OmMetadataManagerImpl.java
 ##########
 @@ -807,33 +807,30 @@ public boolean isBucketEmpty(String volume, String bucket)
   @Override
   public List<OmVolumeArgs> listVolumes(String userName,
       String prefix, String startKey, int maxKeys) throws IOException {
-    List<OmVolumeArgs> result = Lists.newArrayList();
-    UserVolumeInfo volumes;
+
     if (StringUtil.isBlank(userName)) {
       throw new OMException("User name is required to list Volumes.",
           ResultCodes.USER_NOT_FOUND);
     }
-    volumes = getVolumesByUser(userName);
 
-    if (volumes == null || volumes.getVolumeNamesCount() == 0) {
-      return result;
-    }
+    final List<OmVolumeArgs> result = Lists.newArrayList();
+    final List<String> volumes = getVolumesByUser(userName)
+        .getVolumeNamesList();
 
-    boolean startKeyFound = Strings.isNullOrEmpty(startKey);
-    for (String volumeName : volumes.getVolumeNamesList()) {
-      if (!Strings.isNullOrEmpty(prefix)) {
-        if (!volumeName.startsWith(prefix)) {
-          continue;
-        }
-      }
+    int index = 0;
+    if (!Strings.isNullOrEmpty(startKey)) {
+      index = volumes.indexOf(
+          startKey.startsWith(OzoneConsts.OM_KEY_PREFIX) ?
+          startKey.substring(1) :
+          startKey);
 
 Review comment:
   Add `index = index != -1 ? index + 1 : index;` at line 826 to make sure that the `startKey` is not part of the returned result.

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