use of org.apache.flink.runtime.messages.RequiresLeaderSessionID in project flink by apache.
the class FlinkUntypedActor method handleLeaderSessionID.
/**
* This method filters out {@link LeaderSessionMessage} whose leader session ID is not equal
* to the actors leader session ID. If a message of type {@link RequiresLeaderSessionID}
* arrives, then an Exception is thrown, because these messages have to be wrapped in a
* {@link LeaderSessionMessage}.
*
* @param message Incoming message
* @throws Exception
*/
private void handleLeaderSessionID(Object message) throws Exception {
if (message instanceof LeaderSessionMessage) {
LeaderSessionMessage msg = (LeaderSessionMessage) message;
UUID expectedID = getLeaderSessionID();
UUID actualID = msg.leaderSessionID();
if (expectedID == actualID || (expectedID != null && expectedID.equals(actualID))) {
handleMessage(msg.message());
} else {
handleDiscardedMessage(expectedID, msg);
}
} else if (message instanceof RequiresLeaderSessionID) {
throw new Exception("Received a message " + message + " without a leader session " + "ID, even though the message requires a leader session ID.");
} else {
// call method to handle message
handleMessage(message);
}
}
Aggregations