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

rhmessaging-commits at lists.jboss.org rhmessaging-commits at lists.jboss.org
Fri Oct 19 17:17:36 EDT 2007


Author: justi9
Date: 2007-10-19 17:17:36 -0400 (Fri, 19 Oct 2007)
New Revision: 1126

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 categories to statistics.  Adds historical data to the model and
displays an average in the ui.



Modified: mgmt/cumin/python/cumin/demo.py
===================================================================
--- mgmt/cumin/python/cumin/demo.py	2007-10-19 20:13:06 UTC (rev 1125)
+++ mgmt/cumin/python/cumin/demo.py	2007-10-19 21:17:36 UTC (rev 1126)
@@ -167,10 +167,11 @@
                             for stat in queue.stats:
                                 if stat.type == "int" and random() < 0.33:
                                     if random() < 0.5:
-                                        stat.value += randint(4, 12)
+                                        value = stat.get_value()
+                                        stat.add_value(value + randint(4, 12))
                                     else:
-                                        value = stat.value - randint(3, 9)
-                                        stat.value = value > 0 and value or 0
+                                        value = stat.get_value() - randint(3, 9)
+                                        stat.add_value(value > 0 and value or 0)
 
                             queue.message_count += 1
 

Modified: mgmt/cumin/python/cumin/model.py
===================================================================
--- mgmt/cumin/python/cumin/model.py	2007-10-19 20:13:06 UTC (rev 1125)
+++ mgmt/cumin/python/cumin/model.py	2007-10-19 21:17:36 UTC (rev 1126)
@@ -268,17 +268,25 @@
 
         writer.write("</realm>")
 
-class StatProperty(object):
+class Statistic(object):
     def __init__(self, name, type):
         self.name = name
         self.type = type
+        self.categories = ()
         self.title = None
+        self.__value = None
+        self.values = list()
 
         if type == "int":
-            self.value = 0
-        else:
-            self.value = None
+            self.add_value(0)
 
+    def add_value(self, value):
+        self.__value = value
+        self.values.append(value)
+
+    def get_value(self):
+        return self.__value
+
 class Queue(ModelObject):
     def __init__(self, model):
         super(Queue, self).__init__(model, model.queue)
@@ -296,40 +304,49 @@
 
         self.stats = list()
 
-        stat = StatProperty("msgTotalEnqueues", "int")
+        stat = Statistic("msgTotalEnqueues", "int")
         stat.title = "Total messages enqueued"
+        stat.categories = ("message", "general")
         self.stats.append(stat)
 
-        stat = StatProperty("msgTotalDequeues", "int")
+        stat = Statistic("msgTotalDequeues", "int")
         stat.title = "Total messages dequeued"
+        stat.categories = ("message", "general")
         self.stats.append(stat)
 
-        stat = StatProperty("msgTxEnqueues", "int")
+        stat = Statistic("msgTxEnqueues", "int")
         stat.title = "Transactional messages enqueued"
+        stat.categories = ("message", "transactional")
         self.stats.append(stat)
 
-        stat = StatProperty("msgTxDequeues", "int")
+        stat = Statistic("msgTxDequeues", "int")
         stat.title = "Transactional messages dequeued"
+        stat.categories = ("message", "transactional")
         self.stats.append(stat)
 
-        stat = StatProperty("msgPersistEnqueues", "int")
-        stat.title = "Persistent message enqueued"
+        stat = Statistic("msgPersistEnqueues", "int")
+        stat.title = "Persistent messages enqueued"
+        stat.categories = ("message", "persistent")
         self.stats.append(stat)
 
-        stat = StatProperty("msgPersistDequeues", "int")
+        stat = Statistic("msgPersistDequeues", "int")
         stat.title = "Persistent messages dequeued"
+        stat.categories = ("message", "persistent")
         self.stats.append(stat)
 
-        stat = StatProperty("msgDepth", "int")
+        stat = Statistic("msgDepth", "int")
         stat.title = "Current number of messages in queue"
+        stat.categories = ("message", "general")
         self.stats.append(stat)
 
-        stat = StatProperty("msgDepthHigh", "int")
+        stat = Statistic("msgDepthHigh", "int")
         stat.title = "Highest message depth in last x hours"
+        stat.categories = ("message", "general")
         self.stats.append(stat)
 
-        stat = StatProperty("msgDepthLow", "int")
+        stat = Statistic("msgDepthLow", "int")
         stat.title = "Lowest message depth in last x hours"
+        stat.categories = ("message", "general")
         self.stats.append(stat)
 
     def remove(self):

Modified: mgmt/cumin/python/cumin/queue.py
===================================================================
--- mgmt/cumin/python/cumin/queue.py	2007-10-19 20:13:06 UTC (rev 1125)
+++ mgmt/cumin/python/cumin/queue.py	2007-10-19 21:17:36 UTC (rev 1126)
@@ -341,6 +341,12 @@
         return "No, Cancel"
 
 class QueueStatistics(ItemSet):
+    def __init__(self, app, name):
+        super(QueueStatistics, self).__init__(app, name)
+
+        self.trans = BooleanParameter(app, "trans")
+        self.add_parameter(self.trans)
+
     def render_title(self, session, queue):
         return "Statistics"
 
@@ -351,4 +357,7 @@
         return stat.title
 
     def render_item_value(self, session, stat):
-        return stat.value
+        return stat.get_value()
+
+    def render_item_average_value(self, session, stat):
+        return "%0.2f" % (sum(stat.values) / float(len(stat.values)))

Modified: mgmt/cumin/python/cumin/queue.strings
===================================================================
--- mgmt/cumin/python/cumin/queue.strings	2007-10-19 20:13:06 UTC (rev 1125)
+++ mgmt/cumin/python/cumin/queue.strings	2007-10-19 21:17:36 UTC (rev 1126)
@@ -166,7 +166,7 @@
 [QueueStatistics.html]
 <table class="mobjects">
   <tr>
-    <th style="background-color: white;"></th>
+    <th>Statistic</th>
     <th>Current Value</th>
     <th>Average Value</th>
   </tr>
@@ -178,5 +178,5 @@
 <tr>
   <th>{item_title}</th>
   <td>{item_value}</td>
-  <td></td>
+  <td>{item_average_value}</td>
 </tr>
\ No newline at end of file




More information about the rhmessaging-commits mailing list