Author: aidan
Date: Sun Apr 20 04:11:59 2008
New Revision: 649909

URL: http://svn.apache.org/viewvc?rev=649909&view=rev
Log:
Merged revisions 649661-649908 via svnmerge from 
https://svn.apache.org/repos/asf/incubator/qpid/trunk

........
  r649666 | astitcher | 2008-04-18 20:44:25 +0100 (Fri, 18 Apr 2008) | 2 lines
  
  Split AsynchIOAcceptor into IOHandler and connection control code
........
  r649671 | aconway | 2008-04-18 20:56:27 +0100 (Fri, 18 Apr 2008) | 2 lines
  
  Fix test failure.
........
  r649689 | astitcher | 2008-04-18 22:03:49 +0100 (Fri, 18 Apr 2008) | 2 lines
  
  Refactored Acceptor code to allow multiple acceptors to be present in the 
broker
........
  r649691 | astitcher | 2008-04-18 22:10:42 +0100 (Fri, 18 Apr 2008) | 2 lines
  
  Added missed new include file
........

Added:
    
incubator/qpid/branches/thegreatmerge/qpid/cpp/src/qpid/sys/AsynchIOHandler.cpp
      - copied unchanged from r649691, 
incubator/qpid/trunk/qpid/cpp/src/qpid/sys/AsynchIOHandler.cpp
    
incubator/qpid/branches/thegreatmerge/qpid/cpp/src/qpid/sys/AsynchIOHandler.h
      - copied unchanged from r649691, 
incubator/qpid/trunk/qpid/cpp/src/qpid/sys/AsynchIOHandler.h
    incubator/qpid/branches/thegreatmerge/qpid/cpp/src/qpid/sys/TCPIOPlugin.cpp
      - copied unchanged from r649691, 
incubator/qpid/trunk/qpid/cpp/src/qpid/sys/TCPIOPlugin.cpp
Removed:
    
incubator/qpid/branches/thegreatmerge/qpid/cpp/src/qpid/sys/AsynchIOAcceptor.cpp
Modified:
    incubator/qpid/branches/thegreatmerge/   (props changed)
    incubator/qpid/branches/thegreatmerge/qpid/cpp/src/Makefile.am
    incubator/qpid/branches/thegreatmerge/qpid/cpp/src/qpid/Plugin.cpp
    incubator/qpid/branches/thegreatmerge/qpid/cpp/src/qpid/Plugin.h
    incubator/qpid/branches/thegreatmerge/qpid/cpp/src/qpid/broker/Broker.cpp
    incubator/qpid/branches/thegreatmerge/qpid/cpp/src/qpid/broker/Broker.h
    incubator/qpid/branches/thegreatmerge/qpid/cpp/src/qpid/sys/Acceptor.h
    
incubator/qpid/branches/thegreatmerge/qpid/cpp/src/tests/amqp_0_10/serialize.cpp

Propchange: incubator/qpid/branches/thegreatmerge/
------------------------------------------------------------------------------
--- svnmerge-integrated (original)
+++ svnmerge-integrated Sun Apr 20 04:11:59 2008
@@ -1 +1 @@
-/incubator/qpid/branches/M2.1:1-648207 /incubator/qpid/branches/M2.x:1-648207 
/incubator/qpid/trunk:1-649660
+/incubator/qpid/branches/M2.1:1-648207 /incubator/qpid/branches/M2.x:1-648207 
/incubator/qpid/trunk:1-649908

Modified: incubator/qpid/branches/thegreatmerge/qpid/cpp/src/Makefile.am
URL: 
http://svn.apache.org/viewvc/incubator/qpid/branches/thegreatmerge/qpid/cpp/src/Makefile.am?rev=649909&r1=649908&r2=649909&view=diff
==============================================================================
--- incubator/qpid/branches/thegreatmerge/qpid/cpp/src/Makefile.am (original)
+++ incubator/qpid/branches/thegreatmerge/qpid/cpp/src/Makefile.am Sun Apr 20 
04:11:59 2008
@@ -172,7 +172,7 @@
   qpid/Plugin.cpp \
   qpid/Url.cpp \
   qpid/sys/AggregateOutput.cpp \
-  qpid/sys/AsynchIOAcceptor.cpp \
+  qpid/sys/AsynchIOHandler.cpp \
   qpid/sys/Dispatcher.cpp \
   qpid/sys/Runnable.cpp \
   qpid/sys/SystemInfo.cpp \
@@ -259,7 +259,8 @@
   qpid/management/Manageable.cpp \
   qpid/management/ManagementAgent.cpp \
   qpid/management/ManagementExchange.cpp \
-  qpid/management/ManagementObject.cpp
+  qpid/management/ManagementObject.cpp \
+  qpid/sys/TCPIOPlugin.cpp
 
 libqpidclient_la_LIBADD = libqpidcommon.la
 libqpidclient_la_SOURCES =                     \
@@ -478,6 +479,7 @@
   qpid/sys/Acceptor.h \
   qpid/sys/AggregateOutput.h \
   qpid/sys/AsynchIO.h \
