hemantk-12 commented on code in PR #4436:
URL: https://github.com/apache/ozone/pull/4436#discussion_r1142796852
##########
hadoop-ozone/ozone-manager/src/main/java/org/apache/hadoop/ozone/om/request/OMClientRequestUtils.java:
##########
@@ -47,4 +60,40 @@ public static void checkClientRequestPrecondition(
OMException.ResultCodes.INTERNAL_ERROR);
}
}
+
+ public static boolean isSnapshotBucket(OMMetadataManager omMetadataManager,
+ OmKeyInfo keyInfo) throws IOException {
+
+ boolean status;
+ TableIterator<String, ? extends Table.KeyValue<String, SnapshotInfo>>
+ iterator = omMetadataManager.getSnapshotInfoTable().iterator();
+ String dbSnapshotBucketKey = omMetadataManager.getBucketKey(
+ keyInfo.getVolumeName(), keyInfo.getBucketName())
+ + OM_KEY_PREFIX;
+
+ iterator.seek(dbSnapshotBucketKey);
+ status = iterator.hasNext() && iterator.next().getKey()
Review Comment:
Curious if we need to check the volume and bucket in case of legacy bucket
type. Similar to
https://github.com/apache/ozone/blob/master/hadoop-ozone/ozone-manager/src/main/java/org/apache/hadoop/ozone/om/KeyManagerImpl.java#L1240
##########
hadoop-ozone/ozone-manager/src/main/java/org/apache/hadoop/ozone/om/OmMetadataManagerImpl.java:
##########
@@ -648,9 +645,9 @@ protected void initializeOmTables(boolean addCacheMetrics)
String.class, SnapshotInfo.class);
checkTableStatus(snapshotInfoTable, SNAPSHOT_INFO_TABLE, addCacheMetrics);
- // objectID -> renamedKeys (renamed keys for key table)
+ // objectID -> renamed Key (renamed key for key table)
Review Comment:
```suggestion
// objectID -> renamedKey (renamed key for key table)
```
##########
hadoop-ozone/ozone-manager/src/main/java/org/apache/hadoop/ozone/om/request/OMClientRequestUtils.java:
##########
@@ -47,4 +60,40 @@ public static void checkClientRequestPrecondition(
OMException.ResultCodes.INTERNAL_ERROR);
}
}
+
+ public static boolean isSnapshotBucket(OMMetadataManager omMetadataManager,
+ OmKeyInfo keyInfo) throws IOException {
+
+ boolean status;
+ TableIterator<String, ? extends Table.KeyValue<String, SnapshotInfo>>
+ iterator = omMetadataManager.getSnapshotInfoTable().iterator();
+ String dbSnapshotBucketKey = omMetadataManager.getBucketKey(
+ keyInfo.getVolumeName(), keyInfo.getBucketName())
+ + OM_KEY_PREFIX;
+
+ iterator.seek(dbSnapshotBucketKey);
+ status = iterator.hasNext() && iterator.next().getKey()
+ .startsWith(dbSnapshotBucketKey);
+
+ return status || checkSnapshotCache(omMetadataManager, keyInfo);
Review Comment:
Shouldn't we check cache first and then DB?
Like:
```
return checkSnapshotCache(omMetadataManager, keyInfo) ||
checkSnapshotInDB(omMetadataManager, keyInfo);
```
##########
hadoop-ozone/ozone-manager/src/main/java/org/apache/hadoop/ozone/om/request/OMClientRequestUtils.java:
##########
@@ -47,4 +60,40 @@ public static void checkClientRequestPrecondition(
OMException.ResultCodes.INTERNAL_ERROR);
}
}
+
+ public static boolean isSnapshotBucket(OMMetadataManager omMetadataManager,
+ OmKeyInfo keyInfo) throws IOException {
+
+ boolean status;
+ TableIterator<String, ? extends Table.KeyValue<String, SnapshotInfo>>
+ iterator = omMetadataManager.getSnapshotInfoTable().iterator();
+ String dbSnapshotBucketKey = omMetadataManager.getBucketKey(
+ keyInfo.getVolumeName(), keyInfo.getBucketName())
+ + OM_KEY_PREFIX;
+
+ iterator.seek(dbSnapshotBucketKey);
+ status = iterator.hasNext() && iterator.next().getKey()
+ .startsWith(dbSnapshotBucketKey);
+
+ return status || checkSnapshotCache(omMetadataManager, keyInfo);
+ }
+
+ private static boolean checkSnapshotCache(OMMetadataManager
omMetadataManager,
Review Comment:
```suggestion
private static boolean checkSnapshotInCache(OMMetadataManager
omMetadataManager,
OmKeyInfo keyInfo)
```
Or `checkInSnapshotCache` whatever is more relevant. `checkSnapshotCache` is
vague to me.
##########
hadoop-ozone/ozone-manager/src/main/java/org/apache/hadoop/ozone/om/request/OMClientRequestUtils.java:
##########
@@ -47,4 +60,40 @@ public static void checkClientRequestPrecondition(
OMException.ResultCodes.INTERNAL_ERROR);
}
}
+
+ public static boolean isSnapshotBucket(OMMetadataManager omMetadataManager,
+ OmKeyInfo keyInfo) throws IOException {
+
+ boolean status;
+ TableIterator<String, ? extends Table.KeyValue<String, SnapshotInfo>>
Review Comment:
Close the iterator after the use.
--
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]