ninja.activeproxy.path
Interface OperatorIF

All Known Implementing Classes:
Operator

public interface OperatorIF
extends java.rmi.Remote

Interface for operators.


Method Summary
 java.lang.Object getCommunicationInfo(java.lang.Object pathID)
          Returns an object which the previous operator in the path will use to create a connection with this operator.
 java.lang.String getIdentification()
          Returns an identification string that will be used to generate a unique path ID; the unique path ID will be generated by using both the source's and destination's identifications.
 java.lang.String getOperatorDescription()
          Returns an operator description.
 OperatorIF getOperatorToNotify(java.lang.Object pathID)
          Returns the operator which would be notified in case of path failure.
 java.net.InetAddress hostName()
           
 boolean isPathAlive(java.lang.Object pathID)
          Determines if the path specified by the given path ID still runs (there is a thread handling this path) through this operator.
 boolean isReaderReady(java.lang.Object pathID)
          Determines if the reader for this operator in the path has been set.
 boolean isReady(java.lang.Object pathID)
          Determines if the reader and writer for this operator in the path have been set.
 boolean isWriterReady(java.lang.Object pathID)
          Determines if the writer for this operator in the path has been set.
 void kill(java.lang.Object pathID)
          Tears down the connections established by this operator in the path, cleans up state associated with this path and kills its thread of execution.
 void loadInputConnector(java.net.URL inputConnectorURL, java.lang.String inputConnectorClass, java.lang.Object pathID)
          Loads and instantiates the input connector.
 void loadOutputConnector(java.net.URL outputConnectorURL, java.lang.String outputConnectorClass, java.lang.Object pathID)
          Loads and instantiates the output connector.
 void pathFailed(java.lang.Object pathID)
          Takes an action when the path fails.
 void resume(java.lang.Object pathID)
          Resume the thread managing the specified pathID.
 void setOperatorToNotify(OperatorIF operatorToNotify, java.lang.Object pathID)
          Sets the operator to notify in case of path failure; used for failure detection while the path is running.
 void setupReader(java.lang.Object pathID)
          Sets up the reader for this operator in the path with the given ID.
 void setupWriter(OperatorIF nextOperator, java.lang.Object pathID)
          Sets up the writer for this operator in the path with the given ID.
 void start(java.lang.Object pathID)
          Starts a new thread of execution in the operator to service the path identified by path ID.
 void suspend(java.lang.Object pathID)
          Suspend the thread managing the specified pathID.
 

Method Detail

loadInputConnector

public void loadInputConnector(java.net.URL inputConnectorURL,
                               java.lang.String inputConnectorClass,
                               java.lang.Object pathID)
                        throws java.lang.ClassNotFoundException,
                               java.lang.InstantiationException,
                               java.lang.IllegalAccessException,
                               java.rmi.RemoteException
Loads and instantiates the input connector.
Parameters:
inputConnectorURL - URL where the input connector can be downloaded from.
inputConnectorClass - input connector class.
pathID - path ID.
Throws:
java.lang.ClassNotFoundException - if the class loader cannot find a definition for the input connector class.
java.lang.InstantiationException - if the instantiation of the input connector fails.
java.lang.IllegalAccessException - if the class or initializer of the input connector is not accessible.
java.rmi.RemoteException - if RMI failed.

loadOutputConnector

public void loadOutputConnector(java.net.URL outputConnectorURL,
                                java.lang.String outputConnectorClass,
                                java.lang.Object pathID)
                         throws java.lang.ClassNotFoundException,
                                java.lang.InstantiationException,
                                java.lang.IllegalAccessException,
                                java.rmi.RemoteException
Loads and instantiates the output connector.
Parameters:
outputConnectorURL - URL where the output connector can be downloaded from.
outputConnectorClass - output connector class.
pathID - path ID.
Throws:
java.lang.ClassNotFoundException - if the class loader cannot find a definition for the output connector class.
java.lang.InstantiationException - if the instantiation of the output connector fails.
java.lang.IllegalAccessException - if the class or initializer of the output connector is not accessible.
java.rmi.RemoteException - if RMI failed.

setupReader

public void setupReader(java.lang.Object pathID)
                 throws InvalidPathIDException,
                        java.rmi.RemoteException
Sets up the reader for this operator in the path with the given ID.
Parameters:
pathID - path ID.
Throws:
InvalidPathIDException - if path ID is invalid.
java.rmi.RemoteException - if RMI failed.

setupWriter

public void setupWriter(OperatorIF nextOperator,
                        java.lang.Object pathID)
                 throws InvalidPathIDException,
                        java.rmi.RemoteException
Sets up the writer for this operator in the path with the given ID.
Parameters:
pathID - path ID.
nextOperator - next operator in the path.
Throws:
InvalidPathIDException - if path ID is invalid.
java.rmi.RemoteException - if RMI failed.

setOperatorToNotify

public void setOperatorToNotify(OperatorIF operatorToNotify,
                                java.lang.Object pathID)
                         throws java.rmi.RemoteException
