com.ibm.streams.operator.management
Class OperatorLifeCycle
- java.lang.Object
-
- com.ibm.streams.operator.management.OperatorLifeCycle
-
public class OperatorLifeCycle extends java.lang.Object
Utility methods to interface with an operator's life cycle. Use of these methods allow code to management their own life cycle, driver by an operator's life cycle without requiring explicit calls fromOperator.allPortsReady()
orOperator.shutdown()
. Thus code can be setup fromOperator.initialize(OperatorContext)
and then respond to all ports ready or shutdown by registering handlers usingaddAllPortsReadyAction
oraddShutdownAction
.
Notifications are through the operator'sOperatorContextMXBean
registered in the platform MBeanServer.- Since:
- InfoSphere® Streams Version 3.2
-
-
Field Summary
Fields Modifier and Type Field and Description static java.lang.String
IBM_COPYRIGHT
-
Constructor Summary
Constructors Constructor and Description OperatorLifeCycle()
-
Method Summary
Methods Modifier and Type Method and Description static void
addAllPortsReadyAction(OperatorContext context, javax.management.NotificationListener listener)
Register an action to be executed when an operator is notified of port readiness.static void
addShutdownAction(OperatorContext context, javax.management.NotificationListener listener)
Register an action to be executed when an operator is shutdown.static void
closeOnShutdown(OperatorContext context, java.io.Closeable closeable)
Register to close aCloseable
when the operator is shutdown.
-
-
-
Field Detail
-
IBM_COPYRIGHT
public static final java.lang.String IBM_COPYRIGHT
- See Also:
- Constant Field Values
-
-
Method Detail
-
closeOnShutdown
public static void closeOnShutdown(OperatorContext context, java.io.Closeable closeable)
Register to close aCloseable
when the operator is shutdown. A weak reference is maintained tocloseable
to avoid unbounded memory growth when an operator has some form of reconnect after failure policy that results in newCloseable
instances. Therefore, an operator cannot rely on shutdown closing the instance if it discards its reference to aCloseable
. In such situations the operator should close the originalCloseable
and invoke this method on the newCloseable
.
Any exception closingcloseable
is ignored.- Parameters:
context
- Operator to be monitored for shutdowncloseable
- Object to be closed on shutdown
-
addShutdownAction
public static void addShutdownAction(OperatorContext context, javax.management.NotificationListener listener)
Register an action to be executed when an operator is shutdown.- Parameters:
context
- Operator to be monitored for shutdownlistener
- Listener to be executed at shutdown- See Also:
Operator.shutdown()
,OperatorContextMXBean.SHUTDOWN
-
addAllPortsReadyAction
public static void addAllPortsReadyAction(OperatorContext context, javax.management.NotificationListener listener)
Register an action to be executed when an operator is notified of port readiness.- Parameters:
context
- Operator to be monitored for port readinesslistener
- Listener to be executed at port readiness- See Also:
Operator.allPortsReady()
,OperatorContextMXBean.ALL_PORTS_READY
-
-