Apache Qpid : Port server to new interface
This page last changed on Jul 29, 2009 by aidan.
Notes: Objectives
Overview of new implementationThis first phase confines the MINA dependency behind the NetworkDriver interface. As can be seen by comparison from the following diagram describing the 0.5 implementation, the changes to the flow of control are not significantly different. The only significant change is to decouple the protocol processing from the network processing. Work requiredAdd QpidByteBuffer
Implement NetworkDriverMINANetworkDriver class/*** * This class wraps the existing MINA implementation behind the NetworkDriver interface. This uses * the AsyncWritePoolingFilter to buffer network writes so that send() is not synchronous. */ public class MINANetworkDriver implements NetworkDriver extends IoHandlerAdapter { /** * Creates a concrete NetworkDriver which opens a connection to the specified address on the port * and starts the given ProtocolEngine instance using MINA */ static NetworkDriver open (int port, InetAddress destination, ProtocolEngine enginer, NetworkDriverConfiguration config); /** * Listens for incoming connections on the specified port and IPaddresses. Creates a new concrete * NetworkDriver for each incoming connection and creates a ProtocolEngine with the given factory */ 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) /** * Adds the data to an Event through AsynchWritePoolingFilter for writing to MINA */ void send(java.nio.ByteBuffer data) } Changes required to implement MINANetworkDriverIt replaces AMQPFastProtocolHandler and the majority of the implementation will be taken from that class. bind() will be taken from the existing org.apache.qpid.server.Main
Implementation of ProtocolEngine/*** * This class replaces the existing AMQMinaProtocolSession and implements the ProtocolEngine interface. It is * responsible for processing bytes into frames and for processing those frames. It is also responsible for * turning frames into bytes and passing them onto the NetworkDriver for writing. */ public class AMQProtocolEngine implements ProtocolEngine { /** * Processes data. It uses AMQDecoder to decode the frame and place it into a Job for later processing */ void received(java.nio.ByteBuffer data) void setNetworkDriver (NetworkDriver driver) /** * calls NetworkDriver.getRemoteAddress() */ SocketAddress getRemoteAddress() long getWrittenBytes() long getReadBytes() /** * Closes the protocol engine, aborts in-progress transactions etc. */ void closed() /** * Generates a heartbeat frame */ void writerIdle() /** * Closes the connection */ void readerIdle() } Changes required to implement AMQProtocolEngine
public class AMQProtocolEngineFactory implements ProtocolEngineFactory { // Returns a new instance of an AMQProtocolEngine ProtocolEngine newProtocolEngine() } Changes required to implement AMQProtocolEngineFactoryNo existing code needs to be changed here. The factory will simply create an AMQProtocolEngine and return it. Implement NetworkConfiguration
Transport layer selection in o.a.q.server.MainCurrently the broker's Main method contains setup code specific to MINA. Main needs to be modified to remove the MINA specific option (NIO, MultiIO, executor pool etc) processing from there. This should be replaced with creation of a Network Driver instance with configuration being picked up & applied in the same way as other subsystems are configured ie. from ServerConfiguration.
![]() ![]() ![]() ![]() |
![]() |
Document generated by Confluence on May 26, 2010 10:32 |