[rhmessaging-commits] rhmessaging commits: r1147 - mgmt/cumin/python/cumin.

rhmessaging-commits at lists.jboss.org rhmessaging-commits at lists.jboss.org
Tue Oct 23 14:04:51 EDT 2007


Author: justi9
Date: 2007-10-23 14:04:51 -0400 (Tue, 23 Oct 2007)
New Revision: 1147

Modified:
   mgmt/cumin/python/cumin/demo.py
   mgmt/cumin/python/cumin/model.py
   mgmt/cumin/python/cumin/queue.py
   mgmt/cumin/python/cumin/queue.strings
Log:
Adds consumers to the model and demo data and displays them under
queue.



Modified: mgmt/cumin/python/cumin/demo.py
===================================================================
--- mgmt/cumin/python/cumin/demo.py	2007-10-23 17:33:50 UTC (rev 1146)
+++ mgmt/cumin/python/cumin/demo.py	2007-10-23 18:04:51 UTC (rev 1147)
@@ -144,6 +144,11 @@
             queue.name = fmt("queue", queue_count)
             vhost.add_queue(queue)
 
+            for consumer_count in range(10):
+                consumer = Consumer(self.model)
+                consumer.name = fmt("consumer", consumer_count)
+                queue.add_consumer(consumer)
+
         for num in range(100, 200, 10):
             client = Client(self.model)
             client.address = "192.168.0.%i:16565" % num
@@ -212,6 +217,14 @@
                         finally:
                             queue.unlock()
 
+                        for consumer in queue.consumer_items():
+                            consumer.lock()
+                            try:
+                                for measure in consumer.measurements:
+                                    self.frob_measure(measure)
+                            finally:
+                                consumer.unlock()
+
                     for client in vhost.client_items():
                         client.lock()
                         try:

Modified: mgmt/cumin/python/cumin/model.py
===================================================================
--- mgmt/cumin/python/cumin/model.py	2007-10-23 17:33:50 UTC (rev 1146)
+++ mgmt/cumin/python/cumin/model.py	2007-10-23 18:04:51 UTC (rev 1147)
@@ -14,6 +14,7 @@
         self.virtual_host = ModelClass(self, "virtual_host")
         self.virtual_host_group = ModelClass(self, "virtual_host_group")
         self.queue = ModelClass(self, "queue")
+        self.consumer = ModelClass(self, "consumer")
         self.exchange = ModelClass(self, "exchange")
         self.client = ModelClass(self, "client")
         self.session = ModelClass(self, "session")
@@ -69,6 +70,10 @@
         assoc.add_endpoint(self.virtual_host, "queue", "0..n")
         assoc.add_endpoint(self.queue, "virtual_host", "0..1")
 
+        assoc = ModelAssociation(self, "queue_to_consumers")
+        assoc.add_endpoint(self.queue, "consumer", "0..n")
+        assoc.add_endpoint(self.consumer, "queue", "0..1")
+
         assoc = ModelAssociation(self, "virtual_host_to_exchanges")
         assoc.add_endpoint(self.virtual_host, "exchange", "0..n")
         assoc.add_endpoint(self.exchange, "virtual_host", "0..1")
@@ -523,6 +528,39 @@
             
         writer.write("</queue>")
 
+class MeasuredModelObject(ModelObject):
+    def __init__(self, model, mclass):
+        super(MeasuredModelObject, self).__init__(model, mclass)
+
+        self.measurements = list()
+
+    def get_measurement(self, name):
+        for measure in self.measurements:
+            if measure.name == name:
+                return measure
+
+class Consumer(MeasuredModelObject):
+    def __init__(self, model):
+        super(Consumer, self).__init__(model, model.consumer)
+
+        self.name = None
+
+        measure = Measurement("msgsConsumed", "int")
+        measure.title = "Messages Consumed"
+        measure.categories = ("message", "general")
+        self.measurements.append(measure)
+        
+        measure = Measurement("bytesConsumed", "int")
+        measure.title = "Bytes Consumed"
+        measure.categories = ("byte", "general")
+        self.measurements.append(measure)
+
+        measure = Measurement("unackedMessages", "int")
+        measure.title = "Unacknowledged messages"
+        measure.categories = ("message", "general")
+        measure.highlow = True
+        self.measurements.append(measure)
+
 class Exchange(ModelObject):
     def __init__(self, model):
         super(Exchange, self).__init__(model, model.exchange)

