Author: eallen
Date: 2008-09-23 17:21:47 -0400 (Tue, 23 Sep 2008)
New Revision: 2537
Modified:
mgmt/trunk/cumin/python/cumin/limits.py
mgmt/trunk/cumin/python/cumin/model.py
mgmt/trunk/cumin/python/cumin/parameters.py
mgmt/trunk/cumin/python/cumin/pool.py
Log:
Added LimitsFrame, LimitsView, and LimitsJobSet to Concurrency Limits
Modified: mgmt/trunk/cumin/python/cumin/limits.py
===================================================================
--- mgmt/trunk/cumin/python/cumin/limits.py 2008-09-23 21:20:30 UTC (rev 2536)
+++ mgmt/trunk/cumin/python/cumin/limits.py 2008-09-23 21:21:47 UTC (rev 2537)
@@ -25,9 +25,11 @@
self.set_default_column(col)
col = self.CurrentColumn(app, "curr")
+ col.alignment = "right"
self.add_column(col)
col = self.MaxColumn(app, "max")
+ col.alignment = "right"
self.add_column(col)
self.limits = self.Limits(self, "limits")
@@ -40,15 +42,18 @@
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))
+ return "Concurrency 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)
+#TODO: fix this. Where do we get the correct negotiator???
+ negotiators = Negotiator.select()
+ for negotiator in negotiators:
+ if negotiator.managedBroker:
+#TODO:
+ limits = self.get_raw_limits(session, negotiator)
+ self.limits.set(session, limits)
return len(limits)
def get_raw_limits(self, session, negotiator):
@@ -73,121 +78,76 @@
def render_title(self, session, data):
return "Name"
+ def render_content(self, session, data):
+ limit = Identifiable(data["name"])
+ branch = session.branch()
+ self.frame.show_limit(branch, limit).show_view(branch)
+ return fmt_olink(branch, limit, name=data["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"
+ return "Max Allowance"
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())
+class LimitsFrame(CuminFrame):
+ def __init__(self, app, name):
+ super(LimitsFrame, self).__init__(app, name)
+ self.object = LimitParameter(app, "id")
+ self.add_parameter(self.object)
+
+ view = LimitsView(app, "view")
+ self.add_mode(view)
+ self.set_view_mode(view)
+
+ def show_job(self, session, job):
+ return self.frame.show_job(session, job)
+
+ def show_scheduler(self, session, sched):
+ return self.frame.show_scheduler(session, sched)
+
+ def show_submitter(self, session, submitter):
+ return self.frame.show_submitter(session, submitter)
+
+ def show_job_group(self, session, job_group):
+ return self.frame.show_job_group(session, job_group)
+
+
+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)
+
+ jobs = LimitsJobSet(app, "jobs")
+ self.__tabs.add_tab(jobs)
+
+ details = CuminDetails(app, "details")
+ self.__tabs.add_tab(details)
+
+class LimitsStatus(CuminStatus):
+ pass
+
+class LimitsJobSet(JobSet, Form):
+ def get_visible_columns(self, session):
+ return self.get_request_visible_columns(session, ["custom_group",
"scheduler", "submitter"])
+
+ def render_sql_where(self, session, limit):
+ phase_sql = self.get_phase_sql(session)
+ Limits_sql = "j.concurrency_limits like '%%%s%%'" % limit.id
+ return "where %s" % " and ".join([phase_sql, Limits_sql])
+
+ def render_title(self, session, limit):
+ Limits_sql = "concurrency_limits like '%%%s%%'" % limit.id
+ return "Jobs %s" % fmt_count(Job.select(Limits_sql).count())
Modified: mgmt/trunk/cumin/python/cumin/model.py
===================================================================
--- mgmt/trunk/cumin/python/cumin/model.py 2008-09-23 21:20:30 UTC (rev 2536)
+++ mgmt/trunk/cumin/python/cumin/model.py 2008-09-23 21:21:47 UTC (rev 2537)
@@ -47,6 +47,7 @@
CuminSubmitter(self)
CuminJob(self)
CuminJobGroup(self)
+ CuminLimit(self)
CuminPool(self)
@@ -1535,6 +1536,19 @@
def show_object(self, session, pool):
return self.cumin_model.show_main(session).show_pool(session, pool)
+class CuminLimit(CuminClass):
+ def __init__(self, model):
+ super(CuminLimit, self).__init__ \
+ (model, "limit", Limit)
+
+ def get_title(self, session):
+ return "Concurrency Limit"
+
+ def get_object_title(self, session, limit):
+ title = self.get_title(session)
+ name = limit.id
+ return "%s '%s'" % (title, fmt_shorten(name))
+
class CuminJobGroup(CuminClass):
def __init__(self, model):
super(CuminJobGroup, self).__init__ \
Modified: mgmt/trunk/cumin/python/cumin/parameters.py
===================================================================
--- mgmt/trunk/cumin/python/cumin/parameters.py 2008-09-23 21:20:30 UTC (rev 2536)
+++ mgmt/trunk/cumin/python/cumin/parameters.py 2008-09-23 21:21:47 UTC (rev 2537)
@@ -86,6 +86,20 @@
def do_marshal(self, job_group):
return str(job_group.id)
+class Limit(object):
+ def __init__(self, id):
+ self.id = id
+
+ def get_id(self):
+ return self.id
+
+class LimitParameter(Parameter):
+ def do_unmarshal(self, string):
+ return Limit(string)
+
+ def do_marshal(self, limit):
+ return limit.id
+
class PeerParameter(Parameter):
def do_unmarshal(self, string):
return Link.get(int(string))
Modified: mgmt/trunk/cumin/python/cumin/pool.py
===================================================================
--- mgmt/trunk/cumin/python/cumin/pool.py 2008-09-23 21:20:30 UTC (rev 2536)
+++ mgmt/trunk/cumin/python/cumin/pool.py 2008-09-23 21:21:47 UTC (rev 2537)
@@ -14,7 +14,7 @@
from job import *
from scheduler import SchedulerSet, SchedulerFrame
from submitter import SubmitterSet, SubmitterFrame
-from limits import LimitsSet
+from limits import LimitsSet, LimitsFrame
strings = StringCatalog(__file__)
log = logging.getLogger("cumin.pool")
@@ -98,6 +98,9 @@
self.__job_group = JobGroupFrame(app, "jobgroup")
self.add_mode(self.__job_group)
+
+ self.__limit = LimitsFrame(app, "limit")
+ self.add_mode(self.__limit)
self.__job_group_hold = JobGroupHold(app, "jobgrouphold")
self.add_mode(self.__job_group_hold)
@@ -118,6 +121,11 @@
self.page.set_current_frame(session, self.__job_group)
return self.show_mode(session, self.__job_group)
+ def show_limit(self, session, limit):
+ self.__limit.set_object(session, limit)
+ self.page.set_current_frame(session, self.__limit)
+ return self.show_mode(session, self.__limit)
+
def show_scheduler(self, session, sched):
self.__sched.set_object(session, sched)
self.page.set_current_frame(session, self.__sched)