From 8dbb78bd3089d73adca27fc767d4d0370672e60e Mon Sep 17 00:00:00 2001 From: Gordon Sim Date: Mon, 14 Mar 2011 11:44:14 +0000 Subject: QPID-3136: Merged r1080589 onto release branch git-svn-id: https://svn.apache.org/repos/asf/qpid/branches/0.10@1081339 13f79535-47bb-0310-9956-ffa450edef68 --- qpid/cpp/src/qpid/broker/Broker.cpp | 6 ++++-- qpid/cpp/src/qpid/broker/Broker.h | 1 + qpid/cpp/src/qpid/broker/Queue.cpp | 2 +- qpid/cpp/src/qpid/broker/ThresholdAlerts.cpp | 14 +++++++------- qpid/cpp/src/qpid/broker/ThresholdAlerts.h | 4 ++-- 5 files changed, 15 insertions(+), 12 deletions(-) diff --git a/qpid/cpp/src/qpid/broker/Broker.cpp b/qpid/cpp/src/qpid/broker/Broker.cpp index 695943854d..b20c346e5b 100644 --- a/qpid/cpp/src/qpid/broker/Broker.cpp +++ b/qpid/cpp/src/qpid/broker/Broker.cpp @@ -121,7 +121,8 @@ Broker::Options::Options(const std::string& name) : qmf2Support(true), qmf1Support(true), queueFlowStopRatio(80), - queueFlowResumeRatio(70) + queueFlowResumeRatio(70), + queueThresholdEventRatio(80) { int c = sys::SystemInfo::concurrency(); workerThreads=c+1; @@ -156,7 +157,8 @@ Broker::Options::Options(const std::string& name) : ("max-session-rate", optValue(maxSessionRate, "MESSAGES/S"), "Sets the maximum message rate per session (0=unlimited)") ("async-queue-events", optValue(asyncQueueEvents, "yes|no"), "Set Queue Events async, used for services like replication") ("default-flow-stop-threshold", optValue(queueFlowStopRatio, "%MESSAGES"), "Queue capacity level at which flow control is activated.") - ("default-flow-resume-threshold", optValue(queueFlowResumeRatio, "%MESSAGES"), "Queue capacity level at which flow control is de-activated."); + ("default-flow-resume-threshold", optValue(queueFlowResumeRatio, "%MESSAGES"), "Queue capacity level at which flow control is de-activated.") + ("default-event-threshold-ratio", optValue(queueThresholdEventRatio, "%age of limit"), "The ratio of any specified queue limit at which an event will be raised"); } const std::string empty; diff --git a/qpid/cpp/src/qpid/broker/Broker.h b/qpid/cpp/src/qpid/broker/Broker.h index 32c3d7936f..6d585bf614 100644 --- a/qpid/cpp/src/qpid/broker/Broker.h +++ b/qpid/cpp/src/qpid/broker/Broker.h @@ -120,6 +120,7 @@ public: bool qmf1Support; uint queueFlowStopRatio; // producer flow control: on uint queueFlowResumeRatio; // producer flow control: off + uint16_t queueThresholdEventRatio; private: std::string getHome(); diff --git a/qpid/cpp/src/qpid/broker/Queue.cpp b/qpid/cpp/src/qpid/broker/Queue.cpp index 02ec67f839..7a266fb4e3 100644 --- a/qpid/cpp/src/qpid/broker/Queue.cpp +++ b/qpid/cpp/src/qpid/broker/Queue.cpp @@ -776,7 +776,7 @@ void Queue::configureImpl(const FieldTable& _settings) setPolicy(QueuePolicy::createQueuePolicy(getName(), _settings)); } if (broker && broker->getManagementAgent()) { - ThresholdAlerts::observe(*this, *(broker->getManagementAgent()), _settings); + ThresholdAlerts::observe(*this, *(broker->getManagementAgent()), _settings, broker->getOptions().queueThresholdEventRatio); } //set this regardless of owner to allow use of no-local with exclusive consumers also diff --git a/qpid/cpp/src/qpid/broker/ThresholdAlerts.cpp b/qpid/cpp/src/qpid/broker/ThresholdAlerts.cpp index decb98df39..d616abadd6 100644 --- a/qpid/cpp/src/qpid/broker/ThresholdAlerts.cpp +++ b/qpid/cpp/src/qpid/broker/ThresholdAlerts.cpp @@ -126,12 +126,12 @@ void ThresholdAlerts::observe(Queue& queue, qpid::management::ManagementAgent& a } void ThresholdAlerts::observe(Queue& queue, qpid::management::ManagementAgent& agent, - const qpid::framing::FieldTable& settings) + const qpid::framing::FieldTable& settings, uint16_t limitRatio) { qpid::types::Variant::Map map; qpid::amqp_0_10::translate(settings, map); - observe(queue, agent, map); + observe(queue, agent, map, limitRatio); } template @@ -169,19 +169,19 @@ class Option }; void ThresholdAlerts::observe(Queue& queue, qpid::management::ManagementAgent& agent, - const qpid::types::Variant::Map& settings) + const qpid::types::Variant::Map& settings, uint16_t limitRatio) { //Note: aliases are keys defined by java broker Option repeatInterval("qpid.alert_repeat_gap", 60); repeatInterval.addAlias("x-qpid-minimum-alert-repeat-gap"); - //If no explicit threshold settings were given use 80% of any - //limit from the policy. + //If no explicit threshold settings were given use specified + //percentage of any limit from the policy. const QueuePolicy* policy = queue.getPolicy(); - Option countThreshold("qpid.alert_count", (uint32_t) (policy ? policy->getMaxCount()*0.8 : 0)); + Option countThreshold("qpid.alert_count", (uint32_t) (policy && limitRatio ? (policy->getMaxCount()*limitRatio/100) : 0)); countThreshold.addAlias("x-qpid-maximum-message-count"); - Option sizeThreshold("qpid.alert_size", (uint64_t) (policy ? policy->getMaxSize()*0.8 : 0)); + Option sizeThreshold("qpid.alert_size", (uint64_t) (policy && limitRatio ? (policy->getMaxSize()*limitRatio/100) : 0)); sizeThreshold.addAlias("x-qpid-maximum-message-size"); observe(queue, agent, countThreshold.get(settings), sizeThreshold.get(settings), repeatInterval.get(settings)); diff --git a/qpid/cpp/src/qpid/broker/ThresholdAlerts.h b/qpid/cpp/src/qpid/broker/ThresholdAlerts.h index e1f59252c4..c77722e700 100644 --- a/qpid/cpp/src/qpid/broker/ThresholdAlerts.h +++ b/qpid/cpp/src/qpid/broker/ThresholdAlerts.h @@ -55,9 +55,9 @@ class ThresholdAlerts : public QueueObserver const uint64_t sizeThreshold, const long repeatInterval); static void observe(Queue& queue, qpid::management::ManagementAgent& agent, - const qpid::framing::FieldTable& settings); + const qpid::framing::FieldTable& settings, uint16_t limitRatio); static void observe(Queue& queue, qpid::management::ManagementAgent& agent, - const qpid::types::Variant::Map& settings); + const qpid::types::Variant::Map& settings, uint16_t limitRatio); private: const std::string name; qpid::management::ManagementAgent& agent; -- cgit v1.2.1