qpid-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cctriel...@apache.org
Subject svn commit: r657088 - in /incubator/qpid/trunk/qpid/python: commands/qpid-config commands/qpid-queue-stats commands/qpid-route commands/qpid-tool qpid/managementdata.py
Date Fri, 16 May 2008 14:51:07 GMT
Author: cctrieloff
Date: Fri May 16 07:51:07 2008
New Revision: 657088

URL: http://svn.apache.org/viewvc?rev=657088&view=rev
Log:
QPID-1067

Modified:
    incubator/qpid/trunk/qpid/python/commands/qpid-config
    incubator/qpid/trunk/qpid/python/commands/qpid-queue-stats
    incubator/qpid/trunk/qpid/python/commands/qpid-route
    incubator/qpid/trunk/qpid/python/commands/qpid-tool
    incubator/qpid/trunk/qpid/python/qpid/managementdata.py

Modified: incubator/qpid/trunk/qpid/python/commands/qpid-config
URL: http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/python/commands/qpid-config?rev=657088&r1=657087&r2=657088&view=diff
==============================================================================
--- incubator/qpid/trunk/qpid/python/commands/qpid-config (original)
+++ incubator/qpid/trunk/qpid/python/commands/qpid-config Fri May 16 07:51:07 2008
@@ -33,8 +33,6 @@
 from qpid.util       import connect
 from time            import sleep
 
-_defspecpath  = "/usr/share/amqp/amqp.0-10.xml"
-_specpath     = _defspecpath
 _recursive    = False
 _host         = "localhost"
 _durable      = False
@@ -65,8 +63,6 @@
     print "    -a [ --broker-addr ] Address (localhost)  Address of qpidd broker"
     print "         broker-addr is in the form:   [username/password@] hostname | ip-address
[:<port>]"
     print "         ex:  localhost, 10.1.1.7:10000, broker-host:10000, guest/guest@localhost"
-    print "    -s [ --spec-file] Path (" + _defspecpath + ")"
-    print "                                              AMQP specification file"
     print
     print "Add Queue Options:"
     print "    --durable           Queue is durable"
@@ -91,13 +87,12 @@
 
     def ConnectToBroker (self):
         try:
-            self.spec = qpid.spec.load (_specpath)
             self.sessionId = "%s.%d" % (os.uname()[1], os.getpid())
