tillrohrmann commented on a change in pull request #7665: [FLINK-11551][rpc]
Allow RpcEndpoint to execute asynchronous stop operations
URL: https://github.com/apache/flink/pull/7665#discussion_r255961369
##########
File path:
flink-runtime/src/main/java/org/apache/flink/runtime/rpc/akka/AkkaRpcActor.java
##########
@@ -183,6 +176,64 @@ protected void handleRpcMessage(Object message) {
}
}
+ private void handleControlMessage(ControlMessages controlMessage) {
+ switch (controlMessage) {
+ case START:
+ if (state == State.STOPPED) {
+ state = State.STARTED;
+ } else {
+ logStateTransitionWarning(state,
State.STARTED);
+ }
+ break;
+ case STOP:
+ if (state == State.STARTED) {
+ state = State.STOPPED;
+ } else {
+ logStateTransitionWarning(state,
State.STOPPED);
+ }
+ break;
+ case TERMINATE:
+ terminateRpcActor();
+ break;
+ default:
+ final String message = String.format("Received
unknown control message %s. Dropping this message!", controlMessage);
+ log.warn(message);
+ sendErrorIfSender(new
AkkaUnknownMessageException(message));
+ }
+ }
+
+ private void logStateTransitionWarning(State currentState, State
targetState) {
+ log.warn("AkkaRpcActor is currently in state {} and cannot go
into state {}.", currentState, targetState);
+ }
+
+ private void terminateRpcActor() {
+ if (state == State.STOPPED) {
+ state = State.TERMINATING;
+
+ rpcEndpointTerminationFuture =
CompletableFuture.completedFuture(null);
+ getSelf().tell(Kill.getInstance(), ActorRef.noSender());
+ } else if (state == State.STARTED) {
+ state = State.TERMINATING;
+
+ mainThreadValidator.enterMainThread();
+
+ try {
+ rpcEndpointTerminationFuture =
rpcEndpoint.onStop();
+ } finally {
+ mainThreadValidator.exitMainThread();
Review comment:
I guess this should be ok, since it should indicate two independent issues.
The one is the `onStop` failure which won't be properly reported and the other
one the main thread constraint. Unless the former does not influence the
latter, I think it is ok that way.
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
With regards,
Apache Git Services