szetszwo commented on code in PR #1647:
URL: https://github.com/apache/ratis/pull/1647#discussion_r4363121278
##########
ratis-server/src/main/java/org/apache/ratis/server/impl/RaftServerImpl.java:
##########
@@ -604,14 +613,14 @@ private void closeImpl(Throwable cause) {
failure = e;
throw e;
} finally {
- completeClose(failure);
+ completeClose(failure, allServers);
}
}
- private void completeClose(Throwable cause) {
+ private void completeClose(Throwable cause, boolean allServers) {
lifeCycle.transitionIfNotEqual(State.CLOSED);
if (cause == null) {
- closeFuture.complete(null);
+ closeFuture.complete(allServers);
} else {
closeFuture.completeExceptionally(cause);
}
Review Comment:
Good catch on the problem!
The closeFuture was newly added by RATIS-2645. For simplicity, let's keep
the current change.
##########
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:
We actually need to implement it in order to preserve the existing behavior:
```java
default void notifyServerShutdown(RoleInfoProto roleInfo, boolean
allServers, EventStatus eventStatus) {
// preserve the existing behavior
if (eventStatus == EventStatus.COMPLETED) {
notifyServerShutdown(roleInfo, allServers);
}
}
```
--
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]