[GitHub] [hadoop-ozone] GlenGeng commented on a change in pull request #1314: HDDS-3988: DN can distinguish SCMCommand from stale leader SCM

2020-09-10 Thread GitBox


GlenGeng commented on a change in pull request #1314:
URL: https://github.com/apache/hadoop-ozone/pull/1314#discussion_r486282159



##
File path: 
hadoop-hdds/server-scm/src/test/java/org/apache/hadoop/hdds/scm/ha/MockSCMHAManager.java
##
@@ -78,8 +79,8 @@ public void start() throws IOException {
* {@inheritDoc}
*/
   @Override
-  public boolean isLeader() {
-return isLeader;
+  public Optional isLeader() {

Review comment:
   Good point. We need add a lot of test cases, including UT and acceptance 
test, before merging 2823 back to master.





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



-
To unsubscribe, e-mail: ozone-issues-unsubscr...@hadoop.apache.org
For additional commands, e-mail: ozone-issues-h...@hadoop.apache.org



[GitHub] [hadoop-ozone] GlenGeng commented on a change in pull request #1314: HDDS-3988: DN can distinguish SCMCommand from stale leader SCM

2020-09-10 Thread GitBox


GlenGeng commented on a change in pull request #1314:
URL: https://github.com/apache/hadoop-ozone/pull/1314#discussion_r486281665



##
File path: 
hadoop-hdds/container-service/src/main/java/org/apache/hadoop/ozone/container/common/statemachine/StateContext.java
##
@@ -478,7 +551,26 @@ public void execute(ExecutorService service, long time, 
TimeUnit unit)
   public SCMCommand getNextCommand() {
 lock.lock();
 try {
-  return commandQueue.poll();
+  initTermOfLeaderSCM();
+  if (!termOfLeaderSCM.isPresent()) {
+return null;  // not ready yet
+  }
+
+  while (true) {
+SCMCommand command = commandQueue.poll();
+if (command == null) {
+  return null;
+}
+
+updateTermOfLeaderSCM(command);
+if (command.getTerm() == termOfLeaderSCM.get()) {

Review comment:
   Do you mean whether `termOfLeaderSCM` is updated in leader election of 
SCM ? No, it won't. Datanode detects the latest SCM term by heartbeat with 
SCMs, whose interval is larger than 30s.





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



-
To unsubscribe, e-mail: ozone-issues-unsubscr...@hadoop.apache.org
For additional commands, e-mail: ozone-issues-h...@hadoop.apache.org