SPL File changeover.spl

com.ibm.streamsx.plumbing > com.ibm.streamsx.plumbing 1.0.0 > com.ibm.streamsx.plumbing.switches > changeover.spl

Content

Operators

Composites

composite Changeover(output CLOSE, OPEN; input IN, CONTROL)

Changeover switch. Changeover has the same control api as the Switch operator in the SPL standard toolkit, but delivers tuples and punctuation to a second output port OPEN when the switch is open, instead of blocking.

Parameters

Input Ports

Output Ports

SPL Source Code


 public composite Changeover (input IN, CONTROL; output CLOSE, OPEN) {
     param expression<boolean> $initialState : false; 
      expression<boolean> $status;
    graph
    (stream<IN> CLOSE; stream<IN> OPEN) as SPDT = Custom(IN ; CONTROL) {
      logic
      
      state: {mutable boolean closed = $initialState;}
      
      onTuple IN: if (closed) submit(IN, CLOSE);  else submit(IN, OPEN);
      onTuple CONTROL: closed = $status;
      onPunct IN:  if (closed) submit(currentPunct(), CLOSE); else submit(currentPunct(), OPEN);
    }
 }

   

composite ControlledChangeover(output CLOSE, OPEN; input IN)

Controlled changeover switch.

A controlled version of Changeover.

Operator invocations in the same job register an interest in controlling this switch by calling registerSwitch(rstring, boolean) passing the name of this switch. Then the state of this switch is changed by calling setSwitchState(rstring, boolean).

A boolean control variable named name is created in the Job Control Plane which provides notifications and operations to control if the switch is open or closed.

Multiple invocations of ControlledChangeover can share the same name and will then be controlled by the same control variable. Any call to setSwitchState(rstring, boolean) sets the state of all switches with the same name.

In the case of failure the state of the switch is retained by the Job Control Plane.

Any application that invokes this operator must include a single invocation of the spl.control::JobControlPlane operator.

Parameters

Input Ports

Output Ports

SPL Source Code


 public composite ControlledChangeover(input IN; output CLOSE, OPEN)
 {
    param
         expression<rstring> $name;
         expression<boolean> $initialState : false;
     graph
 
         (stream<IN> CLOSE; stream<IN> OPEN) as CtrlSPDT = Changeover(IN ; SwitchControl)
         {
             param
                 status : getSwitchState($name) ;
                 initialState: __initChangeover($name, $initialState);
             config placement: partitionColocation(getThisCompositeInstanceName());
         }
         // this issues an attribute change notification which is then
         // sent to the Changeover's control port. This will then call
         // getSwitchState() to set the switch to its correct state.
         stream<MBeanNotificationBase> SwitchControl = ControlVariableChange()
         {
             param
                 name : $name;
             config placement: partitionColocation(getThisCompositeInstanceName());
         }
 }