You are viewing a plain text version of this content. The canonical link for it is here.
Posted to reviews@iotdb.apache.org by GitBox <gi...@apache.org> on 2022/08/19 06:24:30 UTC

[GitHub] [iotdb] JackieTien97 commented on a diff in pull request #7056: [IOTDB-4027] Support cross disk link in RatisConsensus

JackieTien97 commented on code in PR #7056:
URL: https://github.com/apache/iotdb/pull/7056#discussion_r949839168


##########
consensus/src/main/java/org/apache/iotdb/consensus/ratis/SnapshotStorage.java:
##########
@@ -141,8 +142,14 @@ public SnapshotInfo getLatestSnapshot() {
     }
     TermIndex snapshotTermIndex = Utils.getTermIndexFromDir(latestSnapshotDir);
 
+    List<File> actualSnapshotFiles = applicationStateMachine.getSnapshotFiles(latestSnapshotDir);
+    List<Path> filesIncludedInSnapshot =
+        actualSnapshotFiles != null
+            ? actualSnapshotFiles.stream().map(File::toPath).collect(Collectors.toList())
+            : getAllFilesUnder(latestSnapshotDir);
+

Review Comment:
   Can we put all these logics into `applicationStateMachine.getSnapshotFiles`, in that method we encapsulate all details about where to get the snapshot files, from logFile or just listing files in a directory. In fact, I find that there already exists such logics in `DataRegionStateMachine.getSnapshotFiles`.
   
   BTW, you can change the interface to directly return `List<Path>` instead of `List<File>`.



##########
consensus/src/main/java/org/apache/iotdb/consensus/ratis/SnapshotStorage.java:
##########
@@ -141,8 +142,14 @@ public SnapshotInfo getLatestSnapshot() {
     }
     TermIndex snapshotTermIndex = Utils.getTermIndexFromDir(latestSnapshotDir);
 
+    List<File> actualSnapshotFiles = applicationStateMachine.getSnapshotFiles(latestSnapshotDir);
+    List<Path> filesIncludedInSnapshot =
+        actualSnapshotFiles != null
+            ? actualSnapshotFiles.stream().map(File::toPath).collect(Collectors.toList())
+            : getAllFilesUnder(latestSnapshotDir);
+

Review Comment:
   Can we put all these logics into `applicationStateMachine.getSnapshotFiles`, in that method we encapsulate all details about where to get the snapshot files, from logFile or just listing files in a directory. In fact, I find that there already exists such logics in `DataRegionStateMachine.getSnapshotFiles`.
   
   BTW, you can change the interface to directly return `List<Path>` instead of `List<File>`.



-- 
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: reviews-unsubscribe@iotdb.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org