Author: eallen
Date: 2008-12-04 14:53:12 -0500 (Thu, 04 Dec 2008)
New Revision: 2926
Modified:
mgmt/trunk/cumin/python/cumin/model.py
mgmt/trunk/cumin/python/cumin/pool.py
mgmt/trunk/cumin/python/cumin/slot.py
mgmt/trunk/cumin/python/cumin/slot.strings
mgmt/trunk/cumin/python/cumin/system.py
Log:
Using slot.qmf_update_time to determine which slot to use when there are multiple
collectors.
Modified: mgmt/trunk/cumin/python/cumin/model.py
===================================================================
--- mgmt/trunk/cumin/python/cumin/model.py 2008-12-04 19:50:51 UTC (rev 2925)
+++ mgmt/trunk/cumin/python/cumin/model.py 2008-12-04 19:53:12 UTC (rev 2926)
@@ -2035,6 +2035,10 @@
def render_sql_where(self, session, pool):
elems = list()
elems.append("s.pool = %(pool)s")
+ recent = self.get_recent_sql_where(session)
+ if recent:
+ elems.append(recent)
+
if self.__machine:
elems.append("machine = %(machine)s")
Modified: mgmt/trunk/cumin/python/cumin/pool.py
===================================================================
--- mgmt/trunk/cumin/python/cumin/pool.py 2008-12-04 19:50:51 UTC (rev 2925)
+++ mgmt/trunk/cumin/python/cumin/pool.py 2008-12-04 19:53:12 UTC (rev 2926)
@@ -266,7 +266,13 @@
return self.frame.get_args(session)
def render_sql_where(self, session, pool):
- return "where s.pool = %(pool)s"
+ elems = list()
+ elems.append("s.pool = %(pool)s")
+ recent = self.get_recent_sql_where(session)
+ if recent:
+ elems.append(recent)
+
+ return "where %s" % " and ".join(elems)
def get_sql_values(self, session, pool):
return {"pool": pool.id}
@@ -274,13 +280,22 @@
def render_title(self, session, pool):
count = self.get_item_count(session, pool)
return "Slots %s" % fmt_count(count)
+
+ def filter(self, session, system, slots):
+ return slots
class PoolMachineSet(MachineSet):
def get_args(self, session):
return self.frame.get_args(session)
def render_sql_where(self, session, pool):
- return "where s.pool = %(pool)s"
+ elems = list()
+ elems.append("s.pool = %(pool)s")
+ recent = self.get_recent_sql_where(session)
+ if recent:
+ elems.append(recent)
+
+ return "where %s" % " and ".join(elems)
def get_sql_values(self, session, pool):
return {"pool": pool.id}
@@ -476,6 +491,10 @@
def render_sql_where(self, session, pool):
elems = list()
elems.append("s.pool = %(pool)s")
+ recent = self.get_recent_sql_where(session)
+ if recent:
+ elems.append(recent)
+
return "where %s" % " and ".join(elems)
def get_sql_values(self, session, pool):
Modified: mgmt/trunk/cumin/python/cumin/slot.py
===================================================================
--- mgmt/trunk/cumin/python/cumin/slot.py 2008-12-04 19:50:51 UTC (rev 2925)
+++ mgmt/trunk/cumin/python/cumin/slot.py 2008-12-04 19:53:12 UTC (rev 2926)
@@ -11,7 +11,15 @@
strings = StringCatalog(__file__)
log = logging.getLogger("cumin.job")
-class SlotSet(CuminTable):
+class UniqueSlot(CuminTable):
+ def get_recent_sql_where(self, session):
+ return """
+ (s.qmf_update_time =
+ (select max(qmf_update_time)
+ from slot as ss
+ where s.name = ss.name))"""
+
+class SlotSet(UniqueSlot):
def __init__(self, app, name):
super(SlotSet, self).__init__(app, name)
@@ -22,8 +30,8 @@
def render_title(self, session, data):
return "Name"
-class MachineSet(CuminTable):
+class MachineSet(UniqueSlot):
pass
-class SlotStatSet(CuminTable):
- pass
\ No newline at end of file
+class SlotStatSet(UniqueSlot):
+ pass
Modified: mgmt/trunk/cumin/python/cumin/slot.strings
===================================================================
--- mgmt/trunk/cumin/python/cumin/slot.strings 2008-12-04 19:50:51 UTC (rev 2925)
+++ mgmt/trunk/cumin/python/cumin/slot.strings 2008-12-04 19:53:12 UTC (rev 2926)
@@ -1,6 +1,6 @@
[SlotSet.sql]
-select distinct
- s.name as id,
+select
+ s.id,
s.name,
s.machine,
s.system,
@@ -9,7 +9,6 @@
c.activity
from slot as s
left outer join slot_stats as c on c.id = s.stats_curr_id
-left outer join slot_stats as p on p.id = s.stats_prev_id
left outer join job as j on j.custom_id = s.job_id
{sql_where}
{sql_orderby}
@@ -17,21 +16,20 @@
[SlotSet.count_sql]
select count(1)
-from (select distinct name, machine, system, pool, qmf_delete_time from slot as s
{sql_where}) as s
+from (select distinct name from slot as s {sql_where}) as s
-
[SlotStatSet.sql]
select
- sum(case activity when 'Idle' then 1 else 0 end) / coll_count as idle,
- sum(1) / coll_count as total
-from (select
- machine, s.pool, c.activity, count(coll.id) as coll_count
- from slot as s
- left outer join slot_stats as c on c.id = s.stats_curr_id
- left outer join collector as coll on coll.pool = s.pool
- group by machine, s.pool, c.activity, s.stats_curr_id) as s
+ sum(case activity when 'Idle' then 1 else 0 end) as idle,
+ sum(1) as total
+from (select
+ s.name,
+ s.pool,
+ s.qmf_update_time,
+ c.activity
+from slot as s
+left outer join slot_stats as c on c.id = s.stats_curr_id) as s
{sql_where}
-group by coll_count
[SlotStatSet.count_sql]
1
@@ -40,21 +38,22 @@
select
machine as id,
machine,
- sum(case activity when 'Busy' then 1 else 0 end) / coll_count as busy,
- sum(case activity when 'Idle' then 1 else 0 end) / coll_count as idle,
- sum(1) / coll_count as total
+ sum(case activity when 'Busy' then 1 else 0 end) as busy,
+ sum(case activity when 'Idle' then 1 else 0 end) as idle,
+ sum(1) as total
from
(select
- machine, s.pool, c.activity, count(coll.id) as coll_count
- from slot as s
- left outer join slot_stats as c on c.id = s.stats_curr_id
- left outer join collector as coll on coll.pool = s.pool
- group by machine, s.pool, c.activity, s.stats_curr_id) as s
+ s.name,
+ s.machine,
+ s.pool,
+ s.qmf_update_time,
+ c.activity
+ from slot as s
+ left outer join slot_stats as c on c.id = s.stats_curr_id) as s
{sql_where}
-group by machine, coll_count
+group by machine
{sql_orderby}
[MachineSet.count_sql]
-select count(*)
-from
- (select 1 from slot group by machine) as l
+select count(1)
+from (select distinct machine from slot) as s
Modified: mgmt/trunk/cumin/python/cumin/system.py
===================================================================
--- mgmt/trunk/cumin/python/cumin/system.py 2008-12-04 19:50:51 UTC (rev 2925)
+++ mgmt/trunk/cumin/python/cumin/system.py 2008-12-04 19:53:12 UTC (rev 2926)
@@ -143,13 +143,15 @@
def render_sql_where(self, session, system):
elems = list()
elems.append("system = %(nodeName)s")
- elems.append("s.qmf_delete_time is null")
+ recent = self.get_recent_sql_where(session)
+ if recent:
+ elems.append(recent)
+
return "where %s" % " and ".join(elems)
-
+
def get_sql_values(self, session, system):
return {"nodeName": system.nodeName}
-
class SystemServices(ItemSet):
def render_title(self, session, *args):
return "Services"