com.ibm.tspaces
Class TSCmdRMIImpl

java.lang.Object
  |
  +--com.ibm.tspaces.TSCmdRMIImpl

public class TSCmdRMIImpl
extends java.lang.Object
implements TSCmd

This is the RMI implementation of the TSCmd interface. The command method is RMI based and many other methods are generic and are same as other implementations of TSCmd. When the client calls the TupleSpace constructor, it will obtain an instance of TSCmd which will be used to send commands to the Server and receive the Tuple responses. The TupleSpace instance will communicate with the server by calling TSCmd.command() (*) The communication protocol: The client communicates with the server using remote method calls. The client looks up a RMIRegistry to get the reference to a TSServer that has registered itself to the regisrty. With this reference, the client calls methods at the server to send requests. The results of the operation is send as return value of the method.

Author:
Venkatesan Esakki
See Also:
TSCmd, TSRMIHandler

Field Summary
static java.lang.String _DEFAULT_PASSWORD
           
static java.lang.String _DEFAULT_USER
          This is what is used if no user/password is specified
protected  java.lang.String _password
          The password for this TSCmdImpl.
protected static com.ibm.tspaces.server.TSRMIServer _remServer
          Reference to the Remote TupleSpace server that exports the RMI interface
protected  int _tsPort
          The port for this space's server.
protected  java.lang.String _tsServer
          The name of the machine running the TupleSpace server
protected  java.lang.String _userName
          The username for this TSCmdImpl .
static int CLI_ID
           
static int CMD_FLAG
           
static int CMD_TUP
           
protected static int DEFAULTCONNECTTRIES
          the number of times to try to connect to the server before raising an exception to the caller.
static int EVENT_ACTION_FLD
           
static int EVENT_COMMAND_FLD
          the fields of an event tuple, keep with the making of the event templates until things stabilize.
static int EVENT_EAT_FLD
           
static int EVENT_SEQ_FLD
           
static int EVENT_TUPLE_FLD
           
