JacksonYao287 commented on a change in pull request #2229:
URL: https://github.com/apache/ozone/pull/2229#discussion_r630782616



##########
File path: 
hadoop-hdds/server-scm/src/main/java/org/apache/hadoop/hdds/scm/protocol/StorageContainerLocationProtocolServerSideTranslatorPB.java
##########
@@ -139,7 +139,7 @@ public 
StorageContainerLocationProtocolServerSideTranslatorPB(
   public ScmContainerLocationResponse submitRequest(RpcController controller,
       ScmContainerLocationRequest request) throws ServiceException {
     // not leader or not belong to admin command.
-    if (!scm.getScmContext().isLeader()
+    if (!scm.checkLeader()

Review comment:
       
   ```
     public boolean checkLeader() {
       // For NON-HA setup, the node will always be the leader
       if (!SCMHAUtils.isSCMHAEnabled(configuration)) {
         Preconditions.checkArgument(scmContext.isLeader());
         return true;
       } else {
         // FOR HA setup, the node has to be the leader and ready to serve
         // requests.
         return scmContext.isLeader() && getScmHAManager().getRatisServer()
             .getDivision().getInfo().isLeaderReady();
       }
     }
   
       public boolean isLeaderReady() {
         return this.isLeader() && 
RaftServerImpl.this.getRole().isLeaderReady();
       }
   ```
   in `checkLeader` , the above `isLeaderReady` will be called and another 
`isLeader` will be called ( not `scmcontext.isLeader()`), which is implemented 
by ratis.
   
   scmcontext.isLeader is notified and thus changed by ratis. so, maybe here we 
can just only use 
`getScmHAManager().getRatisServer().getDivision().getInfo().isLeaderReady()` to 
checkLeader(), and I think that is enough. what do you think?




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



---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to