Cyrill commented on code in PR #6135:
URL: https://github.com/apache/ozone/pull/6135#discussion_r1477888372


##########
hadoop-ozone/ozone-manager/src/main/java/org/apache/hadoop/ozone/om/OmSnapshotManager.java:
##########
@@ -603,31 +624,64 @@ public ReferenceCounted<IOmMetadataReader, SnapshotCache> 
checkForSnapshot(
     String[] keyParts = keyName.split(OM_KEY_PREFIX);
     if (isSnapshotKey(keyParts)) {
       String snapshotName = keyParts[1];
-      if (snapshotName == null || snapshotName.isEmpty()) {
-        // don't allow snapshot indicator without snapshot name
-        throw new OMException(INVALID_KEY_NAME);
-      }
-      String snapshotTableKey = SnapshotInfo.getTableKey(volumeName,
-          bucketName, snapshotName);
 
-      // Block FS API reads when snapshot is not active.
-      if (!skipActiveCheck) {
-        checkSnapshotActive(ozoneManager, snapshotTableKey);
-      }
-
-      // Warn if actual cache size exceeds the soft limit already.
-      if (snapshotCache.size() > softCacheSize) {
-        LOG.warn("Snapshot cache size ({}) exceeds configured soft-limit 
({}).",
-            snapshotCache.size(), softCacheSize);
-      }
-
-      // retrieve the snapshot from the cache
-      return snapshotCache.get(snapshotTableKey, skipActiveCheck);
+      return (ReferenceCounted<IOmMetadataReader, SnapshotCache>) 
(ReferenceCounted<?, ?>)
+          getActiveSnapshot(volumeName, bucketName, snapshotName);
     } else {
       return ozoneManager.getOmMetadataReader();
     }
   }
 
+  public ReferenceCounted<OmSnapshot, SnapshotCache> getActiveSnapshot(
+      String volumeName,
+      String bucketName,
+      String snapshotName) throws IOException {
+    return getSnapshot(volumeName, bucketName, snapshotName, false);
+  }
+
+  public ReferenceCounted<OmSnapshot, SnapshotCache> getSnapshot(
+      String volumeName,
+      String bucketName,
+      String snapshotName) throws IOException {
+    return getSnapshot(volumeName, bucketName, snapshotName, true);
+  }
+
+  private ReferenceCounted<OmSnapshot, SnapshotCache> getSnapshot(
+      String volumeName,
+      String bucketName,
+      String snapshotName,
+      boolean skipActiveCheck) throws IOException {
+
+    if (snapshotName == null || snapshotName.isEmpty()) {
+      // don't allow snapshot indicator without snapshot name
+      throw new OMException(INVALID_KEY_NAME);
+    }
+
+    String snapshotTableKey = SnapshotInfo.getTableKey(volumeName,
+        bucketName, snapshotName);
+
+    return getSnapshot(snapshotTableKey, skipActiveCheck);
+  }
+
+  private ReferenceCounted<OmSnapshot, SnapshotCache> getSnapshot(
+      String snapshotTableKey,
+      boolean skipActiveCheck) throws IOException {
+
+    // Block FS API reads when snapshot is not active.
+    if (!skipActiveCheck) {
+      checkSnapshotActive(ozoneManager, snapshotTableKey);
+    }
+
+    // Warn if actual cache size exceeds the soft limit already.
+    if (snapshotCache.size() > softCacheSize) {
+      LOG.warn("Snapshot cache size ({}) exceeds configured soft-limit ({}).",
+          snapshotCache.size(), softCacheSize);
+    }

Review Comment:
   Done



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

Reply via email to