bharatviswa504 commented on a change in pull request #300:
URL: https://github.com/apache/incubator-ratis/pull/300#discussion_r530715499



##########
File path: 
ratis-server/src/main/java/org/apache/ratis/server/impl/RaftServerImpl.java
##########
@@ -593,6 +593,30 @@ public boolean isLeaderReady() {
     return true;
   }
 
+  /**
+   * Return status of the RaftServer.
+   * @return LeaderStatus
+   */
+  public ServerStatus getServerStatus() {

Review comment:
       One reason is in OM HA we want to check isLeader and isLeaderReady and 
these are implemented as below.
   
   
     public boolean isLeader() {
       Preconditions.checkState(server instanceof RaftServerProxy);
       RaftServerImpl serverImpl = null;
       try {
         serverImpl = ((RaftServerProxy) server).getImpl(raftGroupId);
         if (serverImpl != null) {
           return serverImpl.isLeader();
         }
       } catch (IOException ioe) {
         // In this case we return not a leader.
         LOG.error("Fail to get RaftServer impl and therefore it's not clear " +
             "whether it's leader. ", ioe);
       }
       return false;
     }
   
     /**
      * Return true, if the current OM node is leader and in ready state to
      * process the requests.
      * @return
      */
     public boolean isLeaderReady() {
       Preconditions.checkState(server instanceof RaftServerProxy);
       RaftServerImpl serverImpl = null;
       try {
         serverImpl = ((RaftServerProxy) server).getImpl(raftGroupId);
         if (serverImpl != null) {
           return serverImpl.isLeaderReady();
         }
       } catch (IOException ioe) {
         // In this case we return not a leader.
         LOG.error("Fail to get RaftServer impl and therefore it's not clear " +
             "whether it's leader. ", ioe);
       }
       return false;
     }
   
   With this new API, we can call the new API and know when it is NOT_LEADER, 
LEADER_AND_READY and LEADER_AND_NOT_READY




----------------------------------------------------------------
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.

For queries about this service, please contact Infrastructure at:
[email protected]


Reply via email to