|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Object | +--com.ibm.tspaces.TSCmdLocalImpl
This is the Local implementation of the TSCmd interface. This implementation can be used when the client is running in the same Java Virtual Machine as the TSpaces server. 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: Document the protocol here
CallbackThread,
Waiter,
Semaphore,
TSDispatch, Serialized Form| Field Summary | |
protected static CallbackThread |
_callback
The CallbackThread instance for this TSCmd implementation It is a class object because there is only one per JVM |
protected int |
_dispatchThreadNumber
the number of dispatch threads we have spawned so far --- so we can give them a unique # |
protected com.ibm.tspaces.server.TS |
_galaxyTS
The TupleSpace of all TupleSpaces maintained by the mother of all TupleSpace Servers. |
protected java.lang.String |
_password
The password for this TSCmdImpl. |
protected java.util.Vector |
_queue
A Vector is used to queue the resultTuples to the CallbackThread |
protected static boolean |
_shutdown
if true then shutdown in progress |
protected java.lang.String |
_userName
The username for this TSCmdImpl . |
| Method Summary | |
static void |
cleanup()
this method is used to close the current connections to the server. |
void |
close()
this method is used to close the current connection to the server. |
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 as an argument. |
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_)
Register for an event on the server. |
static TSCmdLocalImpl |
getRef(java.lang.String user_,
java.lang.String password_)
static class method to obtain a reference to the singleton instance for this class. |
Tuple |
getResponse()
Get a response to the client, |
java.util.Vector |
getTSpaceClients()
Return the TSpace clients vector |
java.security.Principal |
getUserPrincipal()
Return the Principal object for the authenticated userid |
static void |
killConnection(java.lang.String key_,
java.lang.Exception ioe_)
this method is used to close the current connection to the server. |
boolean |
sendResponse(java.lang.String status_,
java.lang.Integer seqNumber_,
SuperTuple retValue_)
Send a response to the client, All responses should come through here! If the communication fails we disable all further communication with this port, indicate that TSIOHandler should stop and return false to the caller. |
void |
setup(java.lang.String userName_,
java.lang.String password_)
Setup the command instance |
| Methods inherited from class java.lang.Object |
clone,
equals,
finalize,
getClass,
hashCode,
notify,
notifyAll,
toString,
wait,
wait,
wait |
| Field Detail |
protected static boolean _shutdown
protected static CallbackThread _callback
protected int _dispatchThreadNumber
protected com.ibm.tspaces.server.TS _galaxyTS
protected java.lang.String _userName
protected java.lang.String _password
protected java.util.Vector _queue
| Method Detail |
public static TSCmdLocalImpl getRef(java.lang.String user_,
java.lang.String password_)
public void setup(java.lang.String userName_,
java.lang.String password_)
throws TupleSpaceException
userName_ - the user's tspaces namepassword_ - the user's tspaces passwordpublic void close()
public SuperTuple command(java.lang.String cmdString_,
SuperTuple argTuple_,
java.lang.String tsName_,
Transaction enclosingTransaction_)
throws TupleSpaceCommunicationException,
TupleSpaceClientException,
TupleSpaceServerException
server_ - the server to send the command toport_ - the port for that serveruserName_ - the Username to associate with this connection.password_ - the password for the above user.cmdString_ - The String that names the command.argTuple_ - The argument Tuple, can be null.tsName_ - The tuple space the command is acting onenclosingTransaction_ - Transaction object that issued this command
enclosingTransaction_ == null ---> standAlone transaction
'' <> null ---> part of enclosingTransaction_Waiter,
CallbackThread
public SuperTuple command(java.lang.String cmdString_,
SuperTuple argTuple_,
java.lang.String tsName_,
Transaction enclosingTransaction_,
long timeout_)
throws TupleSpaceCommunicationException,
TupleSpaceClientException,
TupleSpaceServerException
waitFor(timeout) {
mySemaphore.decr(timeout);
}
call(SuperTuple retValue, some other irrelevent junk) {
myTuple = retValue;
mySemaphore.incr();
}
So the command method will send the command and then call "waitFor() which blocks. When the command is complete, the callbackThread will get the response and call waiter.call(retValue) which will unblock this code. This code will then get the returned Tuple from the Waiter instance and return it to the caller. in case it isn't obvious, the methods in Waiter had better *not* be synchronized since the waitFor would then block with the lock held and call would block waiting on the lock.
server_ - the server to send the command toport_ - the port for that serveruserName_ - the Username to associate with this connection.password_ - the password for the above user.cmdString_ - The String that names the command.argTuple_ - The argument Tuple, can be null.tsName_ - The tuple space the command is acting onenclosingTransaction_ - Transaction object that issued this command
enclosingTransaction_ == null ---> standAlone transaction
'' <> null ---> part of enclosingTransaction_timeout_ - Time (in ms) that command shuld wait for a response.Waiter,
CallbackThread
public void eventRegister(int seqNum,
Callback callback_,
java.lang.String commandName_,
java.lang.String tsName_,
boolean newThread_)
The eventRegister method for the TSCmd instance is called to warn it to expect an event to arrive. The client can then send the eventRegister command to the server
seqNum - The sequence number assigned to the eventcallback_ - 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 namenewThread_ - If true, a new thread will be started for the callbackpublic void eventDeRegister(int seqNum)
The eventRegister command is then sent to the server. he TSCmd instance is called to tell it not to expect any more events to arrive.
seqNum - The sequence number assigned to the event
public static void killConnection(java.lang.String key_,
java.lang.Exception ioe_)
key_ - the hostname and port catted togetherioe_ - the ioexception that occured.runpublic static void cleanup()
public Tuple getResponse()
public boolean sendResponse(java.lang.String status_,
java.lang.Integer seqNumber_,
SuperTuple retValue_)
status_ - was the status OK or EXCEPTION?seqNumber_ - the unique *client* side sequence number of this commandretValue_ - the tuple going back to the clientpublic java.security.Principal getUserPrincipal()
public java.util.Vector getTSpaceClients()
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||