diff options
| author | Alan Conway <aconway@apache.org> | 2010-01-27 22:20:51 +0000 |
|---|---|---|
| committer | Alan Conway <aconway@apache.org> | 2010-01-27 22:20:51 +0000 |
| commit | 1297c818282f26838776df418d846e07457a7f7f (patch) | |
| tree | d69c3b15f76b9d83a62462df3ca5211a45be7a4b /cpp/src/qpid/management | |
| parent | d0df2e739d5fba4bfb9f549720518e55d6fa9c9c (diff) | |
| download | qpid-python-1297c818282f26838776df418d846e07457a7f7f.tar.gz | |
Added PeriodicTimer interface for periodic tasks that need cluster synchronization.
The ManagementAgent's periodic prociessing uses PeriodicTimer.
PeriodicTimerImpl is the default implementation for stand-alone
brokers, simple wrapper for sys::Timer.
git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk/qpid@903866 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'cpp/src/qpid/management')
| -rw-r--r-- | cpp/src/qpid/management/ManagementAgent.cpp | 18 | ||||
| -rw-r--r-- | cpp/src/qpid/management/ManagementAgent.h | 13 |
2 files changed, 7 insertions, 24 deletions
diff --git a/cpp/src/qpid/management/ManagementAgent.cpp b/cpp/src/qpid/management/ManagementAgent.cpp index 378e150a0f..9f7d8046d4 100644 --- a/cpp/src/qpid/management/ManagementAgent.cpp +++ b/cpp/src/qpid/management/ManagementAgent.cpp @@ -91,10 +91,12 @@ void ManagementAgent::configure(const string& _dataDir, uint16_t _interval, dataDir = _dataDir; interval = _interval; broker = _broker; - timer = &_broker->getTimer(); + timer = &_broker->getPeriodicTimer(); threadPoolSize = _threads; ManagementObject::maxThreads = threadPoolSize; - timer->add (new Periodic(*this, interval)); + timer->add (boost::bind(&ManagementAgent::periodicProcessing, this), + interval * sys::TIME_SEC, + "ManagementAgent::periodicProcessing"); // Get from file or generate and save to file. if (dataDir.empty()) @@ -231,17 +233,6 @@ void ManagementAgent::raiseEvent(const ManagementEvent& event, severity_t severi "console.event.1.0." + event.getPackageName() + "." + event.getEventName()); } -ManagementAgent::Periodic::Periodic (ManagementAgent& _agent, uint32_t _seconds) - : TimerTask (qpid::sys::Duration ((_seconds ? _seconds : 1) * qpid::sys::TIME_SEC)), agent(_agent) {} - -ManagementAgent::Periodic::~Periodic () {} - -void ManagementAgent::Periodic::fire () -{ - agent.timer->add (new Periodic (agent, agent.interval)); - agent.periodicProcessing (); -} - void ManagementAgent::clientAdded (const std::string& routingKey) { if (routingKey.find("console") != 0) @@ -332,6 +323,7 @@ void ManagementAgent::periodicProcessing (void) { #define BUFSIZE 65536 #define HEADROOM 4096 + QPID_LOG(trace, "Management agent periodic processing") Mutex::ScopedLock lock (userLock); char msgChars[BUFSIZE]; uint32_t contentSize; diff --git a/cpp/src/qpid/management/ManagementAgent.h b/cpp/src/qpid/management/ManagementAgent.h index 1c06e5896b..3dea8ce3c7 100644 --- a/cpp/src/qpid/management/ManagementAgent.h +++ b/cpp/src/qpid/management/ManagementAgent.h @@ -26,7 +26,7 @@ #include "qpid/broker/Exchange.h" #include "qpid/framing/Uuid.h" #include "qpid/sys/Mutex.h" -#include "qpid/sys/Timer.h" +#include "qpid/sys/PeriodicTimer.h" #include "qpid/broker/ConnectionToken.h" #include "qpid/management/ManagementObject.h" #include "qpid/management/ManagementEvent.h" @@ -105,15 +105,6 @@ public: void importSchemas(framing::Buffer& inBuf); private: - struct Periodic : public qpid::sys::TimerTask - { - ManagementAgent& agent; - - Periodic (ManagementAgent& agent, uint32_t seconds); - virtual ~Periodic (); - void fire (); - }; - // Storage for tracking remote management agents, attached via the client // management agent API. // @@ -205,7 +196,7 @@ private: std::string dataDir; uint16_t interval; qpid::broker::Broker* broker; - qpid::sys::Timer* timer; + qpid::sys::PeriodicTimer* timer; uint16_t bootSequence; uint32_t nextObjectId; uint32_t brokerBank; |
