szetszwo commented on code in PR #1143:
URL: https://github.com/apache/ratis/pull/1143#discussion_r1742353981


##########
ratis-server/src/main/java/org/apache/ratis/server/impl/LeaderElection.java:
##########
@@ -234,12 +234,17 @@ LifeCycle.State getCurrentState() {
 
   @Override
   public void run() {
+    if (server.initializing()) {
+        LOG.info("{}: skip running since the server is initializing", this);
+        return;
+    }
     if (!lifeCycle.compareAndTransition(STARTING, RUNNING)) {
       final LifeCycle.State state = lifeCycle.getCurrentState();
       LOG.info("{}: skip running since this is already {}", this, state);
       return;
     }
 
+

Review Comment:
   Please revert this whitespace change.



##########
ratis-server/src/main/java/org/apache/ratis/server/impl/RaftServerImpl.java:
##########
@@ -1513,6 +1513,10 @@ public CompletableFuture<AppendEntriesReplyProto> 
appendEntriesAsync(
     }
   }
 
+  public boolean initializing() {
+    return !startComplete.get();
+  }

Review Comment:
   Let's check also the `lifeCycle`.  Also, remove `public`.
   ```java
     boolean isRunning() {
       return startComplete.get() && lifeCycle.getCurrentState() == 
State.RUNNING;
     }
   ```



##########
ratis-server/src/main/java/org/apache/ratis/server/impl/LeaderElection.java:
##########
@@ -234,12 +234,17 @@ LifeCycle.State getCurrentState() {
 
   @Override
   public void run() {
+    if (server.initializing()) {
+        LOG.info("{}: skip running since the server is initializing", this);

Review Comment:
   Update the message after changing the if-condition.



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

To unsubscribe, e-mail: [email protected]

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

Reply via email to