qpid-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From conflue...@apache.org
Subject [CONF] Apache Qpid > Common Network Layer Interface
Date Thu, 23 Jul 2009 13:26:00 GMT
<html>
<head>
    <base href="http://cwiki.apache.org/confluence">
            <link rel="stylesheet" href="/confluence/s/1519/1/1/_/styles/combined.css?spaceKey=qpid&amp;forWysiwyg=true"
type="text/css">
    </head>
<body style="background-color: white" bgcolor="white">
<div id="pageContent">
<div id="notificationFormat">
<div class="wiki-content">
<div class="email">
     <h2><a href="http://cwiki.apache.org/confluence/display/qpid/Common+Network+Layer+Interface">Common
Network Layer Interface</a></h2>
     <h4>Page <b>edited</b> by             <a href="http://cwiki.apache.org/confluence/display/~ritchiem">Martin
Ritchie</a>
    </h4>
     
          <br/>
     <div class="notificationGreySide">
         <h2><a name="CommonNetworkLayerInterface-Purpose"></a>Purpose</h2>

<p>This 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 &amp; Client.
</p>

<p>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.</p>

<p>This document will provide sufficient information for architecture review and also
for input to task breakdown &amp; planning.</p>

<h2><a name="CommonNetworkLayerInterface-InterfaceRequirements"></a>Interface
Requirements</h2>

<ol>
	<li>Provide an API which supports pluggable network layers</li>
	<li>Facilitate the replacement of instantiations of MINA classes with an abstraction</li>
	<li>Expose methods to set TCP options (see main design doc for details)</li>
	<li>Provide support for configuration of related properties including buffer size</li>
	<li>Protocol driver should be non-blocking</li>
	<li>Network interface and drivers should be thread model agnostic</li>
	<li>Data will be passed around as byte arrays</li>
	<li>The Protocol driver will not perform any buffering</li>
	<li>Buffering will be the responsibility of the Network Driver</li>
	<li>Initial designs will only support TCP (see main design doc for info)</li>
	<li>The interface will support an SSLEngine</li>
</ol>


<h2><a name="CommonNetworkLayerInterface-DesignDetails"></a>Design Details
</h2>

<h3><a name="CommonNetworkLayerInterface-CurrentInterface"></a>Current Interface</h3>

<p>Currently ...... (Add description of current transport code, including packages/key
classes/major problem areas are)</p>

<h3><a name="CommonNetworkLayerInterface-NewInterface"></a>New Interface
</h3>

<p>Skeleton code for the new interface objects is outline below, for illustrative purposes.</p>

<h3><a name="CommonNetworkLayerInterface-DataFlow"></a>Data Flow</h3>

<p>At the start of a connection the the NetworkDriver will pass data to a ProtocolFactory
which will handle protocol negotiation and return the ProtocolDriver to use or throw an exception
if no driver is available. </p>

<p>The network driver will call bytesReceived on the ProtocolDriver when data is recieved.
</p>

<p>Control lies primarily with the network driver. </p>

<p>Data comes in from the operating system, is read from the socket by the network driver
and given to the protocol drivers bytesReceived method. If the bytes represent the completion
of an AMQP frame the ProtocolDriver calls the handler for that frame. </p>

<p>The frame handler may request a frame to be written in response, in which case it
places the frame in the ProtocolDriver which signals to the NetworkDriver that it has data
to be written. </p>

<p><img src="/confluence/download/attachments/2327666/qpid-network-flow.png" align="absmiddle"
border="0" /></p>

<style type="text/css">
@import url(/confluence/download/resources/confluence.ext.code:code/shStyles.css);
</style>
<!--[if IE]>
<style type="text/css">
    .code textarea, .code input { padding: 0 !important; }
</style>
<![endif]-->
<script class="javascript" src="/confluence/download/resources/confluence.ext.code:code/shCore.js"></script>
<script class="javascript" src="/confluence/download/resources/confluence.ext.code:code/shBrushCSharp.js"></script>
<script class="javascript" src="/confluence/download/resources/confluence.ext.code:code/shBrushPhp.js"></script>
<script class="javascript" src="/confluence/download/resources/confluence.ext.code:code/shBrushJScript.js"></script>
<script class="javascript" src="/confluence/download/resources/confluence.ext.code:code/shBrushVb.js"></script>
<script class="javascript" src="/confluence/download/resources/confluence.ext.code:code/shBrushSql.js"></script>
<script class="javascript" src="/confluence/download/resources/confluence.ext.code:code/shBrushXml.js"></script>
<script class="javascript" src="/confluence/download/resources/confluence.ext.code:code/shBrushShell.js"></script>
<script class="javascript" src="/confluence/download/resources/confluence.ext.code:code/shBrushDelphi.js"></script>
<script class="javascript" src="/confluence/download/resources/confluence.ext.code:code/shBrushPython.js"></script>
<script class="javascript" src="/confluence/download/resources/confluence.ext.code:code/shBrushJava.js"></script>
<div class="code">
<textarea name="newcodemacro" class="java:nocontrols:nogutter" rows="10" readonly="readonly">public
interface ProtocolDriver 
{

  int bytesReceived(byte[] bytes, int offset, int length);

  byte[] bytesRead();

  // Called when the connection has been idle
  void idle();

  void close();
  
  void halfclose();

  void setDataReadyHandler(ProtocolDriverDataListener listener);

}

public class AMQProtocolDriver implements ProtocolDriver 
{
  int bytesReceived(byte[] bytes, int offset, int length)
  {
     // Parses bytes until it figures out which ProtocolDriver to use, constructs  one and
then passes through all data and other method calls. 
  }

}

public interface ProtocolDriverDataListener
{
    // Called by the ProtocolDriver when it has data ready to be written
    void protocolDriverDataReady();
}

public interface NetworkDriver implements ProtocolDriverDataListener
{
   void open(InetAddress destination);

   void bind(int port, InetAddress[] addresses);

   void close();

   // Returns number of bytes actually accepted
   int write(byte[] bytes, int offset, int length);

   // Use the preconfigured SSLEngine
   void setSSLEngine(SSLEngine engine);

   void setNetworkDriverConfiguration(NetworkDriverConfiguration config);

   void protocolDriverDataReady();
}

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);
}</textarea>
<script class="javascript">
    if(!window.newcodemacro_initialised)
    {
        window.newcodemacro_initialised = true;
        window.oldonloadmethod = window.onload;
        window.onload = function(){
            dp.SyntaxHighlighter.HighlightAll('newcodemacro');
            if(window.oldonloadmethod)
            {
                window.oldonloadmethod();
            }
        }
    }

</script>
</div>

     </div>
     <div id="commentsSection" class="wiki-content pageSection">
       <div style="float: right;">
            <a href="http://cwiki.apache.org/confluence/users/viewnotifications.action"
class="grey">Change Notification Preferences</a>
       </div>

       <a href="http://cwiki.apache.org/confluence/display/qpid/Common+Network+Layer+Interface">View
Online</a>
       |
       <a href="http://cwiki.apache.org/confluence/pages/diffpagesbyversion.action?pageId=2327666&revisedVersion=25&originalVersion=24">View
Change</a>
              |
       <a href="http://cwiki.apache.org/confluence/display/qpid/Common+Network+Layer+Interface?showComments=true&amp;showCommentArea=true#addcomment">Add
Comment</a>
            </div>
</div>
</div>
</div>
</div>
</body>
</html>

---------------------------------------------------------------------
Apache Qpid - AMQP Messaging Implementation
Project:      http://qpid.apache.org
Use/Interact: mailto:commits-subscribe@qpid.apache.org


Mime
View raw message