szetszwo commented on code in PR #640:
URL: https://github.com/apache/ratis/pull/640#discussion_r867345606
##########
ratis-server-api/src/main/java/org/apache/ratis/server/DivisionInfo.java:
##########
@@ -51,6 +52,10 @@ default boolean isListener() {
/** Is this server division currently the leader and ready? */
boolean isLeaderReady();
+ /** @return the current leader of this server division, null means either
there is
+ * no leader for this term yet or this server division does not know who it
is yet */
+ RaftPeer getCurrentLeader();
Review Comment:
Let's return RaftPeerId so that it is more efficient? When RaftPeer is
needed, we may call RaftServer.getRaftConf() to get it.
```
/**
* @return the id of the current leader if the leader is known to this
server division;
* otherwise, return null.
*/
RaftPeerId getLeaderId();
```
##########
ratis-server/src/main/java/org/apache/ratis/server/impl/RaftServerImpl.java:
##########
@@ -113,9 +113,14 @@ public boolean isLeaderReady() {
return isLeader() && getRole().isLeaderReady();
}
+ @Override
+ public RaftPeer getCurrentLeader() {
+ return getRaftConf().getPeer(getState().getLeaderId());
+ }
+
@Override
public LifeCycle.State getLifeCycleState() {
- return lifeCycle.getCurrentState();
+ return getLifeCycle().getCurrentState();
Review Comment:
Please revert this and the following unrelated changes.
--
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]