Current and proposed network interfacesPage edited by Aidan SkinnerPurposeThis design page describes the low level design for the new interface which is aimed at facilitating encapsulation for the Network code in both the Java Broker & Client. This is the first step in decoupling the exsiting IO layer from both the surrounding Qpid code and more specifically from the current tie-in to MINA. This document will provide sufficient information for architecture review and also for input to task breakdown & planning. Interface Requirements
Current implementationBrokerCurrently the broker decodes the incoming network data, adds the frames to a Job queue which are then processed as Events by AMQPFastProtocolHandler which passes the majority of the work to AMQMinaProtocolSession. Often this results in a FrameHandler being called. On the outbound route Frames are written to AMQMinaProtocolSession which calls IoSession.writeFrame which passes the data to Mina for writing to the wire. Client connection creationWhen the client creates a connection it creates an AMQConnectionDelegate for the protocol version it requires and passes the new protocol handler to TransportConnection which creates a socket of the requested type (new TCP socket, existing TCP socket or InVM). It then attaches the socket to the protocol handler which init()s a new ProtocolSession which begins version negotiation with the broker. Client processingOnce a socket has been opened the client processes data similarly to the broker, decoding frames using AMQDecoder and passing them to AMQProtocolHandler which, normally, calls a frame handler to perform the actual work. If this frame is one which has a listener waiting for it, those listeners are notified. Outgoing data is generated in AMQSession or it's delegate and written to AMQProtocolHandler, optionally with a return frame to wait for. This is passed to Mina directly. New implementationIn the new version, a NetworkDriver is created by a ProtocolEngine (in the case of outgoing conenctions) or by the Broker at startup and creates a ProtocolEngine when new connections are created. The network driver passes raw data to the ProtocolEngine which is responsible for both decoding the frames and processing them. When the ProtocolEngine wishes to send data, it does so by calling the NetworkDriver. The existing mechanisms for frame listeners etc are retained, but are decoupled from the network processing parts. At the start of a connection the the NetworkDriver will pass data to a ProtocolEngine which will handle protocol negotiation and return the ProtocolEngine to use or throw an exception if no driver is available. The implementation will use the existing Sender and Reciever interfaces in org.apache.qpid.transport which will allow the use of the existing alternate transport layer implementations. The thread of control remains with the network driver. Data comes in from the operating system, is read from the socket by the NetworkDriver and given to the ProtocolEngines received method. The ProtocolEngine is responsible for processing the bytes and interfacing to the rest of the broker or client. The ProtocolEngine will write bytes to the wire using the NetworkDriver which implements the Sender interface. Sender:
public interface Sender<T>
{
void setIdleTimeout(long l);
void send(T msg);
void flush();
void close();
}
The ProtocolEngine will implement the Reciever interface to be given bytes by the NetworkDriver. Receiever:
public interface Receiver<T>
{
void received(T msg);
void exception(Throwable t);
void closed();
}
The ProtocolEngine will implement the following interface:
public interface ProtocolEngine implements Receiver<java.nio.ByteBuffer>
{
void setNetworkDriver (NetworkDriver driver)
void SocketAddress getRemoteAddress()
long getWrittenBytes()
long getReadBytes()
long close()
// Called when the NetworkEngine has not written data for the specified period of time
void writerIdle()
// Called when the NetworkEngine has not read data for the specified period of time
void readerIdle()
}
public interface ProtocolEngineFactory
{
// Returns a new instance of a ProtocolEngine
ProtocolEngine newProtocolEngine()
}
The NetworkDriver will implement the following interface:
public interface NetworkDriver implements Sender<java.nio.ByteBuffer>
{
static NetworkDriver open(InetAddress destination, ProtocolEngine enginer, NetworkDriverConfiguration config);
static NetworkDriver bind (int port, InetAddress[] addresses, ProtocolEngineFactory factory,
NetworkDriverConfiguration config);
void SocketAddress getRemoteAddress()
/**
* The length of time after which the ProtocolEngines readIdle() method should be called if no data has been
* read
*/
void setMaxReadIdle(int idleTime)
/**
* The length of time after which the ProtocolEngines writeIdle() method should be called if no data has been
* written
*/
void setMaxWriteIdle(int idleTime)
}
The NetworkConfiguration interface provides configuration data for the NetworkDriver:
public interface NetworkDriverConfiguration
{
// Taken from Socket
void getKeepAlive(boolean on)
void getOOBInline(boolean on)
void getReceiveBufferSize(int size)
void getReuseAddress(boolean on)
void getSendBufferSize(int size)
void getSoLinger(boolean on, int linger)
void getSoTimeout(int timeout)
void getTcpNoDelay(boolean on)
void getTrafficClass(int tc)
void getReceiveBufferSize(int size);
void getSendBufferSize(int size);
}
New broker network / protocol engine interfaceNew client network / protocol engine interface
Change Notification Preferences
View Online
|
View Change
|
Add Comment
|
- [CONF] Apache Qpid > Current and proposed network interfaces confluence
- [CONF] Apache Qpid > Current and proposed network interfaces confluence
- [CONF] Apache Qpid > Current and proposed network interfaces confluence
- [CONF] Apache Qpid > Current and proposed network interfaces confluence
- [CONF] Apache Qpid > Current and proposed network interfaces confluence
- [CONF] Apache Qpid > Current and proposed network interfaces confluence
- [CONF] Apache Qpid > Current and proposed network interfaces confluence
- [CONF] Apache Qpid > Current and proposed network interfaces confluence
- [CONF] Apache Qpid > Current and proposed network interfaces confluence
- [CONF] Apache Qpid > Current and proposed network interfaces confluence
- [CONF] Apache Qpid > Current and proposed network interfaces confluence
- [CONF] Apache Qpid > Current and proposed network interfaces confluence
- [CONF] Apache Qpid > Current and proposed network interfaces confluence
- [CONF] Apache Qpid > Current and proposed network interfaces confluence
- [CONF] Apache Qpid > Current and proposed network interfaces confluence
- [CONF] Apache Qpid > Current and proposed network interfaces confluence
- [CONF] Apache Qpid > Current and proposed network interfaces confluence
- [CONF] Apache Qpid > Current and proposed network interfaces confluence
- [CONF] Apache Qpid > Current and proposed network interfaces confluence
- [CONF] Apache Qpid > Current and proposed network interfaces confluence
- [CONF] Apache Qpid > Current and proposed network interfaces confluence