hemantk-12 commented on code in PR #4573:
URL: https://github.com/apache/ozone/pull/4573#discussion_r1174210553
##########
hadoop-ozone/client/src/main/java/org/apache/hadoop/ozone/client/OzoneVolume.java:
##########
@@ -365,7 +365,25 @@ public Iterator<? extends OzoneBucket> listBuckets(String
bucketPrefix) {
*/
public Iterator<? extends OzoneBucket> listBuckets(String bucketPrefix,
String prevBucket) {
- return new BucketIterator(bucketPrefix, prevBucket);
+ return listBuckets(bucketPrefix, prevBucket, false);
+ }
+
+ /**
+ * Returns Iterator to iterate over all buckets after prevBucket in the
Review Comment:
```suggestion
* Returns Iterator to iterate over all buckets after prevBucket in the
* volum's snapshotted buckets.
```
##########
hadoop-ozone/client/src/main/java/org/apache/hadoop/ozone/client/protocol/ClientProtocol.java:
##########
@@ -295,11 +295,13 @@ OzoneBucket getBucketDetails(String volumeName, String
bucketName)
* @param bucketPrefix Bucket prefix to match
* @param prevBucket Starting point of the list, this bucket is excluded
* @param maxListResult Max number of buckets to return.
+ * @param isSnapshot Set the flag to list the buckets which have snapshot.
Review Comment:
```suggestion
* @param isSnapshot flag to list the buckets which have snapshot.
```
##########
hadoop-ozone/common/src/main/java/org/apache/hadoop/ozone/om/protocol/OzoneManagerProtocol.java:
##########
@@ -382,11 +382,14 @@ default void deleteBucket(String volume, String bucket)
throws IOException {
* @param maxNumOfBuckets
* the maximum number of buckets to return. It ensures
* the size of the result will not exceed this limit.
+ * @param isSnapshot
+ * set the flag to list bucket which have snapshots.
Review Comment:
```suggestion
* flag to list bucket which have snapshots.
```
##########
hadoop-ozone/ozone-manager/src/main/java/org/apache/hadoop/ozone/om/OmMetadataManagerImpl.java:
##########
@@ -1108,8 +1111,14 @@ public List<OmBucketInfo> listBuckets(final String
volumeName,
// We should return only the keys, whose keys match with prefix and
// the keys after the startBucket.
if (key.startsWith(seekPrefix) && key.compareTo(startKey) >= 0) {
- result.add(omBucketInfo);
- currentCount++;
+ if (isSnapshot && !listSnapshot(
Review Comment:
```suggestion
if (isSnapshot) {
if (!listSnapshot(volumeName, omBucketInfo.getBucketName())
.isEmpty()) {
result.add(omBucketInfo);
currentCount++;
}
} else {
result.add(omBucketInfo);
currentCount++;
}
```
Also you can extract out snapshot check to `containsSnapshot()`
```
if (isSnapshot) {
if (containsSnapshot()) {
result.add(omBucketInfo);
currentCount++;
}
} else {
result.add(omBucketInfo);
currentCount++;
}
```
##########
hadoop-ozone/client/src/main/java/org/apache/hadoop/ozone/client/OzoneVolume.java:
##########
@@ -365,7 +365,25 @@ public Iterator<? extends OzoneBucket> listBuckets(String
bucketPrefix) {
*/
public Iterator<? extends OzoneBucket> listBuckets(String bucketPrefix,
String prevBucket) {
- return new BucketIterator(bucketPrefix, prevBucket);
+ return listBuckets(bucketPrefix, prevBucket, false);
+ }
+
+ /**
+ * Returns Iterator to iterate over all buckets after prevBucket in the
+ * volume.
+ * If prevBucket is null it iterates from the first bucket in the volume.
+ * The result can be restricted using bucket prefix, will return all
+ * buckets if bucket prefix is null.
+ *
+ * @param bucketPrefix Bucket prefix to match
+ * @param prevBucket Buckets are listed after this bucket
+ * @param isSnapshot Set the flag to list the buckets which have snapshot
+ * @return {@code Iterator<OzoneBucket>}
+ */
+ public Iterator<? extends OzoneBucket> listBuckets(String bucketPrefix,
+ String prevBucket,
+ boolean isSnapshot) {
Review Comment:
nit: I don't think that `isSnapshot` is a good name here. May be
`listSnapshot` or `onlySnapshot` would be better in my opinion.
--
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: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]