com.ibm.streams.flow.handlers
Class StreamCounter<T>
- java.lang.Object
-
- com.ibm.streams.flow.handlers.StreamCounter<T>
-
- Type Parameters:
T
- Type for the tuples on the stream
- All Implemented Interfaces:
- StreamHandler<T>
public class StreamCounter<T> extends java.lang.Object implements StreamHandler<T>
Count the number of tuples and punctuation marks that are seen on a stream.
Useful for testing graphs by verifing the output of an operator produced the correct number of tuples and punctuation marks.- Since:
- InfoSphere® Streams Version 3.1
-
-
Field Summary
Fields Modifier and Type Field and Description static java.lang.String
IBM_COPYRIGHT
-
Constructor Summary
Constructors Constructor and Description StreamCounter()
Construct aStreamCounter
that initializes all the counts to zero.
-
Method Summary
Methods Modifier and Type Method and Description long
getMarkCount(StreamingData.Punctuation mark)
Return the number of punctuation marks of typemark
that are seen on the stream.long
getTupleCount()
Return the number of tuples that are seen on the stream.void
mark(StreamingData.Punctuation mark)
Count the number of punctuation marks.void
reset()
Reset all the counts to zero.void
tuple(T tuple)
Count the number of tuples.boolean
waitForTuples(int count, long timeout, java.util.concurrent.TimeUnit unit)
-
-
-
Field Detail
-
IBM_COPYRIGHT
public static final java.lang.String IBM_COPYRIGHT
- See Also:
- Constant Field Values
-
-
Constructor Detail
-
StreamCounter
public StreamCounter()
Construct aStreamCounter
that initializes all the counts to zero.
-
-
Method Detail
-
getTupleCount
public long getTupleCount()
Return the number of tuples that are seen on the stream.- Returns:
- Number of tuples that are seen on the stream.
-
getMarkCount
public long getMarkCount(StreamingData.Punctuation mark)
Return the number of punctuation marks of typemark
that are seen on the stream.- Returns:
- Number of punctuation marks of type
mark
that are seen on the stream.
-
tuple
public void tuple(T tuple) throws java.lang.Exception
Count the number of tuples.- Specified by:
tuple
in interfaceStreamHandler<T>
- Parameters:
tuple
- The tuple.- Throws:
java.lang.Exception
- Failure to process the tuple.
-
mark
public void mark(StreamingData.Punctuation mark) throws java.lang.Exception
Count the number of punctuation marks.- Specified by:
mark
in interfaceStreamHandler<T>
- Parameters:
mark
- The punctuation mark.- Throws:
java.lang.Exception
- Failure to process the punctuation mark.
-
reset
public void reset()
Reset all the counts to zero.
-
waitForTuples
public boolean waitForTuples(int count, long timeout, java.util.concurrent.TimeUnit unit) throws java.lang.InterruptedException
- Throws:
java.lang.InterruptedException
-
-