You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@ratis.apache.org by GitBox <gi...@apache.org> on 2022/07/07 18:33:38 UTC

[GitHub] [ratis] szetszwo commented on a diff in pull request #667: RATIS-1609. RaftStorageImpl should not lock the directory in the constructor.

szetszwo commented on code in PR #667:
URL: https://github.com/apache/ratis/pull/667#discussion_r916171229


##########
ratis-server/src/main/java/org/apache/ratis/server/storage/RaftStorageImpl.java:
##########
@@ -38,30 +37,35 @@ public class RaftStorageImpl implements RaftStorage {
 
   // TODO support multiple storage directories
   private final RaftStorageDirectoryImpl storageDir;
-  private final StorageState state;
+  private final StartupOption startupOption;
   private final CorruptionPolicy logCorruptionPolicy;
+  private volatile StorageState state = StorageState.UNINITIALIZED;
   private volatile RaftStorageMetadataFileImpl metaFile;
 
   RaftStorageImpl(File dir, CorruptionPolicy logCorruptionPolicy, StartupOption option,
-      long storageFeeSpaceMin) throws IOException {
+      long storageFeeSpaceMin) {
     this.storageDir = new RaftStorageDirectoryImpl(dir, storageFeeSpaceMin);
-    if (option == StartupOption.FORMAT) {
+    this.logCorruptionPolicy = Optional.ofNullable(logCorruptionPolicy).orElseGet(CorruptionPolicy::getDefault);
+    this.startupOption = option;
+  }
+
+  @Override
+  public void initialize() throws IOException {

Review Comment:
   @lokeshj1703 , That's is a good idea!  Thanks.



-- 
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: issues-unsubscribe@ratis.apache.org

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