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


##########
ratis-server-api/src/main/java/org/apache/ratis/statemachine/StateMachine.java:
##########
@@ -229,20 +234,39 @@ default void notifyLogFailed(Throwable cause, 
LogEntryProto failedEntry) {}
     default void notifySnapshotInstalled(InstallSnapshotResult result, long 
snapshotIndex,  RaftPeer peer) {}
 
     /**
-     * Notify the {@link StateMachine} that the server for this division has 
been shut down.
-     * @deprecated please use/override {@link 
#notifyServerShutdown(RoleInfoProto, boolean)} instead
+     * The same as notifyServerShutdown(roleInfo, false, 
EventStatus.COMPLETED).
+     *
+     * @deprecated please use/override {@link 
#notifyServerShutdown(RoleInfoProto, boolean, EventStatus)} instead
      */
     @Deprecated
     default void notifyServerShutdown(RoleInfoProto roleInfo) {
-      notifyServerShutdown(roleInfo, false);
+      notifyServerShutdown(roleInfo, false, EventStatus.COMPLETED);
+    }
+
+    /**
+     * The same as notifyServerShutdown(roleInfo, allServers, 
EventStatus.COMPLETED).
+     *
+     * @deprecated please use/override {@link 
#notifyServerShutdown(RoleInfoProto, boolean, EventStatus)} instead
+     */
+    @Deprecated
+    default void notifyServerShutdown(RoleInfoProto roleInfo, boolean 
allServers) {
+      notifyServerShutdown(roleInfo, allServers, EventStatus.COMPLETED);
     }
 
     /**
-     * Notify the {@link StateMachine} that either the server for this 
division or all the servers have been shut down.
+     * Notify the {@link StateMachine} server shutdown.
+     * <p>
+     * {@link EventStatus#INITIATED} is notified before the shutdown has 
closed any resources,
+     * in particular, before waiting for the committed log entries to be 
applied to this {@link StateMachine},
+     * which is unbounded in time.  An implementation must return promptly for 
{@link EventStatus#INITIATED}.
+     * <p>
+     * {@link EventStatus#COMPLETED} is notified after the shutdown has 
completed.
+     *
      * @param roleInfo roleInfo this server
-     * @param allServer whether all raft servers will be shutdown at this time
+     * @param allServers whether all raft servers will be shutdown at this time
+     * @param eventStatus {@link EventStatus#INITIATED} or {@link 
EventStatus#COMPLETED}
      */
-    default void notifyServerShutdown(RoleInfoProto roleInfo, boolean 
allServer) {}
+    default void notifyServerShutdown(RoleInfoProto roleInfo, boolean 
allServers, EventStatus eventStatus) {}

Review Comment:
   > Ah actually I guess the complete solution is this...
   
   Agree.
   
   > ...  if a user calls notifyServerShutdown(roleInfo, allServers), ...
   
   The notification methods should only be called by Ratis but not the users.
   
   - BTW, when we add the allServers parameter, we should implement it the 
other way as below.  Let's also fix it here.
   ```java
       default void notifyServerShutdown(RoleInfoProto roleInfo) {}
   
       default void notifyServerShutdown(RoleInfoProto roleInfo, boolean 
allServers) {
         notifyServerShutdown(roleInfo);
       }
   ```
   
   - Let's also change the javadoc: "please use/override" -> "please override". 
 It is more clear.



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