|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Object
|
+--one.world.util.AbstractHandler
|
+--one.world.io.NetworkIO.Client
A reliable network I/O client. Implements structured I/O over a TCP
client socket, providing reliable, in-order delivery.
Handles SimpleInputRequests and SimpleOutputRequests.
Network I/O clients generally should be obtained via a binding request to the environment's request handler.
Note that any exception on the underlying object stream or socket will cause the resource to be revoked.
Internal fields and methods are protected so that a subclass can access or override any method, for instance to build an encrypted network I/O client.
SioResource,
BindingRequest,
Environment, Serialized Form| Inner Class Summary | |
protected class |
NetworkIO.Client.Listener
Listens for data arriving from the network. |
protected class |
NetworkIO.Client.RevokationHandler
The revokation handler. |
| Field Summary | |
protected ObjectInputStream |
inputStream
The object input stream for receiving tuples. |
protected boolean |
isRevoked
Indicates whether the resource has been revoked. |
protected EventHandler |
leaseHandler
The lease manager to use for requesting leases. |
protected Object |
lock
The lock object. |
protected ObjectOutputStream |
outputStream
The object output stream for sending tuples. |
protected EventHandler |
requester
The original requester of the resource. |
protected SioResource |
sioResource
The SioResource (for debugging only). |
protected Socket |
socket
The socket. |
| Constructor Summary | |
protected |
NetworkIO.Client(EventHandler requester,
SioResource sioResource,
Socket socket,
EventHandler leaseHandler,
NestedConcurrencyDomain cDomain)
Create a new reliable network channel using the specified socket, in the specified environment. |
| Method Summary | |
boolean |
handle1(Event event)
Handles SimpleInputRequest and SimpleOutputRequest
events. |
protected void |
put(SimpleOutputRequest request)
Handles a put request by writing the tuple to the network channel. |
protected void |
requestTermination()
Request that the nested concurrency domain be revoked. |
protected void |
revoke()
Revokes the network I/O client resource. |
protected void |
revoke1()
Revokes the network I/O client resource. |
protected void |
terminate()
Terminates the nested concurrency domain. |
String |
toString()
Returns a string representation of this network I/O client. |
| Methods inherited from class one.world.util.AbstractHandler |
handle, isNotValid, respond, respond, respond, respond, respond, respond |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Field Detail |
protected EventHandler requester
protected final SioResource sioResource
protected EventHandler leaseHandler
protected Socket socket
protected ObjectOutputStream outputStream
protected volatile ObjectInputStream inputStream
NetworkIO.Client.Listener thread. Furthermore, we must be able to interrupt
this thread by closing the socket.protected Object lock
protected volatile boolean isRevoked
revoke() method, but subclasses may need to
read it to decide whether the resource is active.| Constructor Detail |
protected NetworkIO.Client(EventHandler requester,
SioResource sioResource,
Socket socket,
EventHandler leaseHandler,
NestedConcurrencyDomain cDomain)
throws IOException
requester - The source of the original resource request.sioResource - The SIO resource descriptor.socket - The TCP socket to use for the channel.leaseHandler - The lease manager used to acquire leases.cDomain - The nested concurrency domain for the client.IOException - Signals an error in configuring the socket or
obtaining the I/O streams.| Method Detail |
public boolean handle1(Event event)
SimpleInputRequest and SimpleOutputRequest
events. A SimpleOutputRequest results in the tuple
being sent over the network channel.
SimpleInputRequests will wait for results until the
timeout expires.
Also handles LeaseEvent.CANCELED
events by revoking the resource.
handle1 in class AbstractHandlerevent - The event to handle.protected void put(SimpleOutputRequest request)
An I/O exception indicates that the output stream,
outputStream, has been closed. This is an abnormal
condition. An error is logged and the resource is revoked.
request - The output request.protected void revoke()
If the system is shutting down, actually revokes the resource.
Otherwise, queues a RevokeEvent in the nested concurrency
domain.
protected void revoke1()
Clean-up includes interrupting and nullifying the listener thread, and closing and nullifying the streams and socket. May be called repeatedly without ill effects.
protected void requestTermination()
protected void terminate()
public String toString()
toString in class Object
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||