qpid-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From nsan...@apache.org
Subject svn commit: r648308 - in /incubator/qpid/trunk/qpid: cpp/src/qpid/broker/ cpp/src/qpid/management/ python/commands/ python/qpid/ specs/
Date Tue, 15 Apr 2008 16:12:18 GMT
Author: nsantos
Date: Tue Apr 15 09:12:01 2008
New Revision: 648308

URL: http://svn.apache.org/viewvc?rev=648308&view=rev
Log:
QPID-921: applied qpid-patch36.diff on behalf of Ted Ross

Modified:
    incubator/qpid/trunk/qpid/cpp/src/qpid/broker/Broker.cpp
    incubator/qpid/trunk/qpid/cpp/src/qpid/broker/Queue.cpp
    incubator/qpid/trunk/qpid/cpp/src/qpid/broker/System.cpp
    incubator/qpid/trunk/qpid/cpp/src/qpid/broker/System.h
    incubator/qpid/trunk/qpid/cpp/src/qpid/broker/Vhost.cpp
    incubator/qpid/trunk/qpid/cpp/src/qpid/management/ManagementAgent.cpp
    incubator/qpid/trunk/qpid/cpp/src/qpid/management/ManagementAgent.h
    incubator/qpid/trunk/qpid/python/commands/qpid-config
    incubator/qpid/trunk/qpid/python/commands/qpid-route
    incubator/qpid/trunk/qpid/python/qpid/management.py
    incubator/qpid/trunk/qpid/python/qpid/managementdata.py
    incubator/qpid/trunk/qpid/specs/management-schema.xml

Modified: incubator/qpid/trunk/qpid/cpp/src/qpid/broker/Broker.cpp
URL: http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/cpp/src/qpid/broker/Broker.cpp?rev=648308&r1=648307&r2=648308&view=diff
==============================================================================
--- incubator/qpid/trunk/qpid/cpp/src/qpid/broker/Broker.cpp (original)
+++ incubator/qpid/trunk/qpid/cpp/src/qpid/broker/Broker.cpp Tue Apr 15 09:12:01 2008
@@ -136,7 +136,7 @@
         managementAgent->setInterval (conf.mgmtPubInterval);
         qpid::management::PackageQpid packageInitializer (managementAgent);
 
-        System* system = new System ();
+        System* system = new System (dataDir.isEnabled () ? dataDir.getPath () : string ());
         systemObject = System::shared_ptr (system);
 
         mgmtObject = management::Broker::shared_ptr (new management::Broker (this, system,
conf.port));
@@ -149,7 +149,7 @@
         mgmtObject->set_dataDirEnabled   (dataDir.isEnabled ());
         mgmtObject->set_dataDir          (dataDir.getPath ());
         
-        managementAgent->addObject (mgmtObject, 1, 0);
+        managementAgent->addObject (mgmtObject, 1, 1);
 
         // Since there is currently no support for virtual hosts, a placeholder object
         // representing the implied single virtual host is added here to keep the

