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


##########
ratis-server/src/main/java/org/apache/ratis/server/impl/RaftServerImpl.java:
##########
@@ -1496,10 +1452,25 @@ Optional<FollowerState> 
updateLastRpcTime(FollowerState.UpdateType updateType) {
     }
   }
 
-  private long updateCommitInfoCache() {
+  long updateCommitInfoCache() {
     return commitInfoCache.update(getId(), 
state.getLog().getLastCommittedIndex());
   }
 
+  CommitInfoCache getCommitInfoCache() {
+    return commitInfoCache;
+  }
+
+  boolean isStartComplete() {
+    return startComplete.get();
+  }
+
+  /** If the life cycle is STARTING, transition it to RUNNING and start the 
follower state. */
+  void startFollowerStateIfStarting(Object reason) {
+    if (lifeCycle.compareAndTransition(State.STARTING, State.RUNNING)) {
+      role.startFollowerState(this, reason);
+    }
+  }

Review Comment:
   Let's pass `isFollowerInitializing`.  It is easier to understand the 
if-condition when initializing ad compareAndTransition are together.
   ```java
     void startFollowerState(boolean isFollowerInitializing) {
       if (!isFollowerInitializing && 
lifeCycle.compareAndTransition(State.STARTING, State.RUNNING)) {
         // the follower has caught up (i.e. not initializing).  If it is not 
already RUNNING, start it up. 
         role.startFollowerState(this, Op.APPEND_ENTRIES);
       }
     }
   ```



##########
ratis-server/src/main/java/org/apache/ratis/server/impl/RaftServerImpl.java:
##########
@@ -1496,10 +1452,25 @@ Optional<FollowerState> 
updateLastRpcTime(FollowerState.UpdateType updateType) {
     }
   }
 
-  private long updateCommitInfoCache() {
+  long updateCommitInfoCache() {
     return commitInfoCache.update(getId(), 
state.getLog().getLastCommittedIndex());
   }
 
+  CommitInfoCache getCommitInfoCache() {
+    return commitInfoCache;
+  }

Review Comment:
   Let's change it to updateCommitInfoCache(..).  Then, we don't have to expose 
commitInfoCache.
   ```java
     void updateCommitInfoCache(List<CommitInfoProto> commitInfos) {
       commitInfos.forEach(commitInfoCache::update);
     }
   ```



##########
ratis-server/src/main/java/org/apache/ratis/server/impl/RaftServerImpl.java:
##########
@@ -1496,10 +1452,25 @@ Optional<FollowerState> 
updateLastRpcTime(FollowerState.UpdateType updateType) {
     }
   }
 
-  private long updateCommitInfoCache() {
+  long updateCommitInfoCache() {
     return commitInfoCache.update(getId(), 
state.getLog().getLastCommittedIndex());
   }
 
+  CommitInfoCache getCommitInfoCache() {
+    return commitInfoCache;
+  }
+
+  boolean isStartComplete() {
+    return startComplete.get();
+  }

Review Comment:
   Let's check it in the beginning  of appendEntriesAsync(..).  Then, we don't 
need this new method.
   ```java
   //RaftServerImpl
     @Override
     public CompletableFuture<AppendEntriesReplyProto> 
appendEntriesAsync(AppendEntriesRequestProto r)
         throws IOException {
       if (!startComplete.get()) {
         throw new ServerNotReadyException(getMemberId() + ": The server role 
is not yet initialized.");
       }
       return appendEntriesHandler.appendEntriesAsync(r);
     }
   ```



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