prashantpogde commented on code in PR #4360:
URL: https://github.com/apache/ozone/pull/4360#discussion_r1131614253


##########
hadoop-ozone/ozone-manager/src/main/java/org/apache/hadoop/ozone/om/OmSnapshotManager.java:
##########
@@ -298,27 +366,144 @@ private void verifySnapshotInfoForSnapDiff(final 
SnapshotInfo fromSnapshot,
     }
   }
 
-  private ManagedRocksDB createDbForSnapshotDiff(OzoneConfiguration config) {
-    final ManagedOptions managedOptions = new ManagedOptions();
-    managedOptions.setCreateIfMissing(true);
+  private int getIndexFromToken(final String token) throws IOException {
+    if (isBlank(token)) {
+      return 0;
+    }
+
+    // Validate that token passed in the request is valid integer as of now.
+    // Later we can change it if we migrate to encrypted or cursor token.
+    try {
+      int index = Integer.parseInt(token);
+      if (index < 0) {
+        // Throws NFE which will be transformed to IOException later.
+        throw new NumberFormatException();
+      }
+      return index;
+    } catch (NumberFormatException exception) {
+      throw new IOException("Passed token is invalid. " +
+          "Resend the request with valid token returned in previous request.");
+    }
+  }
+
+  private ManagedRocksDB createRocksDbForSnapshotDiff(
+      final ManagedDBOptions dbOptions, String dbPath,
+      final List<ColumnFamilyDescriptor> familyDescriptors,
+      final List<ColumnFamilyHandle> familyHandles
+  ) {
+    try {
+      return ManagedRocksDB.open(dbOptions,
+          dbPath,
+          familyDescriptors,
+          familyHandles);
+    } catch (RocksDBException exception) {
+      // TODO: Fail gracefully.
+      throw new RuntimeException(exception);
+    }
+  }
+
+  private String getDbPath(final OzoneConfiguration config) {
+    File dbDirPath = ServerUtils.getDBPath(config,
+        OZONE_OM_SNAPSHOT_DIFF_DB_DIR);
+    return Paths.get(dbDirPath.toString(), OM_SNAPSHOT_DIFF_DB_NAME)
+        .toFile().getAbsolutePath();
+  }
 
-    final File dbDirPath =
-        ServerUtils.getDBPath(config, OZONE_OM_SNAPSHOT_DIFF_DB_DIR);
+  private List<ColumnFamilyDescriptor> getExitingColumnFamilyDescriptors(
+      final String path) {
+    try {
+      return RocksDatabase.listColumnFamiliesEmptyOptions(path)
+          .stream()
+          .map(columnFamilyName -> new ColumnFamilyDescriptor(
+              columnFamilyName, columnFamilyOptions))
+          .collect(Collectors.toList());
+    } catch (RocksDBException exception) {
+      // TODO: Fail gracefully.

Review Comment:
   All Snapshot todos should be marked with TODO: [SNAPSHOT]



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