You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@qpid.apache.org by ac...@apache.org on 2011/10/31 13:00:15 UTC

svn commit: r1195424 - in /qpid/branches/qpid-2920-active/qpid/cpp/src/qpid/cluster/exp: Core.h MessageHandler.cpp QueueContext.cpp QueueContext.h QueueHandler.h overview.h

Author: aconway
Date: Mon Oct 31 12:00:15 2011
New Revision: 1195424

URL: http://svn.apache.org/viewvc?rev=1195424&view=rev
Log:
QPID-2920: Updated cluster/exp/overview.h & other comments.

Modified:
    qpid/branches/qpid-2920-active/qpid/cpp/src/qpid/cluster/exp/Core.h
    qpid/branches/qpid-2920-active/qpid/cpp/src/qpid/cluster/exp/MessageHandler.cpp
    qpid/branches/qpid-2920-active/qpid/cpp/src/qpid/cluster/exp/QueueContext.cpp
    qpid/branches/qpid-2920-active/qpid/cpp/src/qpid/cluster/exp/QueueContext.h
    qpid/branches/qpid-2920-active/qpid/cpp/src/qpid/cluster/exp/QueueHandler.h
    qpid/branches/qpid-2920-active/qpid/cpp/src/qpid/cluster/exp/overview.h

Modified: qpid/branches/qpid-2920-active/qpid/cpp/src/qpid/cluster/exp/Core.h
URL: http://svn.apache.org/viewvc/qpid/branches/qpid-2920-active/qpid/cpp/src/qpid/cluster/exp/Core.h?rev=1195424&r1=1195423&r2=1195424&view=diff
==============================================================================
--- qpid/branches/qpid-2920-active/qpid/cpp/src/qpid/cluster/exp/Core.h (original)
+++ qpid/branches/qpid-2920-active/qpid/cpp/src/qpid/cluster/exp/Core.h Mon Oct 31 12:00:15 2011
@@ -55,7 +55,7 @@ class BrokerContext;
  * Holds together the various objects that implement cluster behavior,
  * and holds state that is shared by multiple components.
  *
