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.StringIBM_COPYRIGHT
-
Constructor Summary
Constructors Constructor and Description StreamCounter()Construct aStreamCounterthat initializes all the counts to zero.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method and Description longgetMarkCount(StreamingData.Punctuation mark)Return the number of punctuation marks of typemarkthat are seen on the stream.longgetTupleCount()Return the number of tuples that are seen on the stream.voidmark(StreamingData.Punctuation mark)Count the number of punctuation marks.voidreset()Reset all the counts to zero.voidtuple(T tuple)Count the number of tuples.booleanwaitForTuples(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 aStreamCounterthat 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 typemarkthat are seen on the stream.- Returns:
- Number of punctuation marks of type
markthat are seen on the stream.
-
tuple
public void tuple(T tuple) throws java.lang.Exception
Count the number of tuples.- Specified by:
tuplein 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:
markin 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
-
-