Control and Data Flows Explained - accelio/JXIO GitHub Wiki

JXIO is a transaction Request-Response model.
It is not a replacement for TCP which is a bi-direction stream.
The client can sends a request which the server can answer with a response once it is ready.

Below is a high level explanation of the control and data flows:

  1. Running Context
  2. Control flow
  1. Data flow

Running Context

All progress in JXIO/Accelio is based on the application threads. An EventQueueHandler (a.k.a.'EQH') object represents the JXIO/AccelIO context. The application must create one EQH for every thread it wants to use a JXIO object for send or receive of data. To get the JXIO engine working, the application thread should be calling runEventLoop() in a blocking or partial blocking manner (with max event or time duration).

Close Context

Close EventQueueHandler by calling EventQueueHandler.close(). This method is synchronous and it will wait until all objects listening on EventQueueHandler will close (ClientSession, ServerSession and ServerPortal).

Control flow

Prepare the Server

The ServerPortal object is the listening port for new incoming connections.
Additional ServerPortal worker thread objects can be used to separate the worker threads from the main listener/balancer thread. Each worker thread require to use a ServerPortal with different port.

Initiate a New Session

The ClientSession object initiates a connection to the main ServerPortal.
A ServerPortal ServerPortal:Callbacks:onNewSession() event is called and the application needs to decided if to handle this new session on this main thread and call ServerPortal:accept() or move this new session to one of the worker threads for handling and call ServerPortal:forward().
ClientSession:Callbacks:onSessionEstablished() is called once session establishment is complete.

Closing an Active Session

Each side can close an active session by calling ClientSession:close() and/or ServerSession:close().
Once the SESSION_CLOSED event is receive the connection between the client and server is no longer active. All resource must be returned back to the JXIO objects in order to fully free release these objects and the underlings resources (native mapped DirectByteBuffers).

Server Shutdown

Shutdown server by calling ServerPortal:close().

MsgPool and Msg

Both ClientSession and ServerSession use Msg's from the MsgPool in order to send and/or receive data.
The MsgPool object is a native allocated buffer which is mapped to Java as a DirectByteBuffer. This buffer is RDMA capable and allows true zero copy from Java application to the wire and back to the application.
JXIO maps the Java data transfers commands to RDMA READ/WRITE operations when message size is larger than 512 bytes. Else it will use RDMA SEND/RECV operations.

Data flow

A JXIO ClientSession will call sendRequest() to initiate a new request to the server. The JXIO ServerSession will receive the new request via the onRequest() callback and should answer via sendResponse() to the client any time it is ready to do so. The transaction is completed when the ClientSession receives the onResponse() callback.

Multiple requests can be issued in parallel to utilize the max transaction rate and high bandwidth the JXIO/AccelIO framework provide applications. Multiple ClientSession can be managed in parallel as well to manage different session and reach even high performance.