- * Thread safe: called from broker connection threads and CPG dispatch threads.
+ * Thread safe: called from broker broker threads and CPG dispatch threads.
  */
 class Core
 {

Modified: qpid/branches/qpid-2920-active/qpid/cpp/src/qpid/cluster/exp/MessageHandler.cpp
URL: http://svn.apache.org/viewvc/qpid/branches/qpid-2920-active/qpid/cpp/src/qpid/cluster/exp/MessageHandler.cpp?rev=1195424&r1=1195423&r2=1195424&view=diff
==============================================================================
--- qpid/branches/qpid-2920-active/qpid/cpp/src/qpid/cluster/exp/MessageHandler.cpp (original)
+++ qpid/branches/qpid-2920-active/qpid/cpp/src/qpid/cluster/exp/MessageHandler.cpp Mon Oct 31 12:00:15 2011
@@ -100,7 +100,7 @@ void MessageHandler::acquire(const std::
     QPID_LOG(trace, "cluster: message " << q << "[" << position
              << "] acquired by " << PrettyId(sender(), self()));
     // Note acquires from other members. My own acquires were executed in
-    // the connection thread
+    // the broker thread
     if (sender() != self()) {
         boost::shared_ptr<Queue> queue = findQueue(q, "cluster: acquire");
         QueuedMessage qm;
@@ -126,7 +126,7 @@ void MessageHandler::dequeue(const std::
     // complete the ack that initiated the dequeue at this point, see
     // BrokerContext::dequeue
 
-    // My own dequeues were processed in the connection thread before multicasting.
+    // My own dequeues were processed in the broker thread before multicasting.
     if (sender() != self()) {
         boost::shared_ptr<Queue> queue = findQueue(q, "cluster: dequeue");
         QueuedMessage qm = QueueContext::get(*queue)->dequeue(position);

Modified: qpid/branches/qpid-2920-active/qpid/cpp/src/qpid/cluster/exp/QueueContext.cpp
URL: http://svn.apache.org/viewvc/qpid/branches/qpid-2920-active/qpid/cpp/src/qpid/cluster/exp/QueueContext.cpp?rev=1195424&r1=1195423&r2=1195424&view=diff
==============================================================================
--- qpid/branches/qpid-2920-active/qpid/cpp/src/qpid/cluster/exp/QueueContext.cpp (original)
+++ qpid/branches/qpid-2920-active/qpid/cpp/src/qpid/cluster/exp/QueueContext.cpp Mon Oct 31 12:00:15 2011
@@ -80,7 +80,7 @@ void QueueContext::replicaState(
 
 // FIXME aconway 2011-07-27: Dont spin the token on an empty queue.
 
-// Called in connection threads when a consumer is added
+// Called in broker threads when a consumer is added
 void QueueContext::consume(size_t n) {
     sys::Mutex::ScopedLock l(lock);
     consumers = n;
@@ -88,7 +88,7 @@ void QueueContext::consume(size_t n) {
         framing::ClusterQueueSubscribeBody(framing::ProtocolVersion(), queue.getName()));
 }
 
-// Called in connection threads when a consumer is cancelled
+// Called in broker threads when a consumer is cancelled
 void QueueContext::cancel(size_t n) {
     sys::Mutex::ScopedLock l(lock);
     consumers = n;

Modified: qpid/branches/qpid-2920-active/qpid/cpp/src/qpid/cluster/exp/QueueContext.h
URL: http://svn.apache.org/viewvc/qpid/branches/qpid-2920-active/qpid/cpp/src/qpid/cluster/exp/QueueContext.h?rev=1195424&r1=1195423&r2=1195424&view=diff
==============================================================================
--- qpid/branches/qpid-2920-active/qpid/cpp/src/qpid/cluster/exp/QueueContext.h (original)
+++ qpid/branches/qpid-2920-active/qpid/cpp/src/qpid/cluster/exp/QueueContext.h Mon Oct 31 12:00:15 2011
@@ -63,12 +63,12 @@ class QueueContext : public RefCounted {
      */
     void stopped();
 
-    /** Called in connection thread when a consumer is added.
+    /** Called in broker thread when a consumer is added.
      *@param n: nubmer of consumers after new one is added.
      */
     void consume(size_t n);
 
-    /** Called in connection thread when a consumer is cancelled on the queue.
+    /** Called in broker thread when a consumer is cancelled on the queue.
      *@param n: nubmer of consumers after the cancel.
      */
     void cancel(size_t n);

Modified: qpid/branches/qpid-2920-active/qpid/cpp/src/qpid/cluster/exp/QueueHandler.h
URL: http://svn.apache.org/viewvc/qpid/branches/qpid-2920-active/qpid/cpp/src/qpid/cluster/exp/QueueHandler.h?rev=1195424&r1=1195423&r2=1195424&view=diff
==============================================================================
--- qpid/branches/qpid-2920-active/qpid/cpp/src/qpid/cluster/exp/QueueHandler.h (original)
+++ qpid/branches/qpid-2920-active/qpid/cpp/src/qpid/cluster/exp/QueueHandler.h Mon Oct 31 12:00:15 2011
@@ -66,7 +66,7 @@ class QueueHandler : public framing::AMQ
 
     void add(boost::shared_ptr<broker::Queue>);
 
-    // NB: These functions ar called in connection threads, not deliver threads.
+    // NB: These functions ar called in broker threads, not deliver threads.
     void acquired(const broker::QueuedMessage& qm);
     void empty(const broker::Queue& q);
 

Modified: qpid/branches/qpid-2920-active/qpid/cpp/src/qpid/cluster/exp/overview.h
URL: http://svn.apache.org/viewvc/qpid/branches/qpid-2920-active/qpid/cpp/src/qpid/cluster/exp/overview.h?rev=1195424&r1=1195423&r2=1195424&view=diff
==============================================================================
--- qpid/branches/qpid-2920-active/qpid/cpp/src/qpid/cluster/exp/overview.h (original)
+++ qpid/branches/qpid-2920-active/qpid/cpp/src/qpid/cluster/exp/overview.h Mon Oct 31 12:00:15 2011
@@ -1,15 +1,66 @@
 // This file is documentation in doxygen format.
 /**
 
-<h1>New cluster implementation overview</h>
+<h1>New Cluster Implementation Overview</h>
 
-Naming conventions: There are 3 types of classes indicated by a suffix on class names:
+<h2>Terms and Naming Conventions</h2>
 
-- *Handler: Dispatch CPG messages by calling Replica objects in the deliver thread.
+Deliver thread: Thread that is dispatching delivered CPG events.
 
-- *Replica: State that is replicated to the entire cluster.
-  Only called by Handlers in the deliver thread. May call on Contexts.
+Broker thread: Thread that is serving a Broker connection.
+
+Local/remote: For a given action the "local" broker is the one
+directly connected to the client in question. The others are "remote".
+
+Contended: a queue is contended if it has subscribes on two different
+brokers. It is uncontended if all subscribers are on the same broker.
+
+There are 3 types of classes indicated by a suffix on class names:
+
+- *Handler: Implements a class from cluster.xml. Called only in the
+   CPG deliver thread to dispatch an XML controls. Calls on *Replica
+   or *Context objects.
+
+- *Replica: Holds state that is replicated to the entire cluster.
+  Called only *Handler in the CPG deliver thread. May call on *Context
+  objects.
+
+- *Context: Holds state private to this member and associated with a
+  local object such as the Broker or a Queue. Can be called in CPG
+  deliver and broker threads.
+
+f<h2>Overview of Message Lifecycle</h2>
+
+BrokerContext implements the broker::Cluster interface, it is the
+point of contact with the Broker.  When a message is delivered locally
+the broker calls BrokerContext::enqueue.  This multicasts the message
+and delays delivery on the local broker by returning false.
+
+On self-delivery the local broker does the enqueue. This is
+synchronized with delivery on the other brokers so that all message
+have the same sequence numbers on their queues. We use queue+sequence
+no. to identify messages in the cluster.
+
+QueueReplica and QueueContext track the subscriptions for a queue. An
+uncontended queue can serve local consumers using the standard broker
+scheme. A queue can be "stopped" meaning no consumers can consume from
+it, or "active" meaning consumers can consume as on a stand-alone
+broker.
+
+An uncontended queue is active. A contended queue is active on only
+one broker which is said to hold the "lock" for that queue. It is
+stopped on all others. The lock is passed on a timeout.
+
+A broker with an active queue multicasts acquire and dequeue events
+for that queue so other brokers can stay in sync. In the case of a
+contended queue the broker sends acquire/dequeue events for its
+activity before passing the lock.
+
+We use multipe CPG groups to make better use of CPUs. Events about a
+given queue always uses the same CPG group, different queues may use
+different groups. There is a fixed set of groups, queue names are
+hashed to pick the gruop for each queue.
+
+// FIXME aconway 2011-10-31: other schemes than hashing?
 
-- *Context: State private to this member and associated with a local entity
-  such as the Broker or a Queue. Called in deliver and connection threads.
 **/



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