[rhmessaging-commits] rhmessaging commits: r1167 - in mgmt: notes and 1 other directory.

rhmessaging-commits at lists.jboss.org rhmessaging-commits at lists.jboss.org
Fri Oct 26 11:00:45 EDT 2007


Author: justi9
Date: 2007-10-26 11:00:45 -0400 (Fri, 26 Oct 2007)
New Revision: 1167

Modified:
   mgmt/cumin/python/cumin/broker.strings
   mgmt/cumin/python/cumin/brokercluster.py
   mgmt/cumin/python/cumin/brokercluster.strings
   mgmt/cumin/python/cumin/brokergroup.py
   mgmt/cumin/python/cumin/demo.py
   mgmt/cumin/python/cumin/model.py
   mgmt/cumin/python/cumin/page.strings
   mgmt/cumin/python/cumin/widgets.py
   mgmt/notes/Todo
Log:
Introduces status lights (instead of warning and error counts) in more
places.  Changes the error and warning states to display a number.



Modified: mgmt/cumin/python/cumin/broker.strings
===================================================================
--- mgmt/cumin/python/cumin/broker.strings	2007-10-26 14:02:43 UTC (rev 1166)
+++ mgmt/cumin/python/cumin/broker.strings	2007-10-26 15:00:45 UTC (rev 1167)
@@ -15,7 +15,7 @@
   <td>{item_link}</td>
   <td>{item_profile_link}</td>
   <td>{item_cluster_link}</td>
-  <td>0 errors, 0 warnings</td>
+  <td>{item_status}</td>
 </tr>
 
 [BrokerSetForm.html]

Modified: mgmt/cumin/python/cumin/brokercluster.py
===================================================================
--- mgmt/cumin/python/cumin/brokercluster.py	2007-10-26 14:02:43 UTC (rev 1166)
+++ mgmt/cumin/python/cumin/brokercluster.py	2007-10-26 15:00:45 UTC (rev 1167)
@@ -27,11 +27,15 @@
         self.page().show_broker_cluster(branch, cluster).show_view(branch)
         return mlink(branch.marshal(), "BrokerCluster", cluster.name)
 
-    def render_item_broker_lights(self, session, cluster):
+    def render_item_config(self, session, cluster):
+        count = len(cluster.broker_items())
+        return "%i broker%s" % (count, ess(count))
+
+    def render_item_status(self, session, cluster):
         writer = Writer()
         
         for broker in sorted_by(cluster.broker_items()):
-            self.broker_tmpl.render(session, broker, writer)
+            writer.write(status(len(broker.errors), len(broker.warnings)))
 
         return writer.to_string()
 

Modified: mgmt/cumin/python/cumin/brokercluster.strings
===================================================================
--- mgmt/cumin/python/cumin/brokercluster.strings	2007-10-26 14:02:43 UTC (rev 1166)
+++ mgmt/cumin/python/cumin/brokercluster.strings	2007-10-26 15:00:45 UTC (rev 1167)
@@ -26,11 +26,8 @@
 [BrokerClusterSet.item_html]
 <tr>
   <td>{item_link}</td>
-  <td>3 brokers</td>
-  <td>
-    <div>0 errors, 0 warnings</div>
-    <div>{item_broker_lights}</div>
-  </td>
+  <td>{item_config}</td>
+  <td>{item_status}</td>
 </tr>
 
 [BrokerClusterSet.broker_html]

Modified: mgmt/cumin/python/cumin/brokergroup.py
===================================================================
--- mgmt/cumin/python/cumin/brokergroup.py	2007-10-26 14:02:43 UTC (rev 1166)
+++ mgmt/cumin/python/cumin/brokergroup.py	2007-10-26 15:00:45 UTC (rev 1167)
@@ -1,7 +1,7 @@
 from wooly import *
 from wooly.widgets import *
 
-from broker import BrokerSet
+from broker import BrokerSetForm
 from model import *
 from widgets import *
 from parameters import *
@@ -30,7 +30,7 @@
         return "%i broker%s" % (count, count == 1 and "" or "s")
 
     def render_item_status(self, session, group):
-        return "0 errors, 0 warnings"
+        return status(len(group.errors), len(group.warnings))
 
     def render_none(self, session, group):
         return none()
@@ -77,7 +77,7 @@
         self.page().show_broker_group(branch, group).show_edit(branch)
         return branch.marshal()
 
-    class GroupBrokerTab(BrokerSet):
+    class GroupBrokerTab(BrokerSetForm):
         def get_items(self, session, group):
             return sorted_by(group.broker_items())
         

Modified: mgmt/cumin/python/cumin/demo.py
===================================================================
--- mgmt/cumin/python/cumin/demo.py	2007-10-26 14:02:43 UTC (rev 1166)
+++ mgmt/cumin/python/cumin/demo.py	2007-10-26 15:00:45 UTC (rev 1167)
@@ -171,6 +171,21 @@
         self.model = model
         self.setDaemon(True)
 
+    def frob(self, mobject):
+        mobject.lock()
+        try:
+            if isinstance(mobject, MeasuredModelObject):
+                for measure in mobject.measurements:
+                    self.frob_measure(measure)
+
+            if hasattr(mobject, "errors"):
+                self.frob_errors(mobject.errors)
+
+            if hasattr(mobject, "warnings"):
+                self.frob_errors(mobject.warnings)
+        finally:
+            mobject.unlock()
+
     def frob_measure(self, measure):
         if measure.type == "int":
             if random() < 0.5:
@@ -183,88 +198,44 @@
             else:
                 measure.add_value(measure.get_value())
                 
