All Packages Class Hierarchy This Package Previous Next Index
Class com.ibm.tspaces.CallbackThread
java.lang.Object
|
+----java.lang.Thread
|
+----com.ibm.tspaces.CallbackThread
- public class CallbackThread
- extends Thread
The callback thread handles all communication that is sent from the server to the client,
that is all responses from a server. The way this works is that the TupleSpace.talkToAServer
method which handles all requests, will register a response handler with the
callback thread for the server it is talking to for each and every
request it sends.
The callback thread just hands the responses over to these response handler (callback) guys.
Below is the comment for the way callback thread used to work. Also note that the code
for the way it used to work is in here, just commented out.
The class CallbackThread is always run on the client side and handles the case where the server
needs to "callback" the client. This is whenever a tuple space operation would block.
So, the idea is that this thread just sits around waiting for the server to send tuples back
for old requests. A unique sequence # is sent with each and every request and thus, this class
can figure out which request goes where.
- Author:
- Pete Wyckoff
- See Also:
- Callback, TSDispatch, TSIOHandler, TupleSpace
-
_SYSTEM_CALLBACK_NUMBER
- the system itself registers a callback so that the server can tell it stuff.
-
CallbackThread(Socket, String)
- constructor for callback thread creates its server socket to activate itself.
-
addWaiter(Integer, Callback, String, String)
- Add another callback object and its sequence # to our pending table
-
finalize()
- clean up the thread by closing the connection to the server.
-
removeWaiter(Integer)
- Remove a waiter from my pending table.
-
run()
- This is the main code for the callback listener thread.
-
shutdown(Exception)
- shutdown this listener due to an IO exception, called by TupleSpace.killConnection.
_SYSTEM_CALLBACK_NUMBER
public Integer _SYSTEM_CALLBACK_NUMBER
- the system itself registers a callback so that the server can tell it stuff.
CallbackThread
public CallbackThread(Socket s_,
String hostAndPort_)
- constructor for callback thread creates its server socket to activate itself. it opens
it on any free port.
- See Also:
- TupleSpace, CallbackThread, TSDispatch
addWaiter
public void addWaiter(Integer seqNum_,
Callback cb_,
String cmdString_,
String tsName_)
- Add another callback object and its sequence # to our pending table
- Parameters:
- seqNum_ - the sequence number of this waiting request
- cb_ - the callback object to call when this request arrives
- cmdString_ - the command that this waiter is waiting on --- normally it is the command
that is being executed but for event registration, it is the command that
we are registering an event on.
- tsName_ - the tuple space that the command is operating on
- See Also:
- TupleSpace, Callback, TSDispatch
finalize
public void finalize() throws IOException
- clean up the thread by closing the connection to the server.
- Throws: IOException
- throw an io exception if the stream cannot be closed
- Overrides:
- finalize in class Object
removeWaiter
public void removeWaiter(Integer seqNum_)
- Remove a waiter from my pending table. May be called from TupleSpace.talkToAServer if the
command is serviced by the server without blocking or by this.run when the command is serviced by blocking.
- Parameters:
- seqNum_ - the sequence # of the waiter to be removed
- See Also:
- TupleSpace, Callback, TSDispatch
shutdown
public synchronized void shutdown(Exception ioe_)
- shutdown this listener due to an IO exception, called by TupleSpace.killConnection.
Each pending callback is called back with the IOexception. If the listner itself
discovers the io exception, it calls TupleSpace.killConnection from its run method,
then this shutdown method is called from there.
- Parameters:
- ioe_, - the io exception that is causing the shutdown.
- See Also:
- TupleSpace, Callback, TSDispatch, doTheCallback
run
public void run()
- This is the main code for the callback listener thread. Forever
(although this class is run as a daemon and therefore will terminate when all non-daemon threads
do) this method looks for new callback connections from the server and then directs these
to the appropriate callback object's call methods.
- Overrides:
- run in class Thread
- See Also:
- TupleSpace, Callback, TSDispatch
All Packages Class Hierarchy This Package Previous Next Index