com.ibm.streamsx.plumbing > shedders 1.0.0 > com.ibm.streamsx.plumbing.sample.shedding > RandomShedderSample.spl
public composite RandomShedderSample
{
graph
() as JCP = JobControlPlane()
{
}
// DataFlow with controlled load shedding
@spl_category(name = "data")
() as DF = DataFlow()
{
}
// Flow that controls DataFlow
// Note they are not connected using streams,
// only indirectly through the control mechanisms
// provided by JobControlPlane
@spl_note(id = "0", text =
"Flow that controls DataFlow by changing the shedding fraction every 30 seconds.")
@spl_category(name = "control")
() as CF = ControlFlow()
{
}
}
Sample application that can be used to demonstrate recovery from failure for com.ibm.streamsx.plumbing.shedders::RandomLoadShedder.
A single change is made to shed tuples in the data flow after 30 seconds to some random fraction >= 0.2.
The failure modes that can be manually tested are:
In each case com.ibm.streamsx.plumbing.shedders::RandomLoadShedder reverts to the shedding fraction set by the control flow, and the current fraction can be seen through the sheddingFraction metric, in tuples per million shed.
public composite RandomShedderFailureSample {
graph
() as JCP = JobControlPlane() {}
// DataFlow with controlled load shedding
@spl_category(name = "data")
() as DF = DataFlow()
{
}
stream<float64 fraction> Control = Beacon()
{
param
initDelay: 30.0;
iterations: 1u;
output
Control : fraction = random() + 0.2;
}
() as ChangeShedding = Custom(Control)
{
logic
state :
{
boolean __unused = registerRandomShedder("sampleShedder") ;
}
onTuple Control :
{
setRandomShedderFraction("sampleShedder", fraction) ;
}
}
}