Class Pivot

java.lang.Object
com.gigaspaces.lrmi.nio.Pivot

public class Pivot extends Object
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.

Since:
4.0
Author:
Igor Goldenberg
  • Constructor Details

  • Method Details

    • getPort

      public int getPort()
    • getHostName

      public String getHostName()
    • isMonitorActivity

      public static boolean isMonitorActivity()
    • handleExceptionFromServer

      public boolean handleExceptionFromServer(Writer writer, Reader reader, Throwable ex)
      send if possible the catch server exception to the client
    • newConnection

      public ChannelEntry newConnection(ReadSelectorThread readHandler, SelectionKey key)
      Called by the ConnMgr thread when a new connection is created.
    • closeConnection

      public void closeConnection(ChannelEntry channelEntry)
      Called by anyone who wants to close a connection.
    • handleProtocolValidation

      public void handleProtocolValidation(ChannelEntry channelEntry, Reader.ProtocolValidationContext context, ReadSelectorThread handler)
    • handleReadRequest

      public void handleReadRequest(ChannelEntry channelEntry, Reader.Context ctx, ReadSelectorThread handler)
      Called by a Reader Selector when it detects that a channel has pending data for read.
      Parameters:
      channelEntry - the channel representing the client connection.
    • requestPending

      public void requestPending(ChannelEntry channel, ReplyPacket<?> respPacket, IResponseContext responseContext)
    • getChannelEntryFromChannel

      public ChannelEntry getChannelEntryFromChannel(SocketChannel channel)
    • getServerBindInetSocketAddress

      public InetSocketAddress getServerBindInetSocketAddress()
      Returns:
      the INetSocketAddress this Selector bind to.
    • handleRequest

      public void handleRequest(RequestPacket requestPacket, ChannelEntry channelEntry)
      Handles client request and sends reply to the client. Called in the following cases: 1. by the ChannelThread when it detects that a channel has a pending two way request. 2. by the Worker in case of a one way request processing.
      Parameters:
      requestPacket - the request
      channelEntry - a channel(socket) wrapper
    • extractMonitoringId

      public static String extractMonitoringId(RequestPacket requestPacket)
    • sendResponse

      public void sendResponse(ChannelEntry channelEntry, ReplyPacket replyPacket, IResponseContext respContext)
    • getChannels

      protected List<ChannelEntry> getChannels(long remoteObjID)
      Returns:
      all channels of supplied remote objectID
    • unexport

      public void unexport(long remoteObjID)
      unexport supplied remote objectID and close all channel sockets
    • getRemoteObjectConnectionsList

      public List<ITransportConnection> getRemoteObjectConnectionsList(long remoteObjID)
      Returns:
      the Transport connection info list for the supplied remote objectID.
    • countRemoteObjectConnections

      public int countRemoteObjectConnections(long remoteObjID)
    • isProtocolValidationEnabled

      public boolean isProtocolValidationEnabled()
    • getMonitoringDetails

      public LRMIInboundMonitoringDetailsImpl getMonitoringDetails()
    • getSystemRequestHandler

      public SystemRequestHandler getSystemRequestHandler()
    • getChannelEntryState

      public ChannelEntry.State getChannelEntryState(SocketAddress monitoredClient)
    • getServiceDetails

      public static String getServiceDetails(Remote exportedService)