Control ports

Control ports are operator input ports that receive tuples that update the internal operator state. These ports do not generate output tuples through submit() calls. Control ports are useful to dynamically control the behavior of the operator by changing a filtering condition, for example.

Operator control ports often consume streams that are generated by other operators downstream, effectively configuring a loop in the application flow graph. By configuring an input port as a control port, the developer informs the Streams Processing Language (SPL) compiler that possible feedback loops using this port are safe. That is, they do not lead to deadlocks or stack overflow due to infinite recursion. Infinite recursion occurs when operators with feedback loops are fused; when the operator submits a tuple to its output port, the subsequent submit() calls lead to a loop of other submit() calls, effectively overflowing the call stack. By default, the SPL compiler assumes that a declared input port is a data port, not a control port.

When you develop a primitive operator that contains control ports, declare data ports first and control ports second. An example is the Gate operator from the SPL Standard Toolkit. In this operator, the first port is a data port, and the second port is a control port. Consider this code sample that shows a segment of the Gate operator model, where the second input port is configured as control (line 16).

01: <inputPorts>
02:  <inputPortSet>
03:    <description>Port that ingests tuples to be gated</description>
04:    <tupleMutationAllowed>false</tupleMutationAllowed>
05:    <windowingMode>NonWindowed</windowingMode>
06:    <windowPunctuationInputMode>Oblivious</windowPunctuationInputMode>
07:    <cardinality>1</cardinality>
08:    <optional>false</optional>
09:   </inputPortSet>
10:   <inputPortSet>
11:     <description>Port that ingests tuples
12:         controlling the gate</description>   
13:     <tupleMutationAllowed>false</tupleMutationAllowed>
14:     <windowingMode>NonWindowed</windowingMode>
15:     <windowPunctuationInputMode>Oblivious</windowPunctuationInputMode>
16:     <controlPort>true</controlPort>
17:     <cardinality>1</cardinality>
18:     <optional>false</optional>
19:   </inputPortSet>
20: </inputPorts>