-
Notifications
You must be signed in to change notification settings - Fork 439
RATIS-2281. Make LogSegmentStartEnd getStartIndex and getEndIndex public #1321
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
base: master
Are you sure you want to change the base?
Conversation
|
@errose28 I am not too sure of the use case, do you think this change suffices? Or did the ticket mean to add new methods to |
|
@devabhishekpal , let's make sure how the methods are going to be used before changing them. |
errose28
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.
I added a comment on the Jira and linked it to the Ozone task for context. We will need a follow-up task in Ozone to migrate our debug tool to use this new API when our Ratis version is updated.
|
@szetszwo could you take a look as well? |
|
I think about this change. It seems not a good idea to simple changing the methods to public and let other projects using it. We should have some kind of APIs. I wonder if the we could move the RaftLog tool from Ozone to Ratis? As a workaround, Ozone could add a RaftLogUtils class in the org.apache.ratis.server.raftlog.segmented package for accessing the package private methods in the meantime. (Something similar to https://github.com/apache/ozone/blob/master/hadoop-hdds/common/src/main/java/com/google/protobuf/ProtoUtils.java ) |
|
Hmm, seems like a good long term plan. Maybe other projects dependent on RATIS can also use such tools. |
|
@szetszwo by ratis log tool you are referring to the OM Ratis log repair tool? |
The class is already public so it is part of the API. We are not changing arbitrary methods to public either. The class is named
This might be possible but the implementation may look strange. The tool is to replace the message contents of one raft log entry with a different type of message/content which is specific to Ozone. An implementation in Ratis that takes a byte string to replace the log entry with could be used for this. However I don't see how adding a low level mutator to the public API is less harmful than two read-only methods in an already public class.
I'd rather not do a hack like this if we have the above two options available. |
For servers, only the classes in ratis-server-api are public APIs. Public classes in ratis-server are not.
If the tool is in Ratis, it could let the applications such as Ozone pass a function for doing the replacement. Note that if the tool is in Ratis, it can access the private API in its implementation.
It is easier to define a public tool API than a public server API. In this case, if LogSegmentStartEnd is a public server API, it means that we have to support such segment files forever. Then, it limits the flexibility of the underlying implementation (e.g. RATIS-2370 SegmentedRaftLog v2). |
I agree this would probably be the best thing long term. We can file a Jira for this and migrate Ozone when it is ready. In the mean time I think we can keep using the regex workaround to identify log segments rather than the private package approach. Should we close this PR? |
|
Sure, let's close this. Thanks for your understanding. |
What changes were proposed in this pull request?
We are changing the visibility of
LogSegmentStartEnd#getStartIndex()andLogSegmentStartEnd#getEndIndex()to public.This will allow external tools that deal with the RATIS log, to directly make changes to it.
What is the link to the Apache JIRA
https://issues.apache.org/jira/browse/RATIS-2281
How was this patch tested?
Patch was tested using unit tests