[rhmessaging-commits] rhmessaging commits: r2697 - mgmt/trunk/cumin/python/cumin.

rhmessaging-commits at lists.jboss.org rhmessaging-commits at lists.jboss.org
Wed Oct 29 16:22:50 EDT 2008


Author: eallen
Date: 2008-10-29 16:22:50 -0400 (Wed, 29 Oct 2008)
New Revision: 2697

Modified:
   mgmt/trunk/cumin/python/cumin/system.py
   mgmt/trunk/cumin/python/cumin/system.strings
Log:
Added slot visualization grid
Don't show orphaned slots (not updated in last 10 minutes)

Modified: mgmt/trunk/cumin/python/cumin/system.py
===================================================================
--- mgmt/trunk/cumin/python/cumin/system.py	2008-10-29 20:20:00 UTC (rev 2696)
+++ mgmt/trunk/cumin/python/cumin/system.py	2008-10-29 20:22:50 UTC (rev 2697)
@@ -2,6 +2,7 @@
 from wooly import *
 from wooly.widgets import *
 
+from stat import *
 from widgets import *
 from parameters import *
 from formats import *
@@ -47,6 +48,58 @@
 class SystemStatus(CuminStatus):
     pass
 
+class SystemStats(Widget):
+    def __init__(self, app, name):
+        super(SystemStats, self).__init__(app, name)
+
+        self.grid = self.SlotUtilizationGrid(app, "slot_grid")
+        self.add_child(self.grid)
+
+    def render_title(self, session):
+        return "Statistics"
+
+    class SlotUtilizationGrid(StatUtilizationGrid):
+        def get_args(self, session):
+            system = self.frame.get_args(session)[0]
+            action = self.app.model.system.slots
+            return action.get_slots(system)
+
+        def render_title(self, session, slots):
+            return "Slot Utilization"
+
+        def get_object_count(self, session, slots):
+            return slots.count()
+    
+        def get_colors(self, session):
+            action = self.app.model.system.slots
+            return action.get_colors()
+            
+        def render_color(self, session, count, slot):
+            action = self.app.model.system.slots
+            return action.get_color(slot)
+    
+        def render_contents(self, session, count, slot):
+            return ""
+
+        def render_cell_id(self, session, count, slot):
+            return "%i" % slot.sourceObjectId
+
+        def get_url(self, session):
+            system = self.parent.frame.get_args(session)[0]
+            return "call.xml?class=system;id=%i;method=slots" % system.id
+        
+        def get_fn(self, session):
+            return self.parent.grid.name
+        
+        def got_fn(self, session):
+            return self.parent.grid.name
+        
+        def elem_id(self, session):
+            return self.parent.grid.name
+    
+        def do_get_sticky_info(self, session):
+            return [("name", "Name"), ("machine", "Machine"), ("job", "Job")]
+
 class SystemView(CuminView):
     def __init__(self, app, name):
         super(SystemView, self).__init__(app, name)
@@ -60,6 +113,7 @@
         self.__tabs = TabbedModeSet(app, "tabs")
         self.add_child(self.__tabs)
 
+        self.__tabs.add_tab(SystemStats(app, "stats"))
         self.__tabs.add_tab(SystemJobSet(app, "jobs"))
         self.__tabs.add_tab(SystemSlotSet(app, "slots"))
         self.__tabs.add_tab(CuminDetails(app, "details"))
@@ -81,14 +135,17 @@
 class SystemSlotSet(SlotSet):
     def get_args(self, session):
         return self.frame.get_args(session)
-    
+
     def render_title(self, session, system):
-        sql = "machine = '%s'" % system.nodeName
-        return "Grid Slots %s" % fmt_count(Slot.select(sql).count())
+        return "Grid Slots %s" % fmt_count(self.get_item_count(session, system))
 
     def render_sql_where(self, session, system):
-        return "where s.machine = %(system_name)s"
+        elems = list()
+        elems.append("machine = %(nodeName)s")
+        elems.append("s.rec_time > now() - interval '90 minutes'")
+        elems.append("deletion_time is null")
+        return "where %s" % " and ".join(elems)
 
     def get_sql_values(self, session, system):
-        return {"system_name": system.nodeName}
+        return {"nodeName": system.nodeName}
 

Modified: mgmt/trunk/cumin/python/cumin/system.strings
===================================================================
--- mgmt/trunk/cumin/python/cumin/system.strings	2008-10-29 20:20:00 UTC (rev 2696)
+++ mgmt/trunk/cumin/python/cumin/system.strings	2008-10-29 20:22:50 UTC (rev 2697)
@@ -23,3 +23,28 @@
   </table>
   <div>{hidden_inputs}</div>
 </form>
+
+[SlotUtilizationGrid.javascript]
+function got_slot_grid(obj, id) {
+	for (var cell in obj.slots.slot) {
+		var slot = obj.slots.slot[cell]
+		var oslot_Button = document.getElementById("button_"+cell);
+		if (oslot_Button) {
+			oslot_Button.className = "btn "+slot.color;
+		}
+		var oslot_Name = document.getElementById("cell_name_"+cell);
+		if (oslot_Name) {
+			oslot_Name.innerHTML = slot.name;
+		}
+		var oslot_Machine = document.getElementById("cell_machine_"+cell);
+		if (oslot_Machine) {
+			oslot_Machine.innerHTML = slot.machine;
+		}
+		var oslot_Job = document.getElementById("cell_job_"+cell);
+		if (oslot_Job) {
+			oslot_Job.innerHTML = slot.job;
+		}
+	}
+	setTimeout("get_slot_grid()", 1000);
+}
+




More information about the rhmessaging-commits mailing list