StefanRRichter 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_r255883742
##########
File path:
flink-runtime/src/main/java/org/apache/flink/runtime/rpc/akka/AkkaRpcActor.java
##########
@@ -183,6 +177,69 @@ 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) {
Review comment:
I think a more OO approach to this would be to define a state machine over
the possible states that has the set of valid transitions and will log
validations if trying to perform an invalid transition. This would also give an
explicit description of the valid transitions and the mental model behind it.
The set of possible states here is rather small, but I observed a similar
"problem" in the execution graph where the set of states and their transitions
is more complex. I feel like this is a more maintainable and readable approach.
----------------------------------------------------------------
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