diff options
| author | Alan Conway <aconway@apache.org> | 2010-01-29 22:59:09 +0000 |
|---|---|---|
| committer | Alan Conway <aconway@apache.org> | 2010-01-29 22:59:09 +0000 |
| commit | a78bf7b9144ed3db8e798124595f48fc75231cce (patch) | |
| tree | b7284043fe639a2c6a880fc33836ce0b51d21b7e /cpp/src/qpid/management | |
| parent | 726b23f43478a85b961365e4de3a9302a261f6b3 (diff) | |
| download | qpid-python-a78bf7b9144ed3db8e798124595f48fc75231cce.tar.gz | |
Replace PeriodicTimer with ClusterTimer, which inherits from Timer.
git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk/qpid@904656 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'cpp/src/qpid/management')
| -rw-r--r-- | cpp/src/qpid/management/ManagementAgent.cpp | 26 | ||||
| -rw-r--r-- | cpp/src/qpid/management/ManagementAgent.h | 17 |
2 files changed, 36 insertions, 7 deletions
diff --git a/cpp/src/qpid/management/ManagementAgent.cpp b/cpp/src/qpid/management/ManagementAgent.cpp index 9f7d8046d4..e00f394a01 100644 --- a/cpp/src/qpid/management/ManagementAgent.cpp +++ b/cpp/src/qpid/management/ManagementAgent.cpp @@ -52,7 +52,8 @@ ManagementAgent::RemoteAgent::~RemoteAgent () } ManagementAgent::ManagementAgent () : - threadPoolSize(1), interval(10), broker(0), startTime(uint64_t(Duration(now()))) + threadPoolSize(1), interval(10), broker(0), timer(0), + startTime(uint64_t(Duration(now()))) { nextObjectId = 1; brokerBank = 1; @@ -91,12 +92,8 @@ void ManagementAgent::configure(const string& _dataDir, uint16_t _interval, dataDir = _dataDir; interval = _interval; broker = _broker; - timer = &_broker->getPeriodicTimer(); threadPoolSize = _threads; ManagementObject::maxThreads = threadPoolSize; - 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()) @@ -135,6 +132,12 @@ void ManagementAgent::configure(const string& _dataDir, uint16_t _interval, } } +void ManagementAgent::pluginsInitialized() { + // Do this here so cluster plugin has the chance to set up the timer. + timer = &broker->getClusterTimer(); + timer->add(new Periodic(*this, interval)); +} + void ManagementAgent::writeData () { string filename (dataDir + "/.mbrokerdata"); @@ -233,6 +236,19 @@ 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), + "ManagementAgent::periodicProcessing"), + 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) diff --git a/cpp/src/qpid/management/ManagementAgent.h b/cpp/src/qpid/management/ManagementAgent.h index ca8bfe97ed..b9ac54c064 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/PeriodicTimer.h" +#include "qpid/sys/Timer.h" #include "qpid/broker/ConnectionToken.h" #include "qpid/management/ManagementObject.h" #include "qpid/management/ManagementEvent.h" @@ -65,8 +65,12 @@ public: ManagementAgent (); virtual ~ManagementAgent (); + /** Called before plugins are initialized */ void configure (const std::string& dataDir, uint16_t interval, qpid::broker::Broker* broker, int threadPoolSize); + /** Called after plugins are initialized. */ + void pluginsInitialized(); + void setInterval (uint16_t _interval) { interval = _interval; } void setExchange (qpid::broker::Exchange::shared_ptr mgmtExchange, qpid::broker::Exchange::shared_ptr directExchange); @@ -112,6 +116,15 @@ public: void setBootSequence(uint16_t b) { bootSequence = b; } 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. // @@ -203,7 +216,7 @@ private: std::string dataDir; uint16_t interval; qpid::broker::Broker* broker; - qpid::sys::PeriodicTimer* timer; + qpid::sys::Timer* timer; uint16_t bootSequence; uint32_t nextObjectId; uint32_t brokerBank; |