+    def frob_errors(self, errors):
+        if random() < 0.005:
+            errors.append(object())
 
+        if random() < 0.02 and len(errors):
+            del errors[0]
+
+
     def run(self):
         while True:
             sleep(1)
 
             for broker in self.model.get_brokers():
-                if random() < 0.005:
-                    broker.errors.append(object())
+                self.frob(broker)
 
-                if random() < 0.02 and len(broker.errors):
-                    del broker.errors[0]
-
-                if random() < 0.005:
-                    broker.warnings.append(object())
-
-                if random() < 0.02 and len(broker.warnings):
-                    del broker.warnings[0]
-
                 for vhost in broker.virtual_host_items():
+                    self.frob(vhost)
+                    
                     for exchange in vhost.exchange_items():
-                        exchange.lock()
-                        try:
-                            for measure in exchange.measurements:
-                                self.frob_measure(measure)
-                        finally:
-                            exchange.unlock()
-
+                        self.frob(exchange)
+                        
                         for binding in exchange.binding_items():
-                            binding.lock()
-                            try:
-                                for measure in binding.measurements:
-                                    self.frob_measure(measure)
-                            finally:
-                                binding.unlock()
+                            self.frob(binding)
 
                         for producer in exchange.producer_items():
-                            producer.lock()
-                            try:
-                                for measure in producer.measurements:
-                                    self.frob_measure(measure)
-                            finally:
-                                producer.unlock()
-                    
+                            self.frob(producer)
+
                     for queue in vhost.queue_items():
-                        queue.lock()
-                        try:
-                            for measure in queue.measurements:
-                                self.frob_measure(measure)
+                        self.frob(queue)
 
-                            queue.message_count += 1
-
-                            if random() < 0.01:
-                                queue.error_count += 1
-
-                            if random() < 0.01:
-                                queue.warning_count += 1
-                        finally:
-                            queue.unlock()
-
                         for consumer in queue.consumer_items():
-                            consumer.lock()
-                            try:
-                                for measure in consumer.measurements:
-                                    self.frob_measure(measure)
-                            finally:
-                                consumer.unlock()
+                            self.frob(consumer)
 
                     for client in vhost.client_items():
-                        client.lock()
-                        try:
-                            for measure in client.measurements:
-                                self.frob_measure(measure)
-                        finally:
-                            client.unlock()
+                        self.frob(client)
 
                         for session in client.session_items():
-                            session.lock()
-                            try:
-                                for measure in session.measurements:
-                                    self.frob_measure(measure)
-                            finally:
-                                session.unlock()
+                            self.frob(session)
                         
 if __name__ == "__main__":
     import sys

Modified: mgmt/cumin/python/cumin/model.py
===================================================================
--- mgmt/cumin/python/cumin/model.py	2007-10-26 14:02:43 UTC (rev 1166)
+++ mgmt/cumin/python/cumin/model.py	2007-10-26 15:00:45 UTC (rev 1167)
@@ -233,6 +233,8 @@
         super(BrokerGroup, self).__init__(model, model.broker_group)
 
         self.name = None
+        self.errors = list()
+        self.warnings = list()
 
 class BrokerGroupType(ModelObject):
     def __init__(self, model):

Modified: mgmt/cumin/python/cumin/page.strings
===================================================================
--- mgmt/cumin/python/cumin/page.strings	2007-10-26 14:02:43 UTC (rev 1166)
+++ mgmt/cumin/python/cumin/page.strings	2007-10-26 15:00:45 UTC (rev 1167)
@@ -343,7 +343,11 @@
   width: 1em;
   height: 1em;
   margin: 0.25em 1px 0 0;
-  padding: 0;
+  padding: 0.15em;
+  color: #fff;
+  font-size: 0.8em;
+  text-align: center;
+  line-height: 1.1em;
 }
 
 div.statuslight.red {
@@ -351,7 +355,7 @@
 }
 
 div.statuslight.yellow {
-  background-color: #ee6;
+  background-color: #fd3;
 }
 
 div.statuslight.green {

Modified: mgmt/cumin/python/cumin/widgets.py
===================================================================
--- mgmt/cumin/python/cumin/widgets.py	2007-10-26 14:02:43 UTC (rev 1166)
+++ mgmt/cumin/python/cumin/widgets.py	2007-10-26 15:00:45 UTC (rev 1167)
@@ -14,9 +14,11 @@
 def none():
     return "<span class=\"none\">None</span>"
 
-def status(errs, warns):
-    return "<div class=\"statuslight %s\"/>" % \
-           (errs + warns == 0 and "green" or (errs and "red" or "yellow"))
+def status(errors, warnings):
+    count = errors + warnings
+    return "<div class=\"statuslight %s\">%s</div>" % \
+           (count == 0 and "green" or (errors and "red" or "yellow"),
+            count == 0 and "&nbsp;" or str(count))
 
 class CuminFrame(Frame, ModeSet):
     def __init__(self, app, name):

Modified: mgmt/notes/Todo
===================================================================
--- mgmt/notes/Todo	2007-10-26 14:02:43 UTC (rev 1166)
+++ mgmt/notes/Todo	2007-10-26 15:00:45 UTC (rev 1167)
@@ -63,8 +63,6 @@
 
    - Remove config tab
 
- * Move q,e to server level (using default vhost)
-
  * Cluster
 
    - Add load balance action
@@ -104,4 +102,4 @@
  * Right now, non cumin pages don't print their stack traces in the
    log
 
- * Make the 0 errors, 0 warnings thing more compact; maybe just lights
+ * Move q,e to server level (using default vhost)




More information about the rhmessaging-commits mailing list