com.ibm.streams.operator.control.variable

Interface ControlVariableAccessor<T>

    • Method Summary

      Methods 
      Modifier and Type Method and Description
      java.lang.String getName()
      Get the name of this control variable.
      T getValue()
      Get the value of this control variable.
      javax.management.ObjectName getVariableObjectName()
      Get the ObjectName of this control variable's MXBean in the Job Control Plane Mbean server.
      void setValue(T value)
      Set this control variable to a new value.
      ControlVariableAccessor<T> sync()
      Synchronize this view of this control variable with the value in the Job Control Plane.
    • Method Detail

      • getValue

        T getValue()
        Get the value of this control variable. Returns the value without blocking.
        If this operator has not yet established a connection with the Job Control Plane then the initial value will be returned.
        If this operator has temporarily lost contact with the Job Control Plane then the most recent value obtained from the Job Control Plane will be returned.
        Otherwise the value returned is the current value of the control variable.

        To ensure the current value is returned then the caller may first call sync() to ensure a connection with the Job Control Plane is established.

        Returns:
        the value of this control variable.
      • setValue

        void setValue(T value)
                      throws java.io.IOException,
                             java.lang.InterruptedException
        Set this control variable to a new value. This call will block if the PE has not yet established a connection to the Job Control Plane. The new value is persisted in the Job Control Plane.
        Parameters:
        value - Value to set the control variable to.
        Throws:
        java.io.IOException - exception communicating with the Job Control Plane.
        java.lang.InterruptedException - Thread was interrupted waiting for a connection to the the Job Control Plane.
      • getName

        java.lang.String getName()
        Get the name of this control variable.
        Returns:
        name of this control variable.
      • getVariableObjectName

        javax.management.ObjectName getVariableObjectName()
        Get the ObjectName of this control variable's MXBean in the Job Control Plane Mbean server.
        Returns:
        ObjectName of this control variable's MXBean.
      • sync

        ControlVariableAccessor<T> sync()
                                        throws java.lang.InterruptedException
        Synchronize this view of this control variable with the value in the Job Control Plane. This call will return immediately if this operator is already connected to the Job Control Plane.
        Otherwise it will wait until a connection is established and getValue() represents the current value of this control variable.

        For example, this code creates a shared double control variable called threshold and then obtains its current value using the sync() method which may block.

         
            ControlPlaneContext cpc = context.getOptionalContext(ControlPlaneContext.class);
            ControlVariableAccessor<Double> thresholdVariable = cpc.createDoubleControlVariable("threshold", true, 100.0);
            
            // This will always get the current value of the
            // control variable, but may block waiting for
            // a connection to the Job Control Plane to
            // be established.
            double threshold = thresholdVariable.sync().getValue();
         
         
         

        Returns:
        this
        Throws:
        java.lang.InterruptedException - Thread was interrupted while waiting for the connection to the Job Control Plane to be established.
        Since:
        InfoSphere® Streams Version 4.1