The Pivot is the center of the NIO Protocol Adapter server-side implementation. It handles
channel (connection) management, thread allocation and request/reply transmission.
The Pivot
runs several types:
- SelectorThread: 1. Which listens on a port and accepts connection
requests. When a new connection is accepted, the connection is added to the table of open
connections. 2. Charge of selecting connections that have pending data (available for read).
- A group of worker threads that can handle invocation requests.
The
interaction between connections, threads, requests and replies is as follows:
Each channel
is associated with a SelectorThread. A SelectorThread manages all channels. SelectorThread is a
thread that listens for incoming Request Packet. When a Request Packet arrives at a channel,
SelectorThread builds a small bus packet that contains the channel info and dispatches it to the
worker threads' queue. An available worker thread receives the bus packet from the queue, reads
the Request Packet from the associated channel, performs the invocation (an up-call to the LRMI
Runtime), builds a Reply Packet from the result and sends it through the channel.
A channel
is closed implicitly if an IO Exception is thrown when reading or writing to the channel (for
example, because the client socket is closed).
A future enhancement is to support automatic
closing of channels that are inactive for a period of time. This also implies a keep-alive
mechanism.