+  qpid/sys/AsynchIOHandler.h \
   qpid/sys/AtomicCount.h \
   qpid/sys/BlockingQueue.h \
   qpid/sys/Condition.h \

Modified: incubator/qpid/branches/thegreatmerge/qpid/cpp/src/qpid/Plugin.cpp
URL: 
http://svn.apache.org/viewvc/incubator/qpid/branches/thegreatmerge/qpid/cpp/src/qpid/Plugin.cpp?rev=649909&r1=649908&r2=649909&view=diff
==============================================================================
--- incubator/qpid/branches/thegreatmerge/qpid/cpp/src/qpid/Plugin.cpp 
(original)
+++ incubator/qpid/branches/thegreatmerge/qpid/cpp/src/qpid/Plugin.cpp Sun Apr 
20 04:11:59 2008
@@ -22,11 +22,20 @@
 
 namespace qpid {
 
-Plugin::Plugins Plugin::plugins;
+namespace {
+// This is a single threaded singleton implementation so
+// it is important to be sure that the first use of this
+// singleton is when the program is still single threaded
+Plugin::Plugins& thePlugins() {
+    static Plugin::Plugins plugins;
+
+    return plugins;
+}
+}
 
 Plugin::Plugin() {
     // Register myself.
-    plugins.push_back(this);
+    thePlugins().push_back(this);
 }
 
 Plugin::~Plugin() {}
@@ -34,7 +43,7 @@
 Options*  Plugin::getOptions() { return 0; }
 
 const Plugin::Plugins& Plugin::getPlugins() {
-    return plugins;
+    return thePlugins();
 }
 
 } // namespace qpid

Modified: incubator/qpid/branches/thegreatmerge/qpid/cpp/src/qpid/Plugin.h
URL: 
http://svn.apache.org/viewvc/incubator/qpid/branches/thegreatmerge/qpid/cpp/src/qpid/Plugin.h?rev=649909&r1=649908&r2=649909&view=diff
==============================================================================
--- incubator/qpid/branches/thegreatmerge/qpid/cpp/src/qpid/Plugin.h (original)
+++ incubator/qpid/branches/thegreatmerge/qpid/cpp/src/qpid/Plugin.h Sun Apr 20 
04:11:59 2008
@@ -88,9 +88,6 @@
      * Caller must not delete plugin pointers.
      */
     static const Plugins& getPlugins();
-
-  private:
-    static Plugins plugins;
 };
  
 } // namespace qpid

Modified: 
incubator/qpid/branches/thegreatmerge/qpid/cpp/src/qpid/broker/Broker.cpp
URL: 
http://svn.apache.org/viewvc/incubator/qpid/branches/thegreatmerge/qpid/cpp/src/qpid/broker/Broker.cpp?rev=649909&r1=649908&r2=649909&view=diff
==============================================================================
--- incubator/qpid/branches/thegreatmerge/qpid/cpp/src/qpid/broker/Broker.cpp 
(original)
+++ incubator/qpid/branches/thegreatmerge/qpid/cpp/src/qpid/broker/Broker.cpp 
Sun Apr 20 04:11:59 2008
@@ -260,8 +260,7 @@
 }
 
 void Broker::run() {
-
-    getAcceptor().run(poller, &factory);
+    accept();
        
     Dispatcher d(poller);
     int numIOThreads = config.workerThreads;
@@ -298,18 +297,6 @@
     }
 }
 
-uint16_t Broker::getPort() const  { return getAcceptor().getPort(); }
-
-Acceptor& Broker::getAcceptor() const {
-    if (!acceptor) {
-        const_cast<Acceptor::shared_ptr&>(acceptor) =
-            Acceptor::create(config.port,
-                             config.connectionBacklog);
-        QPID_LOG(info, "Listening on port " << getPort());
-    }
-    return *acceptor;
-}
-
 ManagementObject::shared_ptr Broker::GetManagementObject(void) const
 {
     return dynamic_pointer_cast<ManagementObject> (mgmtObject);
@@ -348,11 +335,41 @@
     return status;
 }
 
