org.apache.flink.streaming.examples.statemachine.event.Alert Java Examples
The following examples show how to use
org.apache.flink.streaming.examples.statemachine.event.Alert.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: StateMachineExample.java From Flink-CEPplus with Apache License 2.0 | 6 votes |
@Override public void flatMap(Event evt, Collector<Alert> out) throws Exception { // get the current state for the key (source address) // if no state exists, yet, the state must be the state machine's initial state State state = currentState.value(); if (state == null) { state = State.Initial; } // ask the state machine what state we should go to based on the given event State nextState = state.transition(evt.type()); if (nextState == State.InvalidTransition) { // the current event resulted in an invalid transition // raise an alert! out.collect(new Alert(evt.sourceAddress(), state, evt.type())); } else if (nextState.isTerminal()) { // we reached a terminal state, clean up the current state currentState.clear(); } else { // remember the new state currentState.update(nextState); } }
Example #2
Source File: StateMachineExample.java From flink with Apache License 2.0 | 6 votes |
@Override public void flatMap(Event evt, Collector<Alert> out) throws Exception { // get the current state for the key (source address) // if no state exists, yet, the state must be the state machine's initial state State state = currentState.value(); if (state == null) { state = State.Initial; } // ask the state machine what state we should go to based on the given event State nextState = state.transition(evt.type()); if (nextState == State.InvalidTransition) { // the current event resulted in an invalid transition // raise an alert! out.collect(new Alert(evt.sourceAddress(), state, evt.type())); } else if (nextState.isTerminal()) { // we reached a terminal state, clean up the current state currentState.clear(); } else { // remember the new state currentState.update(nextState); } }
Example #3
Source File: StateMachineExample.java From flink with Apache License 2.0 | 6 votes |
@Override public void flatMap(Event evt, Collector<Alert> out) throws Exception { // get the current state for the key (source address) // if no state exists, yet, the state must be the state machine's initial state State state = currentState.value(); if (state == null) { state = State.Initial; } // ask the state machine what state we should go to based on the given event State nextState = state.transition(evt.type()); if (nextState == State.InvalidTransition) { // the current event resulted in an invalid transition // raise an alert! out.collect(new Alert(evt.sourceAddress(), state, evt.type())); } else if (nextState.isTerminal()) { // we reached a terminal state, clean up the current state currentState.clear(); } else { // remember the new state currentState.update(nextState); } }