szetszwo commented on PR #1589: URL: https://github.com/apache/ratis/pull/1589#issuecomment-5727953177
@ivandika3 , @amaliujia , thanks for working on this! Sorry for checking this late. I do have some comments on the new public APIs - I suggest to make the new method more general by adding an enum. - Then, we could also clean up the code in RaftServerImpl; see https://issues.apache.org/jira/secure/attachment/13084585/1589_review.patch ```java //RaftServer.Division /** @return the current leadership status of this division. */ LeadershipStatus getLeadershipStatus(); /** * Convert the given leadership status (not necessarily the current status) to an exception. * * @return For {@link LeadershipStatus#LEADER_READY}, return null. * Otherwise, return an exception corresponding to {@link LeadershipStatus#getExceptionClass()}. */ RaftException newLeadershipException(LeadershipStatus leadershipStatus); ``` ```java //RaftServer enum LeadershipStatus { /** The division is a leader and it is ready. */ LEADER_READY(null), /** The division is a leader, but it is NOT ready. */ LEADER_NOT_READY(LeaderNotReadyException.class), /** The division is a leader, but it is stepping down. */ LEADER_STEPPING_DOWN(LeaderSteppingDownException.class), /** The division is NOT a leader; */ NOT_LEADER(NotLeaderException.class); private final Class<? extends RaftException> exceptionClass; LeadershipStatus(Class<? extends RaftException> exceptionClass) { this.exceptionClass = exceptionClass; } /** * @return For {@link #LEADER_READY}, return null. * Otherwise, return the corresponding exception class. */ public Class<? extends RaftException> getExceptionClass() { return exceptionClass; } } ``` -- 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]
