diff options
author | Alan Conway <aconway@apache.org> | 2012-02-17 14:54:46 +0000 |
---|---|---|
committer | Alan Conway <aconway@apache.org> | 2012-02-17 14:54:46 +0000 |
commit | 0a8773c335509c2b9e9b96df360de190a266dcad (patch) | |
tree | 288469c17dacc37199b5f77498965fee7e778d95 /cpp/src/qpid/broker/MessageMap.cpp | |
parent | d82ce6836f7f0e4f7d647b2dc603141f549869d3 (diff) | |
download | qpid-python-0a8773c335509c2b9e9b96df360de190a266dcad.tar.gz |
QPID-3603: Merge new HA foundations.
Merged from qpid-3603-7. This is basic support for the new HA approach.
For information & limitations see qpid/cpp/design_docs/new-ha-design.txt.
git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk/qpid@1245587 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'cpp/src/qpid/broker/MessageMap.cpp')
-rw-r--r-- | cpp/src/qpid/broker/MessageMap.cpp | 36 |
1 files changed, 11 insertions, 25 deletions
diff --git a/cpp/src/qpid/broker/MessageMap.cpp b/cpp/src/qpid/broker/MessageMap.cpp index 39e23df533..048df45434 100644 --- a/cpp/src/qpid/broker/MessageMap.cpp +++ b/cpp/src/qpid/broker/MessageMap.cpp @@ -27,6 +27,8 @@ namespace { const std::string EMPTY; } +bool MessageMap::deleted(const QueuedMessage&) { return true; } + std::string MessageMap::getKey(const QueuedMessage& message) { const framing::FieldTable* ft = message.payload->getApplicationHeaders(); @@ -44,7 +46,7 @@ bool MessageMap::empty() return messages.empty(); } -void MessageMap::reinsert(const QueuedMessage& message) +void MessageMap::release(const QueuedMessage& message) { std::string key = getKey(message); Index::iterator i = index.find(key); @@ -54,7 +56,7 @@ void MessageMap::reinsert(const QueuedMessage& message) } //else message has already been replaced } -bool MessageMap::remove(const framing::SequenceNumber& position, QueuedMessage& message) +bool MessageMap::acquire(const framing::SequenceNumber& position, QueuedMessage& message) { Ordering::iterator i = messages.find(position); if (i != messages.end()) { @@ -77,38 +79,22 @@ bool MessageMap::find(const framing::SequenceNumber& position, QueuedMessage& me } } -bool MessageMap::next(const framing::SequenceNumber& position, QueuedMessage& message) +bool MessageMap::browse(const framing::SequenceNumber& position, QueuedMessage& message, bool) { - if (!messages.empty() && position < front().position) { - message = front(); + Ordering::iterator i = messages.lower_bound(position+1); + if (i != messages.end()) { + message = i->second; return true; } else { - Ordering::iterator i = messages.lower_bound(position+1); - if (i != messages.end()) { - message = i->second; - return true; - } else { - return false; - } + return false; } } -QueuedMessage& MessageMap::front() -{ - return messages.begin()->second; -} - -void MessageMap::pop() -{ - QueuedMessage dummy; - pop(dummy); -} - -bool MessageMap::pop(QueuedMessage& out) +bool MessageMap::consume(QueuedMessage& message) { Ordering::iterator i = messages.begin(); if (i != messages.end()) { - out = i->second; + message = i->second; erase(i); return true; } else { |