-
Notifications
You must be signed in to change notification settings - Fork 587
HDDS-2779. Fix list volume for --start parameter #385
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 2 commits
a40d61a
03bcf0c
df0aeae
39dec1a
4e7a7f3
1925ffb
4c1adfc
7eda1a0
8691191
f7719ab
bde3976
f7be6cb
1958f45
33c52b3
d5dac4e
76bd8c2
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -815,34 +815,55 @@ public List<OmVolumeArgs> listVolumes(String userName, | |
| } | ||
| volumes = getVolumesByUser(userName); | ||
|
|
||
| if (volumes == null || volumes.getVolumeNamesCount() == 0) { | ||
| if (volumes.getVolumeNamesCount() == 0) { | ||
| return result; | ||
| } | ||
|
|
||
| /* Process listing volumes with startVolume. */ | ||
| boolean startKeyFound = Strings.isNullOrEmpty(startKey); | ||
| if (!startKeyFound) { | ||
| OmVolumeArgs startVolArgs = getVolumeTable() | ||
|
||
| .get(this.getVolumeKey(startKey)); | ||
|
|
||
| if (startVolArgs == null) { | ||
| throw new OMException("StartVolume info not found for " + startKey, | ||
| ResultCodes.VOLUME_NOT_FOUND); | ||
| } else if (!startKey.startsWith(prefix)) { | ||
|
||
| throw new OMException("StartVolume " + startKey + " not found" + | ||
| " for prefix " + prefix, ResultCodes.VOLUME_NOT_FOUND); | ||
| } | ||
|
|
||
| result.add(startVolArgs); | ||
| } | ||
|
|
||
| OmVolumeArgs volumeArgs; | ||
| for (String volumeName : volumes.getVolumeNamesList()) { | ||
|
|
||
| if (!Strings.isNullOrEmpty(prefix)) { | ||
| if (!volumeName.startsWith(prefix)) { | ||
| continue; | ||
| } | ||
| } | ||
|
|
||
| volumeArgs = getVolumeTable().get(this.getVolumeKey(volumeName)); | ||
| if (volumeArgs == null) { | ||
| // Could not get volume info by given volume name, | ||
| // since the volume name is loaded from db, | ||
| // this probably means om db is corrupted or some entries are | ||
| // accidentally removed. | ||
| throw new OMException("Volume info not found for " + volumeName, | ||
| ResultCodes.VOLUME_NOT_FOUND); | ||
| } | ||
|
|
||
| if (!startKeyFound && volumeName.equals(startKey)) { | ||
| startKeyFound = true; | ||
| continue; | ||
| } | ||
| if (startKeyFound && result.size() < maxKeys) { | ||
| OmVolumeArgs volumeArgs = | ||
| getVolumeTable().get(this.getVolumeKey(volumeName)); | ||
| if (volumeArgs == null) { | ||
| // Could not get volume info by given volume name, | ||
| // since the volume name is loaded from db, | ||
| // this probably means om db is corrupted or some entries are | ||
| // accidentally removed. | ||
| throw new OMException("Volume info not found for " + volumeName, | ||
| ResultCodes.VOLUME_NOT_FOUND); | ||
| } | ||
|
|
||
| if (result.size() < maxKeys) { | ||
| result.add(volumeArgs); | ||
| } else { | ||
| break; | ||
| } | ||
| } | ||
|
|
||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Without this logic, remote iteration will not work. Removing this will break the
listVolumecall if we try to list more than 1000 (ozone.client.list.cache) volumes.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @nandakumar131 for this important info.
I deleted the block cause it would lead infinitely loop when I test
listVolumeson my cluster.I'm going to fix it. (without deleting it.)
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed with checking existed volume.
And work well in listing more than 1000 volumes with the same user.