-
Notifications
You must be signed in to change notification settings - Fork 440
RATIS-1588. Add a builder of RaftStorageImpl #652
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
|
@szetszwo Can you help review this pull request, thanks! |
|
@codings-dan , sorry that it broke Alluxio. RaftStorageImpl is not a public API so that we do not have to maintain compatibility. We may consider adding a RaftStorage.Builder as a public API. BTW, this is backward compatibility -- a new version of the software works for the existing applications. Forward compatibility means the current design of the software can work on future applications. |
1 similar comment
|
@codings-dan , sorry that it broke Alluxio. RaftStorageImpl is not a public API so that we do not have to maintain compatibility. We may consider adding a RaftStorage.Builder as a public API. BTW, this is backward compatibility -- a new version of the software works for the existing applications. Forward compatibility means the current design of the software can work on future applications. |
Good idea, I will add a RaftStorage.Builder.
Thanks for telling me about these, I now understand the difference! |
|
@szetszwo I have added a RaftStorage.Builder, PTAL again, thx! |
szetszwo
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@codings-dan , thanks for the update! Some comments inlined.
| return new RaftStorageImpl.Builder(); | ||
| } | ||
|
|
||
| public static class Builder { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The Builder should be moved to RaftStorage so that it will be in raft-server-api.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
| private StartupOption option; | ||
| private long storageFeeSpaceMin; | ||
|
|
||
| public Builder setDir(File dir) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's rename it to setDirectory.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
| return this; | ||
| } | ||
|
|
||
| public Builder setOption(StartupOption option) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
| } | ||
|
|
||
| public RaftStorageImpl build() throws IOException { | ||
| return new RaftStorageImpl(dir, logCorruptionPolicy, option, storageFeeSpaceMin); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
After moved to raft-server-api, we have to use reflection to call the constructor. See RaftServer.Builder as an example.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
| return this; | ||
| } | ||
|
|
||
| public Builder setStorageFeeSpaceMin(long storageFeeSpaceMin) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's call it setFreeSpaceMin. BTW, there is a TYPO: "Fee" should "Free".
Also, let's use SizeInBytes for the parameter.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
|
@szetszwo PTAL again, thank you! |
szetszwo
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
+1 the change looks good.
|
@codings-dan , The test failure seems related. Could you take a look? BTW, let's remove the public RaftStorageImpl constructor below since it is no longer used. Also, let's use SizeInBytes for storageFreeSpaceMin? Or, we may have two setStorageFreeSpaceMin methods. |
This is caused by improper handling of exceptions in reflection,I have fixed it.
I have remove the extra code.
Done. |
|
@szetszwo Thanks for help review the code, PTAL, thx! |
|
@codings-dan , thanks for the update. TestRaftStorage failed. Please take a look. |
Similar to the previous ut error, it was caused by improper handling of exceptions in reflection, I have fixed it |
|
The ci test error seems have noting to do with this code change. https://github.com/apache/ratis/runs/6930404226?check_suite_focus=true#step:5:611 |
|
Sure, let's restart the failed jobs. |
|
#635 should be able to reduce the timeout problem. @codings-dan , could you review it? |
Of course, happy to help review the code! |
(cherry picked from commit 995dce9)

see https://issues.apache.org/jira/projects/RATIS/issues/RATIS-1588