From e7b97eac85d94d739cba9d9a324e9c7319271278 Mon Sep 17 00:00:00 2001 From: Alan Conway Date: Thu, 25 Feb 2010 22:07:30 +0000 Subject: Last member of a cluster always has clean store. When a cluster is reduced to a single broker, it marks its store as clean regardless of how it is shut down. If we're down to a single member we know we want to use its store to recover as there are no others. git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk/qpid@916475 13f79535-47bb-0310-9956-ffa450edef68 --- cpp/src/qpid/cluster/Cluster.cpp | 6 ++++++ cpp/src/qpid/cluster/StoreStatus.cpp | 6 ++++++ cpp/src/qpid/cluster/StoreStatus.h | 6 +++--- 3 files changed, 15 insertions(+), 3 deletions(-) (limited to 'cpp/src/qpid') diff --git a/cpp/src/qpid/cluster/Cluster.cpp b/cpp/src/qpid/cluster/Cluster.cpp index e718819f48..08646e5a6b 100644 --- a/cpp/src/qpid/cluster/Cluster.cpp +++ b/cpp/src/qpid/cluster/Cluster.cpp @@ -914,6 +914,12 @@ void Cluster::memberUpdate(Lock& l) { size_t size = urls.size(); failoverExchange->updateUrls(urls); + if (store.hasStore()) { + // Mark store clean if I am the only broker, dirty otherwise. + if (size == 1) store.clean(Uuid(true)); + else store.dirty(clusterId); + } + if (size == 1 && lastSize > 1 && state >= CATCHUP) { QPID_LOG(notice, *this << " last broker standing, update queue policies"); lastBroker = true; diff --git a/cpp/src/qpid/cluster/StoreStatus.cpp b/cpp/src/qpid/cluster/StoreStatus.cpp index 947f81d596..648fcfbbd5 100644 --- a/cpp/src/qpid/cluster/StoreStatus.cpp +++ b/cpp/src/qpid/cluster/StoreStatus.cpp @@ -114,7 +114,12 @@ void StoreStatus::save() { } } +bool StoreStatus::hasStore() const { + return state != framing::cluster::STORE_STATE_NO_STORE; +} + void StoreStatus::dirty(const Uuid& clusterId_) { + if (!hasStore()) return; assert(clusterId_); clusterId = clusterId_; shutdownId = Uuid(); @@ -123,6 +128,7 @@ void StoreStatus::dirty(const Uuid& clusterId_) { } void StoreStatus::clean(const Uuid& shutdownId_) { + if (!hasStore()) return; assert(shutdownId_); state = STORE_STATE_CLEAN_STORE; shutdownId = shutdownId_; diff --git a/cpp/src/qpid/cluster/StoreStatus.h b/cpp/src/qpid/cluster/StoreStatus.h index 911b3a2ba2..2371f0424e 100644 --- a/cpp/src/qpid/cluster/StoreStatus.h +++ b/cpp/src/qpid/cluster/StoreStatus.h @@ -46,14 +46,14 @@ class StoreStatus const Uuid& getShutdownId() const { return shutdownId; } framing::SequenceNumber getConfigSeq() const { return configSeq; } - void dirty(const Uuid& start); // Start using the store. - void clean(const Uuid& stop); // Stop using the store. + void dirty(const Uuid& clusterId); // Mark the store in use by clusterId. + void clean(const Uuid& shutdownId); // Mark the store clean at shutdownId void setConfigSeq(framing::SequenceNumber seq); // Update the config seq number. void load(); void save(); - bool hasStore() { return state != framing::cluster::STORE_STATE_NO_STORE; } + bool hasStore() const; private: framing::cluster::StoreState state; -- cgit v1.2.1