Class Operator

java.lang.Object
com.streambase.sb.operator.Operator
All Implemented Interfaces:
com.streambase.sb.util.LocatedItem, Serializable
Direct Known Subclasses:
InputAdapter, OutputAdapter

public abstract class Operator extends Object implements Serializable, com.streambase.sb.util.LocatedItem
Abstract base class for User code that is used as a Java Operator or an embedded Adapter in a StreamBase application. One instance will be created for each Java Operator in a StreamBase application. StreamBase Studio may operate on several StreamBase applications at a time, so Operator subclass instances may be in different applications.

Operator subclasses must have a public default constructor.

An Operator is notified of state changes through callbacks. The StreamBase runtime 'calls back' an Operator when it changes the runtime state of the Operator. These callbacks include resume(), resumed(), suspend(), suspended() and . shutdown().

Operator provides "managed threads", which are threads that run concurrently with the application, but which can synchronize with its overall state changes. These threads are started, suspended, resumed, and shut down with the application. Managed threads are registered with an Operator using the method registerRunnable. This is particularly useful for input adapters, which typically have to respond to external events asynchronously with the application. Managed threads can call sendOutput at any time.

If an Operator registers one or more managed threads, and all of its managed threads exit their run() methods, then the Operator itself will shut down.

The StreamBase runtime blocks while it waits for an Operator's managed threads to respond to a state change. This can be problematic if a managed thread is blocked on some event. However, the StreamBase runtime can be configured to interrupt a thread when it needs to change its state. This is accomplished by setting the flag shouldInterrupt to true when registering the thread with registerRunnable.

It may be that an Operator's managed thread does not respond to a state change even after it has been interrupted. If the Operator's thread does not respond to the state within a given time interval then it is considered to be in failure and it is shut down. This time interval is specified by the server configuration parameter operator-state-change-timeout-ms.

For sharing state amongst instances, Operators may use the services provided by the Operator.SharedObjectManager accessible via getRuntimeEnvironment()

Since 7.2.12, if your operator simply passes through Tuples without creating new Tuple instances, ensure you override isPassthruOperator() for maximum performance.

Special Studio Considerations:

Note: Serializations of instances of this class that are created (e.g., by using ObjectOutputStream) in one version of StreamBase in general will not be deserializable in any other version of StreamBase.

See Also: