You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@ratis.apache.org by GitBox <gi...@apache.org> on 2020/12/23 12:27:23 UTC

[GitHub] [incubator-ratis] runzhiwang removed a comment on pull request #372: RATIS-1260. Implement transferLeaderShip in server

runzhiwang removed a comment on pull request #372:
URL: https://github.com/apache/incubator-ratis/pull/372#issuecomment-750245608


   > Let's add new TransferLeadership class and put all the code there.
   
   @szetszwo Do I need to put the following check code in TransferLeadership class ? if so, I need to change some method from private to publibc, such as `checkLeaderState`
   
   ```
        CompletableFuture<RaftClientReply> reply = checkLeaderState(request, null, false);
         if (reply != null) {
           return reply;
         }
   
         if (getId().equals(request.getNewLeader())) {
           return CompletableFuture.completedFuture(newSuccessReply(request));
         }
   
         final RaftConfigurationImpl conf = getRaftConf();
         final LeaderStateImpl leaderState = role.getLeaderStateNonNull();
   
      
         if (!conf.isStable() || leaderState.inStagingState() || !state.isConfCommitted()) {
           String msg = getMemberId() + " refused to transfer leadership to peer " + request.getNewLeader() +
               " when raft reconfiguration in progress.";
           return logAndReturnTransferLeadershipFail(request, msg);
         }
   
         if (!conf.containsInConf(request.getNewLeader())) {
           String msg = getMemberId() + " refused to transfer leadership to peer " + request.getNewLeader() +
               " as it is not in " + conf;
           return logAndReturnTransferLeadershipFail(request, msg);
         }
   
         if (!conf.isHighestPriority(request.getNewLeader())) {
           String msg = getMemberId() + " refused to transfer leadership to peer " + request.getNewLeader() +
               " as it does not has highest priority " + conf;
           return logAndReturnTransferLeadershipFail(request, msg);
         }
   
   ```


----------------------------------------------------------------
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:
users@infra.apache.org