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:
[email protected]


With regards,
Apache Git Services

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to