Java™ Operator API overview
You use the Teracloud® Streams Java™ Operator API to implement user-defined operators in Java™.
The Javadoc™ documentation
for this API is provided with the Teracloud®
Streams installation
in the $STREAMS_INSTALL/doc/spl/operator/api/java/api directory.
The primary package within this API is
com.ibm.streams.operator
.
Here is a brief description of its main classes.Operator
: This interface defines an operator. The Teracloud® Streams run time calls methods on this interface for initialization and then on for each incoming tuple and punctuation until a shutdown request is made.AbstractOperator
: Is an abstract class that developers can extend to implementOperator
. It provides a number of useful utility methods.OperatorContext
: This interface provides access to the operator's runtime context, including descriptions of the streams and parameters. In addition, it provides access to a Java™ScheduledExectorService
andThreadFactory
for asynchronous actions.StreamSchema
: This interface describes the schema of a port, including the names and types (Java™ and SPL) of its attributes.StreamingInput
: This interface describes an input port, including its schema.StreamingOutput
: This interface describes an output port and provides methods to obtain new output tuples and to submit them.Tuple
: This interface implements an immutable object that generically represents an incoming tuple.OutputTuple
: This interface implements a mutable object that generically represents an outgoing tuple.
The Java™ Operator API is in the Teracloud®
Streams library
com.ibm.streams.operator.jar
, which is located in
$STREAMS_INSTALL/lib. The Java™ Operator API depends on Apache Commons Math 2.2 library
(commons-math-2.2.jar
) which is located in
$STREAMS_INSTALL/ext/lib. When you develop Java™ operators using the Java™ Operator API, the com.ibm.streams.operator.jar
and
commons-math-2.2.jar
libraries are required in the class path. Sample operators
and patterns, including source, are supplied in the Teracloud®
Streams Version 7.2.0 library com.ibm.streams.operator.samples.jar
, which is in
$STREAMS_INSTALL/lib
.Note: All of these
libraries are automatically added by the Teracloud®
Streams run time for operator invocation, thus they must not be declared as dependencies of a Java™ primitive operator or included in the
classLibrary parameter for a JavaOp
invocation.
The Teracloud® Streams run time provides a Java™ SE Version 8 execution environment for operators that are implemented using the Teracloud® Streams Java™ Operator API. The virtual machine that is used by a stream application is defined by the setting of the environment variable JAVA_HOME when the SPL compiler (sc) is run.