com.ibm.streamsx.plumbing > com.ibm.streamsx.plumbing 1.0.0 > com.ibm.streamsx.plumbing.shedders > exprshedder.spl
Controllable load shedder that sheds (drops) tuples based upon evaluating an expression. Tuple that are not shed are copied from the input port to the output port without modification. Punctuation marks are always forwarded from In to Out.
This operator creates a boolean control variable named name. Initially the variable is set to false which means no tuples will be shed. If the variable is changed to true then tuples will be shed. The selection of tuples to shed is defined by expr. If
The control variable may be shared across multiple invocations of ExpreessionLoadShedder, by invoking them with the same value for name. name is scoped to the job.
The shedding mode is changed by calling the function setExpressionShedderMode(rstring, boolean) from any operator in same job. Thus the logic that determines the shedding mode does not define a stream connection to this operator, instead the Job Control Plane, through the the control variable, provides the control mechanism. When the job is first submitted the shedding mode is set to false, so no tuples will be shed. Upon any failure, the shedding is maintained by the control variable.
Java primitive operators may also change the shedding mode by modifying the control variable using functionality in the com.ibm.streams.operator.control.variable package.
Multiple ExpressionLoadShedder operator may share the same control variable, by being invoked with the same value for the name parameter.
Any application that invokes this operator must include a single invocation of the spl.control::JobControlPlane operator.
public composite ExpressionLoadShedder(input In ; output Out) { param expression<rstring> $name ; expression<boolean> $expr ; graph (stream<In> Out) as LoadShedder = Custom(In) { logic state : { rstring _name = $name; boolean __unused = __initExpressionShedder(_name) ; mutable boolean currentShed = false; } onTuple In : { boolean shed = getExpressionShedderMode(_name); if(!shed) { submit(In, Out) ; } else if (!($expr)) { submit(In, Out) ; } if (shed != currentShed) { setCustomMetricValue("shedding", shed ? 1l : 0l) ; currentShed = shed; } } } }
Register that an operator invocation will call setExpressionShedderMode(rstring, boolean) or getExpressionShedderMode(rstring). A sharedboolean control variable is created with name name.
This function must be called in the logic state section of any operator invocation that calls setExpressionShedderMode or getExpressionShedderMode.
public stateful boolean registerExpressionShedder(rstring name) { createBooleanControlVariable(name, true, false) ; return true ; }
Set the shedding mode for ExpressionLoadShedder operator invocations using control variable name. If shed is false, then no tuples will be shed. If shed is true then any tuple that evaluates the operator invocation's expression to true will be shed
Any operator that invokes this must call registerExpressionShedder(rstring) in its logic state section, passing the same value for name. Any operator may invoke this method to control ExpressionLoadShedder operator invocations within the same job, that were invoked with their parameter name set to name.
public stateful void setExpressionShedderMode(rstring name, boolean shed) { setBooleanControlVariable(name, shed) ; }
Get the shedding mode for ExpressionLoadShedder operator invocations using control variable name.
Any operator that invokes this must call registerExpressionShedder(rstring) in its logic state section, passing the same value for name.
public boolean getExpressionShedderMode(rstring name) { return getBooleanControlVariable(name) ; }