diff options
author | Alan Conway <aconway@apache.org> | 2010-03-12 20:11:31 +0000 |
---|---|---|
committer | Alan Conway <aconway@apache.org> | 2010-03-12 20:11:31 +0000 |
commit | ef9268528d3147173dfb0d2ef707ee3e4fc4f210 (patch) | |
tree | 4d8a9851683812bd04392f57c695a5143c80ca79 /cpp/src/qpid/cluster/StoreStatus.cpp | |
parent | 937fe6e7295efff28cb680642fca28ebf65e7d4e (diff) | |
download | qpid-python-ef9268528d3147173dfb0d2ef707ee3e4fc4f210.tar.gz |
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
Diffstat (limited to 'cpp/src/qpid/cluster/StoreStatus.cpp')
-rw-r--r-- | cpp/src/qpid/cluster/StoreStatus.cpp | 39 |
1 files changed, 30 insertions, 9 deletions
diff --git a/cpp/src/qpid/cluster/StoreStatus.cpp b/cpp/src/qpid/cluster/StoreStatus.cpp index 648fcfbbd5..b44c0e1a9a 100644 --- a/cpp/src/qpid/cluster/StoreStatus.cpp +++ b/cpp/src/qpid/cluster/StoreStatus.cpp @@ -21,6 +21,7 @@ #include "StoreStatus.h" #include "qpid/Exception.h" #include "qpid/Msg.h" +#include "qpid/log/Statement.h" #include <boost/filesystem/path.hpp> #include <boost/filesystem/fstream.hpp> #include <boost/filesystem/operations.hpp> @@ -54,24 +55,39 @@ Uuid loadUuid(const fs::path& path) { Uuid ret; if (exists(path)) { fs::ifstream i(path); - throw_exceptions(i); - i >> ret; + try { + throw_exceptions(i); + i >> ret; + } catch (const std::exception& e) { + QPID_LOG(error, "Cant load UUID from " << path.string() << ": " << e.what()); + throw; + } } return ret; } void saveUuid(const fs::path& path, const Uuid& uuid) { fs::ofstream o(path); - throw_exceptions(o); - o << uuid; + try { + throw_exceptions(o); + o << uuid; + } catch (const std::exception& e) { + QPID_LOG(error, "Cant save UUID to " << path.string() << ": " << e.what()); + throw; + } } framing::SequenceNumber loadSeqNum(const fs::path& path) { uint32_t n = 0; if (exists(path)) { fs::ifstream i(path); - throw_exceptions(i); - i >> n; + try { + throw_exceptions(i); + i >> n; + } catch (const std::exception& e) { + QPID_LOG(error, "Cant load sequence number from " << path.string() << ": " << e.what()); + throw; + } } return framing::SequenceNumber(n); } @@ -105,9 +121,14 @@ void StoreStatus::save() { create_directory(dir); saveUuid(dir/CLUSTER_ID_FILE, clusterId); saveUuid(dir/SHUTDOWN_ID_FILE, shutdownId); - fs::ofstream o(dir/CONFIG_SEQ_FILE); - throw_exceptions(o); - o << configSeq.getValue(); + try { + fs::ofstream o(dir/CONFIG_SEQ_FILE); + throw_exceptions(o); + o << configSeq.getValue(); + } catch (const std::exception& e) { + QPID_LOG(error, "Cant save sequence number to " << (dir/CONFIG_SEQ_FILE).string() << ": " << e.what()); + throw; + } } catch (const std::exception&e) { throw Exception(QPID_MSG("Cannot save cluster store status: " << e.what())); |