Repository: incubator-ratis
Updated Branches:
  refs/heads/master 39916f231 -> f7dea20f1


RATIS-366. In StateMachineUpdater, the stopIndex should use Long. Contributed 
by Tsz Wo Nicholas Sze.


Project: http://git-wip-us.apache.org/repos/asf/incubator-ratis/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-ratis/commit/f7dea20f
Tree: http://git-wip-us.apache.org/repos/asf/incubator-ratis/tree/f7dea20f
Diff: http://git-wip-us.apache.org/repos/asf/incubator-ratis/diff/f7dea20f

Branch: refs/heads/master
Commit: f7dea20f19a7432b32cedda0fa4b8e7bd648ee66
Parents: 39916f2
Author: Jitendra Pandey <[email protected]>
Authored: Mon Oct 22 11:26:44 2018 -0700
Committer: Jitendra Pandey <[email protected]>
Committed: Mon Oct 22 11:26:44 2018 -0700

----------------------------------------------------------------------
 .../org/apache/ratis/server/impl/StateMachineUpdater.java | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-ratis/blob/f7dea20f/ratis-server/src/main/java/org/apache/ratis/server/impl/StateMachineUpdater.java
----------------------------------------------------------------------
diff --git 
a/ratis-server/src/main/java/org/apache/ratis/server/impl/StateMachineUpdater.java
 
b/ratis-server/src/main/java/org/apache/ratis/server/impl/StateMachineUpdater.java
index d0b7947..d00e19a 100644
--- 
a/ratis-server/src/main/java/org/apache/ratis/server/impl/StateMachineUpdater.java
+++ 
b/ratis-server/src/main/java/org/apache/ratis/server/impl/StateMachineUpdater.java
@@ -44,7 +44,7 @@ import java.util.concurrent.CompletableFuture;
  */
 class StateMachineUpdater implements Runnable {
   static final Logger LOG = LoggerFactory.getLogger(StateMachineUpdater.class);
-  private volatile long stopIndex = -1;
+  private volatile Long stopIndex = null;
 
   enum State {
     RUNNING, STOP, RELOAD
@@ -100,13 +100,13 @@ class StateMachineUpdater implements Runnable {
    *
    * @throws InterruptedException
    */
-  public void stopAndJoin()
-      throws InterruptedException {
-    if (stopIndex == -1) {
+  void stopAndJoin() throws InterruptedException {
+    if (stopIndex == null) {
       synchronized (this) {
         this.stopIndex = raftLog.getLastCommittedIndex();
         notifyUpdater();
       }
+      LOG.info("{}: set stopIndex = {}", this, stopIndex);
     }
     updater.join();
   }
@@ -210,7 +210,7 @@ class StateMachineUpdater implements Runnable {
   }
 
   private boolean shouldStop() {
-    return stopIndex > -1 && getLastAppliedIndex() >= stopIndex;
+    return stopIndex != null && getLastAppliedIndex() >= stopIndex;
   }
 
   private boolean shouldTakeSnapshot() {

Reply via email to