From ef9268528d3147173dfb0d2ef707ee3e4fc4f210 Mon Sep 17 00:00:00 2001 From: Alan Conway Date: Fri, 12 Mar 2010 20:11:31 +0000 Subject: New cluster member pushes store when joining an active cluster. Previously a broker with a clean store would not be able to join an active cluster because the shtudown-id did not match. This commit ensures that when a broker joins an active cluster, it always pushes its store regardless of status. Clean/dirty status is only compared when forming an initial cluster. This change required splitting initialization into two phases: PRE_INIT: occurs in the Cluster ctor during early-initialize. This phase determines whether or not to push the store. INIT: occurs after Cluster::initialize and does the remaining initialization chores. git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk/qpid@922412 13f79535-47bb-0310-9956-ffa450edef68 --- cpp/src/qpid/cluster/PollableQueue.h | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) (limited to 'cpp/src/qpid/cluster/PollableQueue.h') diff --git a/cpp/src/qpid/cluster/PollableQueue.h b/cpp/src/qpid/cluster/PollableQueue.h index 2aed6de5b9..59d0bcd36a 100644 --- a/cpp/src/qpid/cluster/PollableQueue.h +++ b/cpp/src/qpid/cluster/PollableQueue.h @@ -31,6 +31,13 @@ namespace cluster { /** * More convenient version of PollableQueue that handles iterating * over the batch and error handling. + * + * Constructed in "bypass" mode where items are processed directly + * rather than put on the queue. This is important for the + * PRE_INIT stage when Cluster is pumping CPG dispatch directly + * before the poller has started. + * + * Calling start() starts the pollable queue and disabled bypass mode. */ template class PollableQueue : public sys::PollableQueue { public: @@ -41,7 +48,7 @@ template class PollableQueue : public sys::PollableQueue { const boost::shared_ptr& poller) : sys::PollableQueue(boost::bind(&PollableQueue::handleBatch, this, _1), poller), - callback(f), error(err), message(msg) + callback(f), error(err), message(msg), bypass(true) {} typename sys::PollableQueue::Batch::const_iterator @@ -62,10 +69,21 @@ template class PollableQueue : public sys::PollableQueue { } } + void push(const T& t) { + if (bypass) callback(t); + else sys::PollableQueue::push(t); + } + + void start() { + bypass = false; + sys::PollableQueue::start(); + } + private: Callback callback; ErrorCallback error; std::string message; + bool bypass; }; -- cgit v1.2.1