hemantk-12 commented on code in PR #4692:
URL: https://github.com/apache/ozone/pull/4692#discussion_r1190451980


##########
hadoop-ozone/ozone-manager/src/main/java/org/apache/hadoop/ozone/om/OmSnapshotManager.java:
##########
@@ -295,47 +295,57 @@ private CacheLoader<String, OmSnapshot> 
createCacheLoader() {
       // load the snapshot into the cache if not already there
       @Nonnull
       public OmSnapshot load(@Nonnull String snapshotTableKey)
-          throws IOException {
-        // see if the snapshot exists
-        SnapshotInfo snapshotInfo = getSnapshotInfo(snapshotTableKey);
-
-        // Block snapshot from loading when it is no longer active e.g. 
DELETED,
-        // unless this is called from SnapshotDeletingService.
-        checkSnapshotActive(snapshotInfo);
-
-        CacheValue<SnapshotInfo> cacheValue =
-            ozoneManager.getMetadataManager().getSnapshotInfoTable()
-                .getCacheValue(new CacheKey<>(snapshotTableKey));
-        boolean isSnapshotInCache = cacheValue != null && Optional.ofNullable(
-            cacheValue.getCacheValue()).isPresent();
-
-        // read in the snapshot
-        OzoneConfiguration conf = ozoneManager.getConfiguration();
-        OMMetadataManager snapshotMetadataManager;
-
-        // Create the snapshot metadata manager by finding the corresponding
-        // RocksDB instance, creating an OmMetadataManagerImpl instance based 
on
-        // that
+          throws Exception {
+        OMMetadataManager snapshotMetadataManager = null;
         try {
-          snapshotMetadataManager = new OmMetadataManagerImpl(conf,
-              snapshotInfo.getCheckpointDirName(), isSnapshotInCache);
-        } catch (IOException e) {
-          LOG.error("Failed to retrieve snapshot: {}", snapshotTableKey);
-          throw e;
+          // see if the snapshot exists
+          SnapshotInfo snapshotInfo = getSnapshotInfo(snapshotTableKey);
+
+          // Block snapshot from loading when it is no longer active
+          // e.g. DELETED, unless this is called from SnapshotDeletingService.
+          checkSnapshotActive(snapshotInfo);
+
+          CacheValue<SnapshotInfo> cacheValue =
+              ozoneManager.getMetadataManager().getSnapshotInfoTable()
+                  .getCacheValue(new CacheKey<>(snapshotTableKey));
+          boolean isSnapshotInCache = cacheValue != null && 
Optional.ofNullable(
+              cacheValue.getCacheValue()).isPresent();
+
+          // read in the snapshot
+          OzoneConfiguration conf = ozoneManager.getConfiguration();
+
+          // Create the snapshot metadata manager by finding the corresponding
+          // RocksDB instance, creating an OmMetadataManagerImpl instance based
+          // on that.
+          try {
+            snapshotMetadataManager = new OmMetadataManagerImpl(conf,
+                snapshotInfo.getCheckpointDirName(), isSnapshotInCache);
+          } catch (IOException e) {
+            LOG.error("Failed to retrieve snapshot: {}", snapshotTableKey);
+            throw e;
+          }
+
+          // create the other manager instances based on snapshot
+          // metadataManager
+          PrefixManagerImpl pm = new PrefixManagerImpl(snapshotMetadataManager,
+              false);
+          KeyManagerImpl km = new KeyManagerImpl(null,
+              ozoneManager.getScmClient(), snapshotMetadataManager, conf,
+              ozoneManager.getBlockTokenSecretManager(),
+              ozoneManager.getKmsProvider(), ozoneManager.getPerfMetrics());
+
+          return new OmSnapshot(km, pm, ozoneManager,
+              snapshotInfo.getVolumeName(),
+              snapshotInfo.getBucketName(),
+              snapshotInfo.getName());
+        } catch (Exception e) {

Review Comment:
   This can't be `IOException` so changed it back to `Exception` after 
refactoring code a little bit.



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