diff options
author | Gordon Sim <gsim@apache.org> | 2006-12-05 17:43:00 +0000 |
---|---|---|
committer | Gordon Sim <gsim@apache.org> | 2006-12-05 17:43:00 +0000 |
commit | 722b16a1a7bbde82a4cd82c99a0e29d31d0545ca (patch) | |
tree | 4866c7dc7e3e85a9f62ce6512ee1a569a4882e20 /cpp/lib/broker/QueuePolicy.cpp | |
parent | 96aa6c6e76ffa946192778d69d36d4c372a0de7b (diff) | |
download | qpid-python-722b16a1a7bbde82a4cd82c99a0e29d31d0545ca.tar.gz |
Allow settings to be set and persisted for queues.
Define policy based on these settings.
git-svn-id: https://svn.apache.org/repos/asf/incubator/qpid/trunk/qpid@482723 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'cpp/lib/broker/QueuePolicy.cpp')
-rw-r--r-- | cpp/lib/broker/QueuePolicy.cpp | 28 |
1 files changed, 27 insertions, 1 deletions
diff --git a/cpp/lib/broker/QueuePolicy.cpp b/cpp/lib/broker/QueuePolicy.cpp index 3cf0882695..055d415226 100644 --- a/cpp/lib/broker/QueuePolicy.cpp +++ b/cpp/lib/broker/QueuePolicy.cpp @@ -21,8 +21,14 @@ #include <QueuePolicy.h> using namespace qpid::broker; +using namespace qpid::framing; -QueuePolicy::QueuePolicy(u_int32_t _maxCount, u_int64_t _maxSize) : maxCount(_maxCount), maxSize(_maxSize) {} +QueuePolicy::QueuePolicy(u_int32_t _maxCount, u_int64_t _maxSize) : + maxCount(_maxCount), maxSize(_maxSize) {} + +QueuePolicy::QueuePolicy(const FieldTable& settings) : + maxCount(getInt(settings, maxCountKey, 0)), + maxSize(getInt(settings, maxSizeKey, 0)) {} void QueuePolicy::enqueued(Message::shared_ptr& msg, MessageStore* store) { @@ -47,3 +53,23 @@ bool QueuePolicy::checkSize(Message::shared_ptr& msg) return maxSize && (size += msg->contentSize()) > maxSize; } +void QueuePolicy::update(FieldTable& settings) +{ + if (maxCount) settings.setInt(maxCountKey, maxCount); + if (maxSize) settings.setInt(maxSizeKey, maxSize); +} + + +int QueuePolicy::getInt(const FieldTable& settings, const std::string& key, int defaultValue) +{ + //Note: currently field table only contain signed 32 bit ints, which + // restricts the values that can be set on the queue policy. + try { + return settings.getInt(key); + } catch (FieldNotFoundException& ignore) { + return defaultValue; + } +} + +const std::string QueuePolicy::maxCountKey("qpid.max_count"); +const std::string QueuePolicy::maxSizeKey("qpid.max_size"); |