szetszwo commented on code in PR #652:
URL: https://github.com/apache/ratis/pull/652#discussion_r891622724
##########
ratis-server/src/main/java/org/apache/ratis/server/storage/RaftStorageImpl.java:
##########
@@ -41,6 +41,41 @@ public enum StartupOption {
FORMAT
}
+ public static Builder newBuilder() {
+ return new RaftStorageImpl.Builder();
+ }
+
+ public static class Builder {
Review Comment:
The Builder should be moved to RaftStorage so that it will be in
raft-server-api.
##########
ratis-server/src/main/java/org/apache/ratis/server/storage/RaftStorageImpl.java:
##########
@@ -41,6 +41,41 @@ public enum StartupOption {
FORMAT
}
+ public static Builder newBuilder() {
+ return new RaftStorageImpl.Builder();
+ }
+
+ public static class Builder {
+ private File dir;
+ private CorruptionPolicy logCorruptionPolicy;
+ private StartupOption option;
+ private long storageFeeSpaceMin;
+
+ public Builder setDir(File dir) {
+ this.dir = dir;
+ return this;
+ }
+
+ public Builder setLogCorruptionPolicy(CorruptionPolicy
logCorruptionPolicy) {
+ this.logCorruptionPolicy = logCorruptionPolicy;
+ return this;
+ }
+
+ public Builder setOption(StartupOption option) {
+ this.option = option;
+ return this;
+ }
+
+ public Builder setStorageFeeSpaceMin(long storageFeeSpaceMin) {
Review Comment:
Let's call it setFreeSpaceMin. BTW, there is a TYPO: "Fee" should "Free".
Also, let's use SizeInBytes for the parameter.
##########
ratis-server/src/main/java/org/apache/ratis/server/storage/RaftStorageImpl.java:
##########
@@ -41,6 +41,41 @@ public enum StartupOption {
FORMAT
}
+ public static Builder newBuilder() {
+ return new RaftStorageImpl.Builder();
+ }
+
+ public static class Builder {
+ private File dir;
+ private CorruptionPolicy logCorruptionPolicy;
+ private StartupOption option;
+ private long storageFeeSpaceMin;
+
+ public Builder setDir(File dir) {
+ this.dir = dir;
+ return this;
+ }
+
+ public Builder setLogCorruptionPolicy(CorruptionPolicy
logCorruptionPolicy) {
+ this.logCorruptionPolicy = logCorruptionPolicy;
+ return this;
+ }
+
+ public Builder setOption(StartupOption option) {
+ this.option = option;
+ return this;
+ }
+
+ public Builder setStorageFeeSpaceMin(long storageFeeSpaceMin) {
+ this.storageFeeSpaceMin = storageFeeSpaceMin;
+ return this;
+ }
+
+ public RaftStorageImpl build() throws IOException {
+ return new RaftStorageImpl(dir, logCorruptionPolicy, option,
storageFeeSpaceMin);
Review Comment:
After moved to raft-server-api, we have to use reflection to call the
constructor. See RaftServer.Builder as an example.
##########
ratis-server/src/main/java/org/apache/ratis/server/storage/RaftStorageImpl.java:
##########
@@ -41,6 +41,41 @@ public enum StartupOption {
FORMAT
}
+ public static Builder newBuilder() {
+ return new RaftStorageImpl.Builder();
+ }
+
+ public static class Builder {
+ private File dir;
+ private CorruptionPolicy logCorruptionPolicy;
+ private StartupOption option;
+ private long storageFeeSpaceMin;
+
+ public Builder setDir(File dir) {
+ this.dir = dir;
+ return this;
+ }
+
+ public Builder setLogCorruptionPolicy(CorruptionPolicy
logCorruptionPolicy) {
+ this.logCorruptionPolicy = logCorruptionPolicy;
+ return this;
+ }
+
+ public Builder setOption(StartupOption option) {
Review Comment:
We should move StartupOption from RaftStorageImpl to RaftStorage so that it
becomes a public API.
Also, let's add a new StartupOption.RECOVER instead of using null.
##########
ratis-server/src/main/java/org/apache/ratis/server/storage/RaftStorageImpl.java:
##########
@@ -41,6 +41,41 @@ public enum StartupOption {
FORMAT
}
+ public static Builder newBuilder() {
+ return new RaftStorageImpl.Builder();
+ }
+
+ public static class Builder {
+ private File dir;
+ private CorruptionPolicy logCorruptionPolicy;
+ private StartupOption option;
+ private long storageFeeSpaceMin;
+
+ public Builder setDir(File dir) {
Review Comment:
Let's rename it to setDirectory.
--
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]