Modified: incubator/qpid/trunk/qpid/cpp/src/qpid/broker/Queue.cpp
URL: http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/cpp/src/qpid/broker/Queue.cpp?rev=648308&r1=648307&r2=648308&view=diff
==============================================================================
--- incubator/qpid/trunk/qpid/cpp/src/qpid/broker/Queue.cpp (original)
+++ incubator/qpid/trunk/qpid/cpp/src/qpid/broker/Queue.cpp Tue Apr 15 09:12:01 2008
@@ -69,7 +69,7 @@
         if (agent.get () != 0)
         {
             mgmtObject = management::Queue::shared_ptr
-                (new management::Queue (this, parent, _name, _store != 0, _autodelete, 0));
+                (new management::Queue (this, parent, _name, _store != 0, _autodelete, _owner
!= 0));
 
             // Add the object to the management agent only if this queue is not durable.
             // If it's durable, we will add it later when the queue is assigned a persistenceId.

Modified: incubator/qpid/trunk/qpid/cpp/src/qpid/broker/System.cpp
URL: http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/cpp/src/qpid/broker/System.cpp?rev=648308&r1=648307&r2=648308&view=diff
==============================================================================
--- incubator/qpid/trunk/qpid/cpp/src/qpid/broker/System.cpp (original)
+++ incubator/qpid/trunk/qpid/cpp/src/qpid/broker/System.cpp Tue Apr 15 09:12:01 2008
@@ -19,19 +19,51 @@
 
 #include "System.h"
 #include "qpid/management/ManagementAgent.h"
+#include "qpid/framing/Uuid.h"
 #include <sys/utsname.h>
+#include <iostream>
+#include <fstream>
 
-using namespace qpid::broker;
 using qpid::management::ManagementAgent;
+using namespace qpid::broker;
+using namespace std;
 
-System::System ()
+System::System (string _dataDir)
 {
     ManagementAgent::shared_ptr agent = ManagementAgent::getAgent ();
 
     if (agent.get () != 0)
     {
+        framing::Uuid systemId;
+
+        if (_dataDir.empty ())
+        {
+            systemId.generate ();
+        }
+        else
+        {
+            string   filename (_dataDir + "/systemId");
+            ifstream inFile (filename.c_str ());
+
+            if (inFile.good ())
+            {
+                inFile >> systemId;
+                inFile.close ();
+            }
+            else
+            {
+                systemId.generate ();
+                ofstream outFile (filename.c_str ());
+                if (outFile.good ())
+                {
+                    outFile << systemId << endl;
+                    outFile.close ();
+                }
+            }
+        }
+
         mgmtObject = management::System::shared_ptr
-            (new management::System (this, "host"));
+            (new management::System (this, systemId));
         struct utsname _uname;
         if (uname (&_uname) == 0)
         {
@@ -42,7 +74,7 @@
             mgmtObject->set_machine  (std::string (_uname.machine));
         }
 
-        agent->addObject (mgmtObject, 3, 0);
+        agent->addObject (mgmtObject, 3, 1);
     }
 }
 

Modified: incubator/qpid/trunk/qpid/cpp/src/qpid/broker/System.h
URL: http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/cpp/src/qpid/broker/System.h?rev=648308&r1=648307&r2=648308&view=diff
==============================================================================
--- incubator/qpid/trunk/qpid/cpp/src/qpid/broker/System.h (original)
+++ incubator/qpid/trunk/qpid/cpp/src/qpid/broker/System.h Tue Apr 15 09:12:01 2008
@@ -23,6 +23,7 @@
 #include "qpid/management/Manageable.h"
 #include "qpid/management/System.h"
 #include <boost/shared_ptr.hpp>
+#include <string>
 
 namespace qpid { 
 namespace broker {
@@ -37,7 +38,7 @@
 
     typedef boost::shared_ptr<System> shared_ptr;
 
-    System ();
+    System (std::string _dataDir);
 
     management::ManagementObject::shared_ptr GetManagementObject (void) const
     { return mgmtObject; }

Modified: incubator/qpid/trunk/qpid/cpp/src/qpid/broker/Vhost.cpp
URL: http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/cpp/src/qpid/broker/Vhost.cpp?rev=648308&r1=648307&r2=648308&view=diff
==============================================================================
--- incubator/qpid/trunk/qpid/cpp/src/qpid/broker/Vhost.cpp (original)
+++ incubator/qpid/trunk/qpid/cpp/src/qpid/broker/Vhost.cpp Tue Apr 15 09:12:01 2008
@@ -33,7 +33,7 @@
         {
             mgmtObject = management::Vhost::shared_ptr
                 (new management::Vhost (this, parentBroker, "/"));
-            agent->addObject (mgmtObject, 2, 0);
+            agent->addObject (mgmtObject, 2, 1);
         }
     }
 }

Modified: incubator/qpid/trunk/qpid/cpp/src/qpid/management/ManagementAgent.cpp
URL: http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/cpp/src/qpid/management/ManagementAgent.cpp?rev=648308&r1=648307&r2=648308&view=diff
==============================================================================
--- incubator/qpid/trunk/qpid/cpp/src/qpid/management/ManagementAgent.cpp (original)
+++ incubator/qpid/trunk/qpid/cpp/src/qpid/management/ManagementAgent.cpp Tue Apr 15 09:12:01
2008
@@ -42,20 +42,24 @@
     dataDir (_dataDir), interval (_interval)
 {
     timer.add (intrusive_ptr<TimerTask> (new Periodic(*this, interval)));
-    nextObjectId = uint64_t (qpid::sys::Duration (qpid::sys::now ()));
+    localBank        = 3;
+    nextObjectId     = 1;
     nextRemotePrefix = 101;
 
     // Get from file or generate and save to file.
     if (dataDir.empty ())
     {
         uuid.generate ();
+        bootSequence = 1;
         QPID_LOG (info, "ManagementAgent has no data directory, generated new broker ID:
"
                   << uuid);
     }
     else
     {
-        string   filename (dataDir + "/brokerId");
-        ifstream inFile   (filename.c_str ());
+        string   filename    (dataDir + "/brokerId");
+        string   seqFilename (dataDir + "/bootseq");
+        ifstream inFile      (filename.c_str ());
+        ifstream seqFile     (seqFilename.c_str ());
 
         if (inFile.good ())
         {
@@ -80,6 +84,26 @@
                 QPID_LOG (warning, "ManagementAgent unable to save broker ID");
             }
         }
+
+        if (seqFile.good ())
+        {
+            seqFile >> bootSequence;
+            seqFile.close ();
+        }
+        else
+            bootSequence = 1;
+
+        ofstream seqOut (seqFilename.c_str ());
+        if (seqOut.good ())
+        {
+            uint16_t nextSeq = (bootSequence + 1) & 0x7FFF;
+            if (nextSeq == 0)
+                nextSeq = 1;
+            seqOut << nextSeq << endl;
+            seqOut.close ();
+        }
+
+        QPID_LOG (debug, "ManagementAgent boot sequence: " << bootSequence);
     }
 }
 