Modified: mgmt/cumin/python/cumin/queue.py
===================================================================
--- mgmt/cumin/python/cumin/queue.py	2007-10-23 17:33:50 UTC (rev 1146)
+++ mgmt/cumin/python/cumin/queue.py	2007-10-23 18:04:51 UTC (rev 1147)
@@ -114,9 +114,9 @@
         self.tabs = TabSet(app, "tabs")
         self.add_child(self.tabs)
 
+        self.tabs.add_tab(ConsumerSet(app, "consumers"))
         self.tabs.add_tab(QueueBindingSet(app, "bindings"))
         self.tabs.add_tab(QueueStatistics(app, "stats"))
-        self.tabs.add_tab(self.QueueConsumers(app, "consumers"))
 
     def render_title(self, session, queue):
         return "Queue '%s'" % queue.name
@@ -134,10 +134,6 @@
         else:
             raise Exception()
 
-    class QueueConsumers(Widget):
-        def render_title(self, session, queue):
-            return "Consumers"
-
 class QueueBindingSet(ItemSet):
     def render_title(self, session, queue):
         return "Bindings (%i)" % len(queue.binding_items())
@@ -382,3 +378,22 @@
     class StatisticsHistory(Widget):
         def render_title(self, session, queue):
             return "History"
+
+class ConsumerSet(ItemSet):
+    def render_title(self, session, queue):
+        return "Consumers (%i)" % len(queue.consumer_items())
+
+    def get_items(self, session, queue):
+        return sorted_by(queue.consumer_items())
+
+    def render_item_name(self, session, consumer):
+        return consumer.name
+
+    def render_item_messages_consumed(self, session, consumer):
+        return consumer.get_measurement("msgsConsumed").get_value()
+
+    def render_item_bytes_consumed(self, session, consumer):
+        return consumer.get_measurement("bytesConsumed").get_value()
+
+    def render_item_unacked_messages(self, session, consumer):
+        return consumer.get_measurement("unackedMessages").get_value()

Modified: mgmt/cumin/python/cumin/queue.strings
===================================================================
--- mgmt/cumin/python/cumin/queue.strings	2007-10-23 17:33:50 UTC (rev 1146)
+++ mgmt/cumin/python/cumin/queue.strings	2007-10-23 18:04:51 UTC (rev 1147)
@@ -206,3 +206,35 @@
     </td>
   </tr>
 </table>
+
+[ConsumerSet.html]
+<select>
+  <option>Act on Selection...</option>
+  <option>Throttle Consumers</option>
+  <option>Stop Consumers</option>
+  <option>Start Consumers</option>
+  <option>Close Consumers</option>
+</select>
+
+<br/><br/>
+
+<table class="mobjects">
+  <tr>
+    <th><input type="checkbox"/></th>
+    <th>Consumer</th>
+    <th style="text-align: right;">Msgs. Consumed</th>
+    <th style="text-align: right;">Bytes Consumed</th>
+    <th style="text-align: right;">Msgs. Unacknowledged</th>
+  </tr>
+
+  {items}
+</table>
+
+[ConsumerSet.item_html]
+<tr>
+  <td><input type="checkbox"/></td>
+  <td>{item_name}</td>
+  <td style="text-align: right;">{item_messages_consumed}</td>
+  <td style="text-align: right;">{item_bytes_consumed}</td>
+  <td style="text-align: right;">{item_unacked_messages}</td>
+</tr>




More information about the rhmessaging-commits mailing list