Author: eallen
Date: 2008-09-23 12:49:54 -0400 (Tue, 23 Sep 2008)
New Revision: 2532
Added:
mgmt/trunk/cumin/python/cumin/limits.py
mgmt/trunk/cumin/python/cumin/limits.strings
Modified:
mgmt/trunk/cumin/python/cumin/pool.py
Log:
1st pass at limits tab under Pool
Added: mgmt/trunk/cumin/python/cumin/limits.py
===================================================================
--- mgmt/trunk/cumin/python/cumin/limits.py (rev 0)
+++ mgmt/trunk/cumin/python/cumin/limits.py 2008-09-23 16:49:54 UTC (rev 2532)
@@ -0,0 +1,193 @@
+import logging
+
+from wooly import *
+from wooly.widgets import *
+from wooly.forms import *
+from wooly.resources import *
+from wooly.tables import *
+
+from stat import *
+from widgets import *
+from parameters import *
+from formats import *
+from util import *
+from job import *
+
+strings = StringCatalog(__file__)
+log = logging.getLogger("cumin.Limits")
+
+class LimitsSet(ItemTable):
+ def __init__(self, app, name):
+ super(LimitsSet, self).__init__(app, name)
+
+ col = self.NameColumn(app, "name")
+ self.add_column(col)
+ self.set_default_column(col)
+
+ col = self.CurrentColumn(app, "curr")
+ self.add_column(col)
+
+ col = self.MaxColumn(app, "max")
+ self.add_column(col)
+
+ self.limits = self.Limits(self, "limits")
+ self.add_attribute(self.limits)
+
+ def do_get_items(self, session, *args):
+ limits = self.limits.get(session)
+ keys = limits.keys()
+ keys.sort()
+ return [{"name":x, "curr":limits[x]["CURRENT"],
"max":limits[x]["MAX"]} for x in keys]
+
+ def render_title(self, session):
+ return "Concurrancy Limits %s" % fmt_count(self.limit_count(session))
+
+ def limit_count(self, session):
+#TODO: fix this
+ negotiator = Negotiator.get(1)
+ limits = self.limits.get(session)
+ if not limits:
+ limits = self.get_raw_limits(session, negotiator)
+ self.limits.set(session, limits)
+ return len(limits)
+
+ def get_raw_limits(self, session, negotiator):
+ self.lim = dict()
+ self.got_data = False
+
+ def completion(status, data):
+ self.lim = data["Limits"]
+ self.got_data = True
+
+ def predicate():
+ return self.got_data
+
+ model = self.app.model
+ negotiator.GetLimits(model.data, completion, self.lim)
+
+ # wait for up to 20 seconds for completion to be called
+ wait(predicate, timeout=20)
+ return self.lim
+
+ class NameColumn(ItemTableColumn):
+ def render_title(self, session, data):
+ return "Name"
+
+ class CurrentColumn(ItemTableColumn):
+ def render_title(self, session, data):
+ return "Current Usage"
+
+ class MaxColumn(ItemTableColumn):
+ def render_title(self, session, data):
+ return "Max Usage"
+
+ class Limits(Attribute):
+ def get_default(self, session):
+ return dict()
+
+#class LimitsFrame(CuminFrame):
+# def __init__(self, app, name):
+# super(LimitsFrame, self).__init__(app, name)
+#
+# self.object = LimitsParameter(app, "id")
+# self.add_parameter(self.object)
+#
+# view = LimitsView(app, "view")
+# self.add_mode(view)
+# self.set_view_mode(view)
+#
+# def show_scheduler(self, session, scheduler):
+# return self.frame.show_scheduler(session, scheduler)
+#
+# def show_job(self, session, job):
+# return self.frame.show_job(session, job)
+#
+# def show_job_group(self, session, job_group):
+# return self.frame.show_job_group(session, job_group)
+#
+# def show_jobs_hold(self, session):
+# return self.frame.show_jobs_hold(session)
+#
+# def show_jobs_release(self, session):
+# return self.frame.show_jobs_release(session)
+#
+# def show_jobs_remove(self, session):
+# return self.frame.show_jobs_remove(session)
+#
+#
+#class LimitsView(CuminView):
+# def __init__(self, app, name):
+# super(LimitsView, self).__init__(app, name)
+#
+# status = LimitsStatus(app, "status")
+# self.add_child(status)
+#
+# self.__tabs = TabbedModeSet(app, "tabs")
+# self.add_child(self.__tabs)
+#
+# stats = LimitsStats(app, "stats")
+# self.__tabs.add_tab(stats)
+#
+# jobs = LimitsJobSet(app, "jobs")
+# self.__tabs.add_tab(jobs)
+#
+# details = CuminDetails(app, "details")
+# self.__tabs.add_tab(details)
+#
+# def render_script(self, session, sched):
+# data = "model.xml?class=scheduler;id=%i" % sched.id
+# return "wooly.setIntervalUpdate('%s', updateLimits, 3000)" %
data
+#
+#class LimitsStatus(CuminStatus):
+# pass
+#
+#class LimitsStats(Widget):
+# def __init__(self, app, name):
+# super(LimitsStats, self).__init__(app, name)
+#
+# stats = StatSet(app, "general", "general")
+# self.add_child(stats)
+#
+# chart = self.JobsChart(app, "jobs")
+# self.add_child(chart)
+#
+# def render_title(self, session):
+# return "Statistics"
+#
+# class JobsChart(StatValueChart):
+# def __init__(self, app, name):
+# super(LimitsStats.JobsChart, self).__init__ \
+# (app, name)
+#
+# self.stats = ("RunningJobs", "IdleJobs",
"HeldJobs")
+#
+# def render_title(self, session, sched):
+# return "Jobs"
+#
+#class LimitsJobSet(JobSet, Form):
+# def __init__(self, app, name):
+# super(LimitsJobSet, self).__init__(app, name)
+#
+# self.set_default_column_name("global_job_id")
+#
+# self.__remove = JobRemoveButton(app, "remove", self)
+# self.add_child(self.__remove)
+#
+# self.__hold = JobHoldButton(app, "hold", self)
+# self.add_child(self.__hold)
+#
+# self.__release = JobReleaseButton(app, "release", self)
+# self.add_child(self.__release)
+#
+# def get_visible_columns(self, session):
+# return self.get_request_visible_columns(session, ["custom_group",
"scheduler"])
+#
+# def render_sql_where(self, session, Limits):
+# phase_sql = self.get_phase_sql(session)
+# Limits_sql = "j.Limits_id = %i" % Limits.id
+# return "where %s" % " and ".join([phase_sql, Limits_sql])
+#
+# def render_title(self, session, Limits):
+# Limits_sql = "Limits_id = %i" % Limits.id
+# return "Jobs %s" % fmt_count(Job.select(Limits_sql).count())
+
Added: mgmt/trunk/cumin/python/cumin/limits.strings
===================================================================
--- mgmt/trunk/cumin/python/cumin/limits.strings (rev 0)
+++ mgmt/trunk/cumin/python/cumin/limits.strings 2008-09-23 16:49:54 UTC (rev 2532)
@@ -0,0 +1,12 @@
+[LimitsSet.html]
+<table class="mobjects">
+ <thead>
+ <tr>
+ <th class="setnav" colspan="{column_count}">
+ {count}
+ </th>
+ </tr>
+ <tr>{headers}</tr>
+ </thead>
+ <tbody>{items}</tbody>
+</table>
Modified: mgmt/trunk/cumin/python/cumin/pool.py
===================================================================
--- mgmt/trunk/cumin/python/cumin/pool.py 2008-09-23 16:49:10 UTC (rev 2531)
+++ mgmt/trunk/cumin/python/cumin/pool.py 2008-09-23 16:49:54 UTC (rev 2532)
@@ -14,6 +14,7 @@
from job import *
from scheduler import SchedulerSet, SchedulerFrame
from submitter import SubmitterSet, SubmitterFrame
+from limits import LimitsSet
strings = StringCatalog(__file__)
log = logging.getLogger("cumin.pool")
@@ -170,12 +171,18 @@
subs = self.SubmittersTab(app, "subs")
self.__tabs.add_tab(subs)
+ limits = self.LimitsTab(app, "limits")
+ self.__tabs.add_tab(limits)
+
class SchedulersTab(SchedulerSet):
pass
class SubmittersTab(SubmitterSet):
pass
+ class LimitsTab(LimitsSet):
+ pass
+
class PoolStatus(CuminStatus):
def render_status(self, session, pool):
return "Active"