public interface Condition<T>
at least N
tuples have been seen on the stream.
In a consistent region a condition exhibits exactly once behavior. For example
an exact tuple count
condition
placed against the stream will become valid when the tuple count is reached taking the resets into
account, even though more tuples may have been seen on the stream. This is because the
conditions are stateful and part of the consistent region.
After a region reset or failure the condition's state is reset
to the last consistent state. For example with a tuple count condition on a stream of 1,000 tuples
assume the region became consistent after 800 tuples. Subsequently a failure occurs after 950 tuples,
the region is reset, and the tuple counter condition is reset to 800 tuples. The source operator
then replays any required tuples and after another 200 tuples the condition becomes valid,
even though the stream actually processed 1,150 tuples.
If at least once behavior is required for a condition on a stream then it can be placed
outside of the region by applying it to an autonomous
stream
created from the stream in the region:
TStream s = ...;
// Add a condition that will perform at least once behavior
// and count all tuples seen on s including any replayed tuples.
s.autonomous().atLeastTupleCount(1150);
getResult()
deprecated.Tester.atLeastTupleCount(com.ibm.streamsx.topology.TStream, long)
,
Tester.tupleCount(com.ibm.streamsx.topology.TStream, long)
,
Tester.tupleContents(com.ibm.streamsx.topology.spl.SPLStream, com.ibm.streams.operator.Tuple...)
,
Tester.stringContents(com.ibm.streamsx.topology.TStream, String...)
,
Tester.stringContentsUnordered(com.ibm.streamsx.topology.TStream, String...)
Modifier and Type | Method and Description |
---|---|
static Condition<java.lang.Boolean> |
all(Condition<?>... conditions)
Return a condition that is true if all conditions are valid.
|
default Condition<java.lang.Boolean> |
and(Condition<?>... conditions)
Return a condition that is true if this AND all
conditions are valid. |
boolean |
failed()
Has the condition failed.
|
T |
getResult()
Deprecated.
Since 1.11. In most distributed environments specific results cannot be obtained
from conditions (such as stream contents) due to network isolation. While the condition will
correct report its failed or valid state tests should no longer rely on using this method
to perform additional testing. An alternative is to use
stringTupleTester
to perform a per-tuple check. |
boolean |
valid()
Test if this condition is valid.
|
boolean valid()
true
if this condition is valid, false
otherwise.T getResult()
stringTupleTester
to perform a per-tuple check.java.lang.UnsupportedOperationException
- Test environment does not support fetching results.boolean failed()
Tester.tupleCount(com.ibm.streamsx.topology.TStream, long)
fails once it the stream has received more tuples than the expected count.default Condition<java.lang.Boolean> and(Condition<?>... conditions)
conditions
are valid.
The result is a Boolean that indicates if all conditions is valid.conditions
- Conditions to be ANDed together.conditions
are valid.static Condition<java.lang.Boolean> all(Condition<?>... conditions)
conditions
- Conditions to be ANDed together.conditions
are valid.