Event graph
Creation of multiple event paths
Introduction
The goal is to create many unique execution paths where a node is invoked only if it is on the active execution path.
The @OnEvent annotation marks a method to be included in the execution graph as per the event pipeline description. In this case we want to create a graph containing multiple execution paths. The uniqueness of an execution path is defined as the compound value of event type and filter value.
For Fluxtion ESC there is no difference between a graph and a pipeline, the use of processing inference determines what the structure is. Similarly for the programmer there is no change in the annotations used, only the creation of a rich object model in the builder is required. Once an object graph is provided to Fluxtion it will generate a SEP with multiple execution paths.
Example
This example creates a processing graph using the builder below. The Combiner node has multiple parents and is on a separate path to the pipeline/child nodes for incoming events of type MyEvent. This described network has multiple execution paths in the execution graph.
The code for the graph example is located here.
SEPConfig builder class
public class Builder extends SEPConfig {
@Override
public void buildConfig() {
DataEventHandler sharedHandler = addNode(new DataEventHandler());
PipelineNode node = addNode(new PipelineNode(sharedHandler));
ChildNode childNode = addNode(new ChildNode(node));
MyEventHandler myHandler = addNode(new MyEventHandler());
CombinerNode combiner = addNode(new CombinerNode(myHandler, sharedHandler));
}
}
Generated SEP
The generated SEP creates a dispatch method for each incoming event, each with its own unique execution path.
public class SampleProcessor implements EventHandler, BatchHandler, Lifecycle {
//Node declarations
private final DataEventHandler dataEventHandler_1 = new DataEventHandler();
private final MyEventHandler myEventHandler_7 = new MyEventHandler();
private final CombinerNode combinerNode_9 =
new CombinerNode(myEventHandler_7, dataEventHandler_1);
private final PipelineNode pipelineNode_3 = new PipelineNode(dataEventHandler_1);
private final ChildNode childNode_5 = new ChildNode(pipelineNode_3);
//code omitted for clarity
public void handleEvent(DataEvent typedEvent) {
//Default, no filter methods
dataEventHandler_1.handleEvent(typedEvent);
combinerNode_9.update();
pipelineNode_3.update();
childNode_5.recalculate();
//event stack unwind callbacks
afterEvent();
}
public void handleEvent(MyEvent typedEvent) {
//Default, no filter methods
myEventHandler_7.handleEvent(typedEvent);
combinerNode_9.update();
//event stack unwind callbacks
afterEvent();
}
}
Generated png
The graphical representation of this execution graph as generated by Fluxtion ESC:

Last updated
Was this helpful?