-            self.conn = Connection (connect (self.broker.host, self.broker.port), self.spec,
+            self.conn = Connection (connect (self.broker.host, self.broker.port),
                                     username=self.broker.username, password=self.broker.password)
             self.conn.start ()
             self.session  = self.conn.session (self.sessionId)
-            self.mclient  = managementClient (self.spec)
+            self.mclient  = managementClient (self.conn.spec)
             self.mchannel = self.mclient.addChannel (self.session)
         except socket.error, e:
             print "Socket Error %s - %s" % (e[0], e[1])
@@ -325,14 +320,12 @@
 ##
 
 try:
-    longOpts = ("durable", "spec-file=", "bindings", "broker-addr=", "file-count=", "file-size=",
"max-queue-size=", "max-queue-count=")
-    (optlist, cargs) = getopt.gnu_getopt (sys.argv[1:], "s:a:b", longOpts)
+    longOpts = ("durable", "bindings", "broker-addr=", "file-count=", "file-size=", "max-queue-size=",
"max-queue-count=")
+    (optlist, cargs) = getopt.gnu_getopt (sys.argv[1:], "a:b", longOpts)
 except:
     Usage ()
 
 for opt in optlist:
-    if opt[0] == "-s" or opt[0] == "--spec-file":
-        _specpath = opt[1]
     if opt[0] == "-b" or opt[0] == "--bindings":
         _recursive = True
     if opt[0] == "-a" or opt[0] == "--broker-addr":

Modified: incubator/qpid/trunk/qpid/python/commands/qpid-queue-stats
URL: http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/python/commands/qpid-queue-stats?rev=657088&r1=657087&r2=657088&view=diff
==============================================================================
--- incubator/qpid/trunk/qpid/python/commands/qpid-queue-stats (original)
+++ incubator/qpid/trunk/qpid/python/commands/qpid-queue-stats Fri May 16 07:51:07 2008
@@ -52,20 +52,19 @@
         self.broker  = None
         self.objects = {}
         self.filter  = None   
-        self.specpath="/usr/share/amqp/amqp.0-10.xml"
 
     def SetBroker (self, broker):
         self.broker = broker
 
     def ConnectToBroker (self):
         try:
-            self.spec     = qpid.spec.load (self.specpath)
             self.sessionId = "%s.%d" % (os.uname()[1], os.getpid())
-            self.conn     = Connection (connect (self.broker.host, self.broker.port), self.spec,
+            self.conn     = Connection (connect (self.broker.host, self.broker.port),
                                     username=self.broker.username, password=self.broker.password)
             self.conn.start ()
-            self.mclient  = managementClient (self.spec, None, self.configCb, self.instCb)
-            self.mchannel = self.mclient.addChannel (self.conn.session(self.sessionId))
+            self.session  = self.conn.session(self.sessionId)
+            self.mclient  = managementClient (self.conn.spec, None, self.configCb, self.instCb)
+            self.mchannel = self.mclient.addChannel (self.session)
         except socket.error, e:
             print "Socket Error %s - %s" % (e[0], e[1])
             sys.exit (1)
@@ -79,11 +78,10 @@
     def setFilter(self,filter):
         self.filter = filter
 
-    def setSpecpath(self,spec):
-        self.specpath = spec
-
     def Disconnect (self):
         self.mclient.removeChannel (self.mchannel)
+        self.session.close(timeout=10)
+        self.conn.close(timeout=10)
 
     def configCb (self, context, classKey, row, timestamps):
         className = classKey[1]
@@ -149,13 +147,11 @@
 def main():
   p = optparse.OptionParser()
   p.add_option('--broker-address','-a', default='localhost' , help='broker-addr is in the
form:  [username/password@] hostname | ip-address [:<port>] \n ex:  localhost, 10.1.1.7:10000,
broker-host:10000, guest/guest@localhost')
-  p.add_option('--amqp-spec-file','-s', default='/usr/share/amqp/amqp.0-10.xml', help='the
path to the amqp spec file')
   p.add_option('--filter','-f' ,default=None ,help='a list of comma separated queue names
(regex are accepted) to show')
 
   options, arguments = p.parse_args()
 
   host = options.broker_address
-  specpath = options.amqp_spec_file
   filter = []
   if options.filter != None:
     for s in options.filter.split(","):
@@ -163,7 +159,6 @@
 
   bm  = BrokerManager ()
   bm.SetBroker (Broker (host))
-  bm.setSpecpath(specpath)
   bm.setFilter(filter)
   bm.Display()
  

Modified: incubator/qpid/trunk/qpid/python/commands/qpid-route
URL: http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/python/commands/qpid-route?rev=657088&r1=657087&r2=657088&view=diff
==============================================================================
--- incubator/qpid/trunk/qpid/python/commands/qpid-route (original)
+++ incubator/qpid/trunk/qpid/python/commands/qpid-route Fri May 16 07:51:07 2008
@@ -41,7 +41,6 @@
     print "        qpid-route [OPTIONS] route flush <dest-broker>"
     print
     print "Options:"
-    print "    -s [ --spec-file ] PATH (/usr/share/amqp/amqp.0-10.xml)"
     print "    -v [ --verbose ]         Verbose output"
     print "    -q [ --quiet ]           Quiet output, don't print duplicate warnings"
     print "    -d [ --durable ]         Added configuration shall be durable"
@@ -52,7 +51,6 @@
     print
     sys.exit (1)
 
-_specpath = "/usr/share/amqp/amqp.0-10.xml"
 _verbose  = False
 _quiet    = False
 _durable  = False
@@ -68,13 +66,13 @@
         if _verbose:
             print "Connecting to broker: %s:%d" % (broker.host, broker.port)
         try:
-            self.spec    = qpid.spec.load (_specpath)
             self.sessionId = "%s.%d" % (os.uname()[1], os.getpid())
-            self.conn    = Connection (connect (broker.host, broker.port), self.spec, \
+            self.conn    = Connection (connect (broker.host, broker.port), \
                                            username=broker.username, password=broker.password)
             self.conn.start ()
-            self.mclient = managementClient (self.spec)
-            self.mch     = self.mclient.addChannel (self.conn.session(self.sessionId))
+            self.session = self.conn.session(self.sessionId)
+            self.mclient = managementClient (self.conn.spec)
+            self.mch     = self.mclient.addChannel (self.session)
             self.mclient.syncWaitForStable (self.mch)
         except socket.error, e:
             print "Socket Error %s - %s" % (e[0], e[1])
@@ -88,6 +86,8 @@
 
     def Disconnect (self):
         self.mclient.removeChannel (self.mch)
+        self.session.close(timeout=10)
+        self.conn.close(timeout=10)
 
     def getLink (self):
         links = self.mclient.syncGetObjects (self.mch, "link")
@@ -292,14 +292,12 @@
 ##
 
 try:
-    longOpts = ("verbose", "quiet", "spec-file=", "durable", "del-empty-link")
-    (optlist, cargs) = getopt.gnu_getopt (sys.argv[1:], "s:vqde", longOpts)
+    longOpts = ("verbose", "quiet", "durable", "del-empty-link")
+    (optlist, cargs) = getopt.gnu_getopt (sys.argv[1:], "vqde", longOpts)
 except:
     Usage ()
 
 for opt in optlist:
-    if opt[0] == "-s" or opt[0] == "--spec-file":
-        _specpath = opt[1]
     if opt[0] == "-v" or opt[0] == "--verbose":
         _verbose = True
     if opt[0] == "-q" or opt[0] == "--quiet":

Modified: incubator/qpid/trunk/qpid/python/commands/qpid-tool
URL: http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/python/commands/qpid-tool?rev=657088&r1=657087&r2=657088&view=diff
==============================================================================
--- incubator/qpid/trunk/qpid/python/commands/qpid-tool (original)
+++ incubator/qpid/trunk/qpid/python/commands/qpid-tool Fri May 16 07:51:07 2008
@@ -142,9 +142,6 @@
 def Usage ():
   print "Usage:", sys.argv[0], "[OPTIONS] [<target-host[:<tcp-port>]]"
   print
-  print "Options:"
-  print "    -s [ --spec-file ] PATH (/usr/share/amqp/amqp.0-10.xml)"
-  print
   sys.exit (1)
 
 #=========================================================
@@ -152,20 +149,10 @@
 #=========================================================
 
 # Get host name and port if specified on the command line
-try:
-  longOpts = ("spec-file=")
-  (optlist, cargs) = getopt.gnu_getopt (sys.argv[1:], 's:', longOpts)
-except:
-  Usage ()
-  sys.exit (1)
+cargs = sys.argv[1:]
 
-_specpath = "/usr/share/amqp/amqp.0-10.xml"
 _host     = "localhost"
 
-for opt in optlist:
-  if opt[0] == "-s" or opt[0] == "--spec-file":
-    _specpath = opt[1]
-
 if len (cargs) > 0:
   _host = cargs[0]
 
@@ -173,7 +160,7 @@
 
 # Attempt to make a connection to the target broker
 try:
-  data = ManagementData (disp, _host, specfile=_specpath)
+  data = ManagementData (disp, _host)
 except socket.error, e:
   print "Socket Error (%s):" % _host, e[1]
   sys.exit (1)

Modified: incubator/qpid/trunk/qpid/python/qpid/managementdata.py
URL: http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/python/qpid/managementdata.py?rev=657088&r1=657087&r2=657088&view=diff
==============================================================================
--- incubator/qpid/trunk/qpid/python/qpid/managementdata.py (original)
+++ incubator/qpid/trunk/qpid/python/qpid/managementdata.py Fri May 16 07:51:07 2008
@@ -79,11 +79,11 @@
   def displayObjId (self, objId):
     bank = (objId & 0x0000FFFFFF000000L) >> 24
     id   =  objId & 0x0000000000FFFFFFL
-    return bank * 1000 + id
+    return bank * 10000 + id
 
   def rawObjId (self, displayId):
-    bank  = displayId / 1000
-    id    = displayId % 1000
+    bank  = displayId / 10000
+    id    = displayId % 10000
     if bank < 5:
       objId = (bank << 24) + id
     else:
@@ -135,13 +135,15 @@
                 value = oldInst[idx][1]
             newInst.append ((key, value))
         self.tables[className][id] = (timestamps, oldConf, newInst)
-      
+
     finally:
       self.lock.release ()
 
   def ctrlHandler (self, context, op, data):
     if op == self.mclient.CTRL_BROKER_INFO:
       pass
+    elif op == self.mclient.CTRL_HEARTBEAT:
+      pass
 
   def configHandler (self, context, className, list, timestamps):
     self.dataHandler (0, className, list, timestamps);
@@ -174,9 +176,7 @@
   def setCli (self, cliobj):
     self.cli = cliobj
 
-  def __init__ (self, disp, host, username="guest", password="guest",
-                specfile="../../specs/amqp.0-10.xml"):
-    self.spec           = qpid.spec.load (specfile)
+  def __init__ (self, disp, host, username="guest", password="guest"):
     self.lock           = Lock ()
     self.tables         = {}
     self.schema         = {}
@@ -188,8 +188,9 @@
     self.sessionId      = "%s.%d" % (os.uname()[1], os.getpid())
 
     self.broker = Broker (host)
-    self.conn   = Connection (connect (self.broker.host, self.broker.port), self.spec,
+    self.conn   = Connection (connect (self.broker.host, self.broker.port),
                               username=self.broker.username, password=self.broker.password)
+    self.spec = self.conn.spec
     self.conn.start ()
 
     self.mclient = managementClient (self.spec, self.ctrlHandler, self.configHandler,



Mime
View raw message