static int SEQ_NUM
          The top level tuple sent to the server has four fields ( Seq #, CmdTuple, clientID, Flag)
static int TS_ARG
           
static int TS_CMD
           
static int TS_NAME
           
static int TS_RETURN_VALUE
           
static int TS_STATUS_CODE
           
 
Constructor Summary
TSCmdRMIImpl(java.lang.String tsServer_, java.lang.Integer tsPort_, java.lang.String userName_, java.lang.String password_)
          Sets up the RMI Security Manager and gets the reference to the Remote Server by looking up the RMI registry.
 
Method Summary
 void close()
          This method is implemented just to satisfy the interface defn This method does nothing in RMI implementation of Command.
 SuperTuple command(java.lang.String cmdString_, SuperTuple argTuple_, java.lang.String tsName_, Transaction enclosingTransaction_)
          Issue a command to the TupleSpace galaxy tuple space and pass along a Tuple as an argument.
 SuperTuple command(java.lang.String cmdString_, SuperTuple argTuple_, java.lang.String tsName_, Transaction enclosingTransaction_, long timeout_)
          Issue a command to the TupleSpace galaxy tuple space and pass along a Tuple and a timeout value as arguments.
 void eventDeRegister(int seqNum)
          DeRegister for an event on the server.
 void eventRegister(int seqNum, Callback callback_, java.lang.String commandName_, java.lang.String tsName_, boolean newThread_)
          To be Implemented !! If the client tries to call eventRegister in RMI implementation, a TupleSpaceException will be thrown, with the corresponding message.
 java.lang.String getPassword()
          Return the password of the user
 int getPort()
          Return the number of the port.
 java.lang.String getServer()
          Return the name of the server.
 java.lang.String getUserName()
          Return the name of the User.
static void killConnection()
          This method is used to close the current connection to the server.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

SEQ_NUM

public static final int SEQ_NUM
The top level tuple sent to the server has four fields ( Seq #, CmdTuple, clientID, Flag)

CMD_TUP

public static final int CMD_TUP

CLI_ID

public static final int CLI_ID

CMD_FLAG

public static final int CMD_FLAG

EVENT_COMMAND_FLD

public static final int EVENT_COMMAND_FLD
the fields of an event tuple, keep with the making of the event templates until things stabilize. The 0th field is TupleSpace.ANEVENT

EVENT_TUPLE_FLD

public static final int EVENT_TUPLE_FLD

EVENT_SEQ_FLD

public static final int EVENT_SEQ_FLD

EVENT_ACTION_FLD

public static final int EVENT_ACTION_FLD

EVENT_EAT_FLD

public static final int EVENT_EAT_FLD

_DEFAULT_USER

public static final java.lang.String _DEFAULT_USER
This is what is used if no user/password is specified

_DEFAULT_PASSWORD

public static final java.lang.String _DEFAULT_PASSWORD

TS_NAME

public static final int TS_NAME

TS_CMD

public static final int TS_CMD

TS_ARG

public static final int TS_ARG

TS_STATUS_CODE

public static final int TS_STATUS_CODE

TS_RETURN_VALUE

public static final int TS_RETURN_VALUE

DEFAULTCONNECTTRIES

protected static final int DEFAULTCONNECTTRIES
the number of times to try to connect to the server before raising an exception to the caller. Would probably be nice in the future if this was an instance variable rather than static.

_remServer

protected static com.ibm.tspaces.server.TSRMIServer _remServer
Reference to the Remote TupleSpace server that exports the RMI interface

_tsServer

protected java.lang.String _tsServer
The name of the machine running the TupleSpace server

_tsPort

protected int _tsPort
The port for this space's server.

_userName

protected java.lang.String _userName
The username for this TSCmdImpl .

_password

protected java.lang.String _password
The password for this TSCmdImpl.
Constructor Detail

TSCmdRMIImpl

public TSCmdRMIImpl(java.lang.String tsServer_,
                    java.lang.Integer tsPort_,
                    java.lang.String userName_,
                    java.lang.String password_)
             throws TupleSpaceException
Sets up the RMI Security Manager and gets the reference to the Remote Server by looking up the RMI registry.
Parameters:
tsServer_ - A string that identifies the TupleSpaceServer that manages the TupleSpace. May be of form host:port
tsPort_ - This parameter is ignored in this RMI implementation. This is just for giving the same interface for all CmdImplementations.
userName_ - the user's tspaces name
password_ - the user's tspaces password
Throws:
TupleSpaceException - If there is a problem creating the space on the server or communicating with the server or there is a problem with the TupleSpaceName.
Method Detail

command

public SuperTuple command(java.lang.String cmdString_,
                          SuperTuple argTuple_,
                          java.lang.String tsName_,
                          Transaction enclosingTransaction_)
                   throws TupleSpaceCommunicationException,
                          TupleSpaceClientException,
                          TupleSpaceServerException
Issue a command to the TupleSpace galaxy tuple space and pass along a Tuple as an argument. The command is a text string that is recongized by the TupleSpace. The results of the command, if any, are returned as a tuple.
Specified by:
command in interface TSCmd
Parameters:
cmdString_ - The String that names the command.
argTuple_ - The argument Tuple, can be null.
tsName_ - The tuple space the command is acting on
enclosingTransaction_ - Transaction object that issued this command enclosingTransaction_ == null ---> standAlone transaction '' <> null ---> part of enclosingTransaction_
Returns:
A result Tuple, the format of which depends upon the command.
Throws:
TupleSpaceCommunicationException - There are problems connecting to the TupleSpace Server
TupleSpaceServerException - There was a problem executing the command on the server.
TupleSpaceClientException - There were problems preparing the command to be sent to the server.

command

public SuperTuple command(java.lang.String cmdString_,
                          SuperTuple argTuple_,
                          java.lang.String tsName_,
                          Transaction enclosingTransaction_,
                          long timeout_)
                   throws TupleSpaceCommunicationException,
                          TupleSpaceClientException,
                          TupleSpaceServerException
Description copied from interface: TSCmd
Issue a command to the TupleSpace galaxy tuple space and pass along a Tuple and a timeout value as arguments. The command is a text string that is recongized by the TupleSpace. The results of the command, if any, are returned as a tuple.
Specified by:
command in interface TSCmd
Tags copied from interface: TSCmd
Parameters:
cmdString_ - The String that names the command.
argTuple_ - The argument Tuple, can be null.
tsName_ - The tuple space the command is acting on
enclosingTransaction_ - Transaction object that issued this command enclosingTransaction_ == null ---> standAlone transaction '' <> null ---> part of enclosingTransaction_
timeout_ - The time in ms until this command should report a timeout. Defaults to 0 which indicates no timeout.
Returns:
A result Tuple, the format of which depends upon the command.
Throws:
TupleSpaceCommunicationException - There are problems connecting to the TupleSpace Server
TupleSpaceServerException - There was a problem executing the command on the server.
TupleSpaceClientException - There were problems preparing the command to be sent to the server.

killConnection

public static void killConnection()
This method is used to close the current connection to the server. It is called by talkToAServer if they get an errro in connection to the server.This just sets the remote server reference to Null.

close

public void close()
This method is implemented just to satisfy the interface defn This method does nothing in RMI implementation of Command.
Specified by:
close in interface TSCmd

eventRegister

public void eventRegister(int seqNum,
                          Callback callback_,
                          java.lang.String commandName_,
                          java.lang.String tsName_,
                          boolean newThread_)
To be Implemented !! If the client tries to call eventRegister in RMI implementation, a TupleSpaceException will be thrown, with the corresponding message.
Specified by:
eventRegister in interface TSCmd
Tags copied from interface: TSCmd
Parameters:
seqNum - The sequence number assigned to the event
callback_ - what class object contains the call() method that will be called when the event happens.
commandName_ - the operation "WRITE" or "DELETE" to be on the watch for!
tsName_ - the Tuple Space name
newThread_ - If true, a new thread will be started for the callback

eventDeRegister

public void eventDeRegister(int seqNum)
DeRegister for an event on the server. To be Implemented !! If the client tries to call eventDeRegister in RMI implementation, a TupleSpaceException will be thrown, with the corresponding message.!!
Specified by:
eventDeRegister in interface TSCmd
Tags copied from interface: TSCmd
Parameters:
seqNum - The sequence number assigned to the event

getServer

public java.lang.String getServer()
Return the name of the server. Cool for debugging.
Returns:
String - the name of the server

getUserName

public java.lang.String getUserName()
Return the name of the User.
Returns:
String - the name of the user

getPassword

public java.lang.String getPassword()
Return the password of the user
Returns:
String - the password string

getPort

public int getPort()
Return the number of the port. Cool for debugging.
Returns:
int - the number of the port