You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@qpid.apache.org by ns...@apache.org on 2008/05/16 03:33:22 UTC

svn commit: r656918 - in /incubator/qpid/trunk/qpid: cpp/src/qpid/management/ManagementBroker.cpp python/qpid/management.py

Author: nsantos
Date: Thu May 15 18:33:21 2008
New Revision: 656918

URL: http://svn.apache.org/viewvc?rev=656918&view=rev
Log:
QPID-1061: Management heartbeat message from broker -- applied patch supplied by Ted Ross

Modified:
    incubator/qpid/trunk/qpid/cpp/src/qpid/management/ManagementBroker.cpp
    incubator/qpid/trunk/qpid/python/qpid/management.py

Modified: incubator/qpid/trunk/qpid/cpp/src/qpid/management/ManagementBroker.cpp
URL: http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/cpp/src/qpid/management/ManagementBroker.cpp?rev=656918&r1=656917&r2=656918&view=diff
==============================================================================
--- incubator/qpid/trunk/qpid/cpp/src/qpid/management/ManagementBroker.cpp (original)
+++ incubator/qpid/trunk/qpid/cpp/src/qpid/management/ManagementBroker.cpp Thu May 15 18:33:21 2008
@@ -25,6 +25,7 @@
 #include <qpid/broker/Message.h>
 #include <qpid/broker/MessageDelivery.h>
 #include "qpid/framing/MessageTransferBody.h"
+#include "qpid/sys/Time.h"
 #include <list>
 #include <iostream>
 #include <fstream>
@@ -246,6 +247,17 @@
     string              routingKey;
     std::list<uint64_t> deleteList;
 
+    {
+        Buffer msgBuffer(msgChars, BUFSIZE);
+        EncodeHeader(msgBuffer, 'h');
+        msgBuffer.putLongLong(uint64_t(Duration(now())));
+
+        contentSize = BUFSIZE - msgBuffer.available ();
+        msgBuffer.reset ();
+        routingKey = "mgmt." + uuid.str() + ".heartbeat";
+        SendBuffer (msgBuffer, contentSize, mExchange, routingKey);
+    }
+
     if (managementObjects.empty ())
         return;
         

Modified: incubator/qpid/trunk/qpid/python/qpid/management.py
URL: http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/python/qpid/management.py?rev=656918&r1=656917&r2=656918&view=diff
==============================================================================
--- incubator/qpid/trunk/qpid/python/qpid/management.py (original)
+++ incubator/qpid/trunk/qpid/python/qpid/management.py Thu May 15 18:33:21 2008
@@ -170,6 +170,7 @@
   CTRL_BROKER_INFO   = 1
   CTRL_SCHEMA_LOADED = 2
   CTRL_USER          = 3
+  CTRL_HEARTBEAT     = 4
 
   SYNC_TIME = 10.0
 
@@ -304,6 +305,8 @@
       self.handlePackageInd (ch, codec)
     elif hdr[0] == 'q':
       self.handleClassInd (ch, codec)
+    elif hdr[0] == 'h':
+      self.handleHeartbeat (ch, codec)
     else:
       self.parse (ch, codec, hdr[0], hdr[1])
     ch.accept(msg)
@@ -549,6 +552,11 @@
       smsg = ch.message(sendCodec.encoded)
       ch.send ("qpid.management", smsg)
 
+  def handleHeartbeat (self, ch, codec):
+    timestamp = codec.read_uint64()
+    if self.ctrlCb != None:
+      self.ctrlCb (ch.context, self.CTRL_HEARTBEAT, timestamp)
+
   def parseSchema (self, ch, codec):
     """ Parse a received schema-description message. """
     self.decOutstanding (ch)