Sets the operator to notify in case of path failure; used for failure detection while the path is running. The operator to notify can be the previous operator in the path, the source operator where the path originated, etc.
Parameters:
operatorToNotify - operator to be notified in case of path failure.
pathID - path ID.
Throws:
java.rmi.RemoteException - if RMI failed.

getOperatorToNotify

public OperatorIF getOperatorToNotify(java.lang.Object pathID)
                               throws java.rmi.RemoteException
Returns the operator which would be notified in case of path failure.
Parameters:
pathID - path ID.
Returns:
the operator which would be notified in case of path failure.
Throws:
java.rmi.RemoteException - if RMI failed.

getCommunicationInfo

public java.lang.Object getCommunicationInfo(java.lang.Object pathID)
                                      throws InvalidPathIDException,
                                             java.rmi.RemoteException
Returns an object which the previous operator in the path will use to create a connection with this operator.
Parameters:
pathID - path ID.
Returns:
object encapsulating enough information to help the previous operator in the path create a connection with the this operator; in case of socket connection, this can be an Integer object containing the port number on which thread is listening for connections in this operator; in case of operators on the same machine, this can be a PipedInputStream; etc.
Throws:
InvalidPathIDException - if the input connector of the next operator in the path is not set.
java.rmi.RemoteException - if RMI failed.

pathFailed

public void pathFailed(java.lang.Object pathID)
                throws java.rmi.RemoteException
Takes an action when the path fails. For example, it can notify another operator, clean up some state, etc.
Parameters:
pathID - path ID.
Throws:
java.rmi.RemoteException - if RMI failed.

isPathAlive

public boolean isPathAlive(java.lang.Object pathID)
                    throws java.rmi.RemoteException
Determines if the path specified by the given path ID still runs (there is a thread handling this path) through this operator.
Parameters:
pathID - path ID.
Returns:
true if path still runs through this operator; otherwise, false.
Throws:
java.rmi.RemoteException - if RMI failed.

isReady

public boolean isReady(java.lang.Object pathID)
                throws java.rmi.RemoteException
Determines if the reader and writer for this operator in the path have been set. If they have been setup, then the operator in the path is ready to read/write data and, thus, it is safe to start a new thread within the operator.
Parameters:
pathID - path ID.
Returns:
true if reader and writer have been set for this operator; otherwise, false.
Throws:
java.rmi.RemoteException - if RMI failed.

isReaderReady

public boolean isReaderReady(java.lang.Object pathID)
                      throws java.rmi.RemoteException
Determines if the reader for this operator in the path has been set.
Parameters:
pathID - path ID.
Returns:
true if reader has been set for this operator; otherwise, false.
Throws:
java.rmi.RemoteException - if RMI failed.

isWriterReady

public boolean isWriterReady(java.lang.Object pathID)
                      throws java.rmi.RemoteException
Determines if the writer for this operator in the path has been set.
Parameters:
pathID - path ID.
Returns:
true if writer has been set for this operator; otherwise, false.
Throws:
java.rmi.RemoteException - if RMI failed.

start

public void start(java.lang.Object pathID)
           throws InvalidPathIDException,
                  java.rmi.RemoteException
Starts a new thread of execution in the operator to service the path identified by path ID.
Parameters:
pathID - path ID.
Throws:
InvalidPathIDException - if a thread couldn't be started for the path with the given ID; little strange, but let's just say that there was something wrong with the given path ID instead of creating some special exception; also thrown if path ID passed is null.
java.rmi.RemoteException - if RMI failed.

kill

public void kill(java.lang.Object pathID)
          throws java.rmi.RemoteException
Tears down the connections established by this operator in the path, cleans up state associated with this path and kills its thread of execution.
Parameters:
pathID - path ID.
Throws:
java.rmi.RemoteException - if RMI failed.

getIdentification

public java.lang.String getIdentification()
                                   throws java.rmi.RemoteException
Returns an identification string that will be used to generate a unique path ID; the unique path ID will be generated by using both the source's and destination's identifications. Every time this method is called, it will return a different value.
Returns:
a unique identification string; different return value on every call.
Throws:
java.rmi.RemoteException - if RMI failed.

getOperatorDescription

public java.lang.String getOperatorDescription()
                                        throws java.rmi.RemoteException
Returns an operator description.
Returns:
an operator description or null if there was no operator description available.
Throws:
java.rmi.RemoteException - if RMI failed.

hostName

public java.net.InetAddress hostName()
                              throws java.rmi.RemoteException
Returns:
the InetAddress of the machine this operator is running one
Throws:
java.rmi.RemoteException - if the operator is unavailable

suspend

public void suspend(java.lang.Object pathID)
             throws java.rmi.RemoteException
Suspend the thread managing the specified pathID.
Parameters:
pathID - The pathID to suspend.
Throws:
java.rmi.RemoteException - if the operator is unavailable.

resume

public void resume(java.lang.Object pathID)
            throws java.rmi.RemoteException
Resume the thread managing the specified pathID.
Parameters:
pathID - The pathID to resume.
Throws:
java.rmi.RemoteException - if the operator is unavailable.