@@ -125,16 +149,17 @@
 }
 
 void ManagementAgent::addObject (ManagementObject::shared_ptr object,
-                                 uint64_t                     /*persistenceId*/,
-                                 uint64_t                     /*idOffset*/)
+                                 uint32_t                     persistId,
+                                 uint32_t                     persistBank)
 {
     Mutex::ScopedLock lock (userLock);
     uint64_t objectId;
 
-//    if (persistenceId == 0)
-        objectId = nextObjectId++;
-//    else
-//        objectId = 0x8000000000000000ULL | (persistenceId + idOffset);
+    if (persistId == 0)
+        objectId = ((uint64_t) bootSequence) << 48 |
+            ((uint64_t) localBank) << 24 | nextObjectId++;
+    else
+        objectId = ((uint64_t) persistBank) << 24 | persistId;
 
     object->setObjectId (objectId);
     managementObjects[objectId] = object;
@@ -384,7 +409,7 @@
     EncodeHeader (outBuffer, 'm', sequence);
 
     ManagementObjectMap::iterator iter = managementObjects.find (objId);
-    if (iter == managementObjects.end ())
+    if (iter == managementObjects.end () || iter->second->isDeleted ())
     {
         outBuffer.putLong        (Manageable::STATUS_UNKNOWN_OBJECT);
         outBuffer.putShortString (Manageable::StatusText (Manageable::STATUS_UNKNOWN_OBJECT));

Modified: incubator/qpid/trunk/qpid/cpp/src/qpid/management/ManagementAgent.h
URL: http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/cpp/src/qpid/management/ManagementAgent.h?rev=648308&r1=648307&r2=648308&view=diff
==============================================================================
--- incubator/qpid/trunk/qpid/cpp/src/qpid/management/ManagementAgent.h (original)
+++ incubator/qpid/trunk/qpid/cpp/src/qpid/management/ManagementAgent.h Tue Apr 15 09:12:01
2008
@@ -58,8 +58,8 @@
                           uint8_t*    md5Sum,
                           ManagementObject::writeSchemaCall_t schemaCall);
     void addObject       (ManagementObject::shared_ptr object,
-                          uint64_t                     persistenceId = 0,
-                          uint64_t                     idOffset      = 10);
+                          uint32_t                     persistId   = 0,
+                          uint32_t                     persistBank = 2);
     void clientAdded     (void);
     void dispatchCommand (broker::Deliverable&             msg,
                           const std::string&               routingKey,
@@ -142,7 +142,9 @@
     broker::Exchange::shared_ptr dExchange;
     std::string                  dataDir;
     uint16_t                     interval;
-    uint64_t                     nextObjectId;
+    uint16_t                     bootSequence;
+    uint32_t                     localBank;
+    uint32_t                     nextObjectId;
     uint32_t                     nextRemotePrefix;
 
 #   define MA_BUFFER_SIZE 65536

Modified: incubator/qpid/trunk/qpid/python/commands/qpid-config
URL: http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/python/commands/qpid-config?rev=648308&r1=648307&r2=648308&view=diff
==============================================================================
--- incubator/qpid/trunk/qpid/python/commands/qpid-config (original)
+++ incubator/qpid/trunk/qpid/python/commands/qpid-config Tue Apr 15 09:12:01 2008
@@ -97,13 +97,17 @@
         try:
             self.spec     = qpid.spec.load (_specpath)
             self.client   = Client (self.broker.host, self.broker.port, self.spec)
-            self.client.start ({"LOGIN":"guest","PASSWORD":"guest"})
+            self.client.start (response='\x00' + "guest" + '\x00' + "guest",
+                               mechanism="PLAIN")
             self.channel  = self.client.channel (1)
             self.mclient  = managementClient (self.spec)
             self.mchannel = self.mclient.addChannel (self.channel)
         except socket.error, e:
-            print "Connect Error:", e
-            exit (1)
+            print "Socket Error:", e
+            sys.exit (1)
+        except Closed, e:
+            print "Connect Failed:", e
+            sys.exit (1)
 
     def Overview (self):
         self.ConnectToBroker ()

Modified: incubator/qpid/trunk/qpid/python/commands/qpid-route
URL: http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/python/commands/qpid-route?rev=648308&r1=648307&r2=648308&view=diff
==============================================================================
--- incubator/qpid/trunk/qpid/python/commands/qpid-route (original)
+++ incubator/qpid/trunk/qpid/python/commands/qpid-route Tue Apr 15 09:12:01 2008
@@ -79,7 +79,8 @@
         try:
             self.spec    = qpid.spec.load (_specpath)
             self.client  = Client (broker.host, broker.port, self.spec)
-            self.client.start ({"LOGIN":"guest","PASSWORD":"guest"})
+            self.client.start (response='\x00' + "guest" + '\x00' + "guest",
+                               mechanism="PLAIN")
             self.channel = self.client.channel (1)
             self.mclient = managementClient (self.spec)
             self.mch     = self.mclient.addChannel (self.channel)

Modified: incubator/qpid/trunk/qpid/python/qpid/management.py
URL: http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/python/qpid/management.py?rev=648308&r1=648307&r2=648308&view=diff
==============================================================================
--- incubator/qpid/trunk/qpid/python/qpid/management.py (original)
+++ incubator/qpid/trunk/qpid/python/qpid/management.py Tue Apr 15 09:12:01 2008
@@ -83,11 +83,11 @@
 class managementChannel:
   """ This class represents a connection to an AMQP broker. """
 
-  def __init__ (self, ch, topicCb, replyCb, cbContext):
+  def __init__ (self, ch, topicCb, replyCb, cbContext, _detlife=0):
     """ Given a channel on an established AMQP broker connection, this method
     opens a session and performs all of the declarations and bindings needed
     to participate in the management protocol. """
-    response         = ch.session_open (detached_lifetime=300)
+    response         = ch.session_open (detached_lifetime=_detlife)
     self.sessionId   = response.session_id
     self.topicName   = "mgmt-%08x-%04x-%04x-%04x-%04x%08x" % struct.unpack ("!LHHHHL", response.session_id)
     self.replyName   = "repl-%08x-%04x-%04x-%04x-%04x%08x" % struct.unpack ("!LHHHHL", response.session_id)
@@ -97,8 +97,8 @@
     self.context     = cbContext
     self.reqsOutstanding = 0
 
-    ch.queue_declare (queue=self.topicName, exclusive=1, auto_delete=1)
-    ch.queue_declare (queue=self.replyName, exclusive=1, auto_delete=1)
+    ch.queue_declare (queue=self.topicName, exclusive=True, auto_delete=True)
+    ch.queue_declare (queue=self.replyName, exclusive=True, auto_delete=True)
 
     ch.queue_bind (exchange="qpid.management",
                    queue=self.topicName, routing_key="mgmt.#")

Modified: incubator/qpid/trunk/qpid/python/qpid/managementdata.py
URL: http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/python/qpid/managementdata.py?rev=648308&r1=648307&r2=648308&view=diff
==============================================================================
--- incubator/qpid/trunk/qpid/python/qpid/managementdata.py (original)
+++ incubator/qpid/trunk/qpid/python/qpid/managementdata.py Tue Apr 15 09:12:01 2008
@@ -21,6 +21,7 @@
 
 import qpid
 import socket
+import struct
 from qpid.management import managementChannel, managementClient
 from threading       import Lock
 from disp            import Display
@@ -63,19 +64,24 @@
   #
 
   def registerObjId (self, objId):
-    if self.baseId == 0:
-      if objId & 0x8000000000000000L == 0:
-        self.baseId = objId - 1000
+    boot = objId & 0x7FFF000000000000L
+    if boot == 0:
+      return
+    self.bootSequence = boot
 
   def displayObjId (self, objId):
-    if objId & 0x8000000000000000L == 0:
-      return objId - self.baseId
-    return (objId & 0x7fffffffffffffffL) + 5000
+    bank = (objId & 0x0000FFFFFF000000L) >> 24
+    id   =  objId & 0x0000000000FFFFFFL
+    return bank * 1000 + id
 
   def rawObjId (self, displayId):
-    if displayId < 5000:
-      return displayId + self.baseId
-    return displayId - 5000 + 0x8000000000000000L
+    bank  = displayId / 1000
+    id    = displayId % 1000
+    if bank < 3:
+      objId = (bank << 24) + id
+    else:
+      objId = self.bootSequence + (bank << 24) + id
+    return objId
 
   def displayClassName (self, cls):
     (packageName, className, hash) = cls
@@ -158,7 +164,7 @@
     self.lock           = Lock ()
     self.tables         = {}
     self.schema         = {}
-    self.baseId         = 0
+    self.bootSequence   = 0
     self.disp           = disp
     self.lastUnit       = None
     self.methodSeq      = 1
@@ -166,7 +172,8 @@
 
     self.broker = Broker (host)
     self.client = Client (self.broker.host, self.broker.port, self.spec)
-    self.client.start ({"LOGIN": username, "PASSWORD": password})
+    self.client.start (response='\x00' + username + '\x00' + password,
+                       mechanism="PLAIN")
     self.channel = self.client.channel (1)
 
     self.mclient = managementClient (self.spec, self.ctrlHandler, self.configHandler,
@@ -189,7 +196,7 @@
         if item[0] == key:
           typecode = item[1]
           unit     = item[2]
-          if (typecode >= 1 and typecode <= 5) or typecode >= 12:  # numerics
+          if (typecode >= 1 and typecode <= 5) or typecode == 12 or typecode == 13:
 # numerics
             if unit == None or unit == self.lastUnit:
               return str (value)
             else:
@@ -214,7 +221,7 @@
             else:
               return "True"
           elif typecode == 14:
-            return str (UUID (bytes=value))
+            return "%08x-%04x-%04x-%04x-%04x%08x" % struct.unpack ("!LHHHHL", value)
           elif typecode == 15:
             return str (value)
     return "*type-error*"

Modified: incubator/qpid/trunk/qpid/specs/management-schema.xml
URL: http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/specs/management-schema.xml?rev=648308&r1=648307&r2=648308&view=diff
==============================================================================
--- incubator/qpid/trunk/qpid/specs/management-schema.xml (original)
+++ incubator/qpid/trunk/qpid/specs/management-schema.xml Tue Apr 15 09:12:01 2008
@@ -45,7 +45,7 @@
   ===============================================================
   -->
   <class name="system">
-    <configElement name="sysId" index="y" type="sstr" access="RC"/>
+    <configElement name="sysId" index="y" type="uuid" access="RC"/>
 
     <configElement name="osName"   type="sstr" access="RO" desc="Operating System Name"/>
     <configElement name="nodeName" type="sstr" access="RO" desc="Node Name"/>



Mime
View raw message