+boost::shared_ptr<Acceptor> Broker::getAcceptor() const {
+    assert(acceptors.size() > 0);
+#if 0
+    if (!acceptor) {
+        const_cast<Acceptor::shared_ptr&>(acceptor) =
+            Acceptor::create(config.port,
+                             config.connectionBacklog);
+        QPID_LOG(info, "Listening on port " << getPort());
+    }
+#endif
+    return acceptors[0];
+}
+
+void Broker::registerAccepter(Acceptor::shared_ptr acceptor) {
+    acceptors.push_back(acceptor);
+}
+
+// TODO: This can only work if there is only one acceptor
+uint16_t Broker::getPort() const  {
+    return getAcceptor()->getPort();
+}
+
+// TODO: This should iterate over all acceptors
+void Broker::accept() {
+    for (unsigned int i = 0; i < acceptors.size(); ++i)
+        acceptors[i]->run(poller, &factory);
+}
+
+
+// TODO: How to chose the acceptor to use for the connection
 void Broker::connect(
     const std::string& host, uint16_t port,
     sys::ConnectionCodec::Factory* f)
 {
-    getAcceptor().connect(poller, host, port, f ? f : &factory);
+    getAcceptor()->connect(poller, host, port, f ? f : &factory);
 }
 
 void Broker::connect(

Modified: 
incubator/qpid/branches/thegreatmerge/qpid/cpp/src/qpid/broker/Broker.h
URL: 
http://svn.apache.org/viewvc/incubator/qpid/branches/thegreatmerge/qpid/cpp/src/qpid/broker/Broker.h?rev=649909&r1=649908&r2=649909&view=diff
==============================================================================
--- incubator/qpid/branches/thegreatmerge/qpid/cpp/src/qpid/broker/Broker.h 
(original)
+++ incubator/qpid/branches/thegreatmerge/qpid/cpp/src/qpid/broker/Broker.h Sun 
Apr 20 04:11:59 2008
@@ -43,7 +43,6 @@
 #include "qpid/framing/FrameHandler.h"
 #include "qpid/framing/OutputHandler.h"
 #include "qpid/framing/ProtocolInitiation.h"
-#include "qpid/sys/Acceptor.h"
 #include "qpid/sys/Runnable.h"
 
 #include <vector>
@@ -51,6 +50,7 @@
 namespace qpid { 
 
 namespace sys {
+    class Acceptor;
     class Poller;
 }
 
@@ -124,6 +124,12 @@
     management::Manageable::status_t
         ManagementMethod (uint32_t methodId, management::Args& args);
     
+    /** Add to the broker's acceptors */
+    void registerAccepter(boost::shared_ptr<sys::Acceptor>);
+
+    /** Accept connections */
+    void accept();
+
     /** Create a connection to another broker. */
     void connect(const std::string& host, uint16_t port,
                  sys::ConnectionCodec::Factory* =0);
@@ -131,11 +137,9 @@
     void connect(const Url& url, sys::ConnectionCodec::Factory* =0);
 
   private:
-    sys::Acceptor& getAcceptor() const;
-
-    boost::shared_ptr<qpid::sys::Poller> poller;
+    boost::shared_ptr<sys::Poller> poller;
     Options config;
-    sys::Acceptor::shared_ptr acceptor;
+    std::vector< boost::shared_ptr<sys::Acceptor> > acceptors;
     MessageStore* store;
     DataDir dataDir;
 
@@ -149,6 +153,10 @@
     management::Broker::shared_ptr mgmtObject;
     Vhost::shared_ptr              vhostObject;
     System::shared_ptr             systemObject;
+
+    // TODO: There is no longer a single acceptor so the use of the following 
needs to be fixed
+    // For the present just return the first acceptor registered.
+    boost::shared_ptr<sys::Acceptor> getAcceptor() const;
 
     void declareStandardExchange(const std::string& name, const std::string& 
type);
 };

Modified: incubator/qpid/branches/thegreatmerge/qpid/cpp/src/qpid/sys/Acceptor.h
URL: 
http://svn.apache.org/viewvc/incubator/qpid/branches/thegreatmerge/qpid/cpp/src/qpid/sys/Acceptor.h?rev=649909&r1=649908&r2=649909&view=diff
==============================================================================
--- incubator/qpid/branches/thegreatmerge/qpid/cpp/src/qpid/sys/Acceptor.h 
(original)
+++ incubator/qpid/branches/thegreatmerge/qpid/cpp/src/qpid/sys/Acceptor.h Sun 
Apr 20 04:11:59 2008
@@ -35,7 +35,6 @@
 class Acceptor : public qpid::SharedObject<Acceptor>
 {
   public:
-    static Acceptor::shared_ptr create(int16_t port, int backlog);
     virtual ~Acceptor() = 0;
     virtual uint16_t getPort() const = 0;
     virtual std::string getHost() const = 0;

Modified: 
incubator/qpid/branches/thegreatmerge/qpid/cpp/src/tests/amqp_0_10/serialize.cpp
URL: 
http://svn.apache.org/viewvc/incubator/qpid/branches/thegreatmerge/qpid/cpp/src/tests/amqp_0_10/serialize.cpp?rev=649909&r1=649908&r2=649909&view=diff
==============================================================================
--- 
incubator/qpid/branches/thegreatmerge/qpid/cpp/src/tests/amqp_0_10/serialize.cpp
 (original)
+++ 
incubator/qpid/branches/thegreatmerge/qpid/cpp/src/tests/amqp_0_10/serialize.cpp
 Sun Apr 20 04:11:59 2008
@@ -348,9 +348,10 @@
     dp.exchange = "foo";
 
     Codec::encode(back_inserter(data))(dp);
-    uint16_t encodedBits=uint8_t(data[1]); // Little-endian
+    // Skip 4 bytes size, little-endian decode for pack bits.
+    uint16_t encodedBits=uint8_t(data[5]);
     encodedBits <<= 8;
-    encodedBits += uint8_t(data[0]);
+    encodedBits += uint8_t(data[4]);
     BOOST_CHECK_EQUAL(encodedBits, packBits(dp));
         
     data.clear();


Reply via email to