[Ovirt-devel] [PATCH matahari] Introduces explicit heartbeat events to the QMF transport.
Darryl L. Pierce
dpierce at redhat.com
Thu May 27 18:19:17 UTC 2010
Also changes the linking to include the two newer qpid libraries.
Signed-off-by: Darryl L. Pierce <dpierce at redhat.com>
---
src/Makefile.am | 4 +++-
src/host.cpp | 28 ++++++++++++++++++----------
src/host.h | 1 +
src/hostlistener.h | 2 +-
src/qmf/hostagent.cpp | 7 +++++--
src/qmf/hostagent.h | 9 ++++++---
src/schema.xml | 7 +++++++
7 files changed, 41 insertions(+), 17 deletions(-)
diff --git a/src/Makefile.am b/src/Makefile.am
index 498ee72..eaad138 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 \
@@ -44,6 +46,6 @@ CLEANFILES = $(generated_file_list) $(first)
matahari_CPPFLAGS = -fno-strict-aliasing
matahari_LDFLAGS = -L/usr/local/lib
-matahari_LDADD = -lqmf $(LIBVIRT_LIBS) $(PCRE_LIBS) $(UDEV_LIBS)
+matahari_LDADD = -lqmf -lqpidclient -lqpidcommon $(LIBVIRT_LIBS) $(PCRE_LIBS) $(UDEV_LIBS)
dist_pkgdata_DATA = schema.xml
diff --git a/src/host.cpp b/src/host.cpp
index 29b84ec..63dbceb 100644
--- a/src/host.cpp
+++ b/src/host.cpp
@@ -29,16 +29,18 @@
using namespace std;
+const string UNKNOWN("Unknow");
+
Host::Host()
+ :_uuid(UNKNOWN)
+ ,_hostname(UNKNOWN)
+ ,_hypervisor(UNKNOWN)
+ ,_architecture(UNKNOWN)
+ ,_memory(0)
+ ,_beeping(false)
+ ,_heartbeat_sequence(0)
{
struct utsname details;
- this->_uuid = string("Unknown");
- this->_hostname = string("Unknown");
- this->_hypervisor = string("Unknown");
- this->_architecture = string("None");
- this->_memory = 0;
- this->_beeping = false;
-
std::ifstream input("/var/lib/dbus/machine-id");
if(input.is_open())
@@ -99,13 +101,19 @@ Host::setup(ManagementAgent* agent, HostAgent* hostAgent)
void
Host::update()
{
+ this->_heartbeat_sequence++;
+
_processors.update();
- for(vector<NetworkDeviceAgent>::iterator iter = _networkdevices.begin();
- iter != _networkdevices.end();
+ time_t __time;
+ time(&__time);
+
+ for(set<HostListener*>::iterator iter = _listeners.begin();
+ iter != _listeners.end();
iter++)
{
- iter->update();
+ (*iter)->heartbeat((unsigned long)__time,
+ this->_heartbeat_sequence);
}
}
diff --git a/src/host.h b/src/host.h
index bcb8c12..b6885e8 100644
--- a/src/host.h
+++ b/src/host.h
@@ -41,6 +41,7 @@ class Host
string _architecture;
unsigned int _memory;
bool _beeping;
+ unsigned int _heartbeat_sequence;
Processors _processors;
vector<NetworkDeviceAgent> _networkdevices;
diff --git a/src/hostlistener.h b/src/hostlistener.h
index 298e51d..de7352a 100644
--- a/src/hostlistener.h
+++ b/src/hostlistener.h
@@ -27,7 +27,7 @@
class HostListener
{
public:
- virtual void heartbeat(unsigned long timestamp) = 0;
+ virtual void heartbeat(unsigned long timestamp, unsigned int sequence) = 0;
};
#endif
diff --git a/src/qmf/hostagent.cpp b/src/qmf/hostagent.cpp
index 9807f65..21e377b 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);
@@ -63,6 +65,7 @@ HostAgent::ManagementMethod(uint32_t method, Args& arguments, string& text)
}
void
-HostAgent::heartbeat(unsigned long timestamp)
+HostAgent::heartbeat(unsigned long timestamp, unsigned int sequence)
{
+ this->_agent->raiseEvent(_qmf::EventHeartbeat(timestamp, sequence));
}
diff --git a/src/qmf/hostagent.h b/src/qmf/hostagent.h
index 6d2f2a0..a31f844 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);
@@ -45,7 +48,7 @@ class HostAgent : public Manageable, public HostListener
ManagementObject* GetManagementObject() const { return _management_object; }
status_t ManagementMethod(uint32_t method, Args& arguments, string& text);
- virtual void heartbeat(unsigned long timestamp);
+ virtual void heartbeat(unsigned long timestamp, unsigned int sequence);
};
#endif
diff --git a/src/schema.xml b/src/schema.xml
index 206e39b..aac5425 100644
--- a/src/schema.xml
+++ b/src/schema.xml
@@ -14,6 +14,13 @@
</class>
+ <eventArguments>
+ <arg name="timestamp" type="absTime" />
+ <arg name="sequence" type="uint32" />
+ </eventArguments>
+
+ <event name="heartbeat" args="timestamp,sequence" />
+
<!-- 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.7.0.1
More information about the ovirt-devel
mailing list