Darryl L. Pierce
2010-May-25 14:54 UTC
[Ovirt-devel] [PATCH matahari] QMF-based heartbeats.
This code allows heartbeat events to be raised on the QMF transport. Signed-off-by: Darryl L. Pierce <dpierce at redhat.com> --- src/Makefile.am | 2 ++ src/host.cpp | 23 ++++++++--------------- src/qmf/hostagent.cpp | 5 ++++- src/qmf/hostagent.h | 7 +++++-- src/schema.xml | 6 ++++++ 5 files changed, 25 insertions(+), 18 deletions(-) diff --git a/src/Makefile.am b/src/Makefile.am index 498ee72..d830031 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -5,6 +5,8 @@ sbin_PROGRAMS = matahari first = qmf/com/redhat/matahari/Host.cpp generated_file_list = \ + qmf/com/redhat/matahari/EventHeartbeat.cpp \ + qmf/com/redhat/matahari/EventHeartbeat.h \ qmf/com/redhat/matahari/Host.h \ qmf/com/redhat/matahari/NetworkDevice.cpp \ qmf/com/redhat/matahari/NetworkDevice.h \ diff --git a/src/host.cpp b/src/host.cpp index 29b84ec..9b2ad29 100644 --- a/src/host.cpp +++ b/src/host.cpp @@ -79,33 +79,26 @@ Host::Host() } } -/* void -Host::setup(ManagementAgent* agent, HostAgent* hostAgent) +Host::update() { - // discover the aspects of the host - _processors.setup(agent, hostAgent); - _networkdevices = Platform::instance()->get_network_devices(); + _processors.update(); for(vector<NetworkDeviceAgent>::iterator iter = _networkdevices.begin(); iter != _networkdevices.end(); iter++) { - iter->setup(agent, hostAgent); + iter->update(); } -} -*/ -void -Host::update() -{ - _processors.update(); + time_t __time; + time(&__time); - for(vector<NetworkDeviceAgent>::iterator iter = _networkdevices.begin(); - iter != _networkdevices.end(); + for(set<HostListener*>::iterator iter = _listeners.begin(); + iter != _listeners.end(); iter++) { - iter->update(); + (*iter)->heartbeat((unsigned long)__time); } } diff --git a/src/qmf/hostagent.cpp b/src/qmf/hostagent.cpp index 9807f65..7376f69 100644 --- a/src/qmf/hostagent.cpp +++ b/src/qmf/hostagent.cpp @@ -20,7 +20,7 @@ #include "hostagent.h" #include <qpid/agent/ManagementAgent.h> -namespace _qmf = qmf::com::redhat::matahari; +#include "qmf/com/redhat/matahari/EventHeartbeat.h" HostAgent::HostAgent(Host& host) :_host(host) @@ -35,6 +35,8 @@ HostAgent::~HostAgent() void HostAgent::setup(ManagementAgent* agent) { + this->_agent = agent; + _management_object = new _qmf::Host(agent, this); agent->addObject(_management_object); @@ -65,4 +67,5 @@ HostAgent::ManagementMethod(uint32_t method, Args& arguments, string& text) void HostAgent::heartbeat(unsigned long timestamp) { + this->_agent->raiseEvent(_qmf::EventHeartbeat(timestamp)); } diff --git a/src/qmf/hostagent.h b/src/qmf/hostagent.h index 6d2f2a0..f9a6f8e 100644 --- a/src/qmf/hostagent.h +++ b/src/qmf/hostagent.h @@ -31,11 +31,14 @@ using namespace qpid::management; using namespace std; +namespace _qmf = qmf::com::redhat::matahari; + class HostAgent : public Manageable, public HostListener { private: - qmf::com::redhat::matahari::Host* _management_object; - Host& _host; + _qmf::Host* _management_object; + Host& _host; + ManagementAgent* _agent; public: HostAgent(Host& host); diff --git a/src/schema.xml b/src/schema.xml index 206e39b..31abb35 100644 --- a/src/schema.xml +++ b/src/schema.xml @@ -14,6 +14,12 @@ </class> + <eventArguments> + <arg name="timestamp" type="absTime" /> + </eventArguments> + + <event name="heartbeat" args="timestamp" /> + <!-- The processor for the node. --> <class name="Processors"> <property name="host" type="objId" access="RC" desc="The host machine." index="y" references="Host" parentRef="y" /> -- 1.6.6.1