netrender: display dispatching rules under master header. (read only for now)
authorMartin Poirier <theeth@yahoo.com>
Mon, 21 Dec 2009 19:56:53 +0000 (19:56 +0000)
committerMartin Poirier <theeth@yahoo.com>
Mon, 21 Dec 2009 19:56:53 +0000 (19:56 +0000)
release/scripts/io/netrender/balancing.py
release/scripts/io/netrender/master_html.py
release/scripts/io/netrender/netrender.css

index 410279f6957ac74a00597c8ebb895cb858b5b598..d8951b1e2e8127cb5948e8a97ab04d4c580355fd 100644 (file)
@@ -81,11 +81,17 @@ class Balancer:
 # ==========================
 
 class RatingUsage(RatingRule):
+       def __str__(self):
+               return "Usage rating"
+       
        def rate(self, job):
                # less usage is better
                return job.usage / job.priority
 
 class RatingUsageByCategory(RatingRule):
+       def __str__(self):
+               return "Usage per category rating"
+       
        def __init__(self, get_jobs):
                self.getJobs = get_jobs
        def rate(self, job):
@@ -96,6 +102,12 @@ class RatingUsageByCategory(RatingRule):
                return total_category_usage / maximum_priority
        
 class NewJobPriority(PriorityRule):
+       def str_limit(self):
+               return "less than %i frame%s done" % (self.limit, "s" if self.limit > 1 else "")
+
+       def __str__(self):
+               return "Priority to new jobs"
+       
        def __init__(self, limit = 1):
                self.limit = limit
                
@@ -103,6 +115,12 @@ class NewJobPriority(PriorityRule):
                return job.countFrames(status = DONE) < self.limit
 
 class MinimumTimeBetweenDispatchPriority(PriorityRule):
+       def str_limit(self):
+               return "more than %i minute%s since last" % (self.limit, "s" if self.limit > 1 else "")
+
+       def __str__(self):
+               return "Priority to jobs that haven't been dispatched recently"
+       
        def __init__(self, limit = 10):
                self.limit = limit
                
@@ -110,10 +128,19 @@ class MinimumTimeBetweenDispatchPriority(PriorityRule):
                return job.countFrames(status = DISPATCHED) == 0 and (time.time() - job.last_dispatched) / 60 > self.limit
 
 class ExcludeQueuedEmptyJob(ExclusionRule):
+       def __str__(self):
+               return "Exclude queued and empty jobs"
+       
        def test(self, job):
                return job.status != JOB_QUEUED or job.countFrames(status = QUEUED) == 0
        
 class ExcludeSlavesLimit(ExclusionRule):
+       def str_limit(self):
+               return "more than %.0f%% of all slaves" % (self.limit * 100)
+
+       def __str__(self):
+               return "Exclude jobs that would use too many slaves"
+       
        def __init__(self, count_jobs, count_slaves, limit = 0.75):
                self.count_jobs = count_jobs
                self.count_slaves = count_slaves
index 99d74b640196800dbe83de043c80a1a1fc37d6da..1f530efa7c6ef91fd682e930f746c0cc22dc0a0e 100644 (file)
@@ -40,8 +40,16 @@ def get(handler):
        def link(text, url):
                return "<a href='%s'>%s</a>" % (url, text)
        
-       def startTable(border=1):
-               output("<table border='%i'>" % border)
+       def startTable(border=1, class_style = None, caption = None):
+               output("<table border='%i'" % border)
+               
+               if class_style:
+                       output(" class='%s'" % class_style)
+               
+               output(">")
+                       
+               if caption:
+                       output("<caption>%s</caption>" % caption)
        
        def headerTable(*headers):
                output("<thead><tr>")
@@ -93,8 +101,23 @@ def get(handler):
        
                output("<h2>Master</h2>")
                
-               output("""<button title="remove all jobs" onclick="request('/clear', null);">CLEAR</button>""")
+               output("""<button title="remove all jobs" onclick="request('/clear', null);">CLEAR JOB LIST</button>""")
+
+               startTable(caption = "Rules", class_style = "rules")
+
+               headerTable("type", "description", "limit")
+
+               for rule in handler.server.balancer.rules:
+                       rowTable("rating", rule, rule.str_limit() if hasattr(rule, "limit") else "&nbsp;")
+
+               for rule in handler.server.balancer.priorities:
+                       rowTable("priority", rule, rule.str_limit() if hasattr(rule, "limit") else "&nbsp;")
                
+               for rule in handler.server.balancer.exceptions:
+                       rowTable("exception", rule, rule.str_limit() if hasattr(rule, "limit") else "&nbsp;")
+
+               endTable()
+
                output("<h2>Slaves</h2>")
                
                startTable()
index 20a64ff984a798b3bbc8b950b170494669e8361f..87de1083315d4d5ee3f5fcf36b77530461862ebb 100644 (file)
@@ -17,6 +17,12 @@ h2 {
         padding:5px;
 }
 
+h2 {
+        background-color:#ddd;
+        font-size:110%;
+        padding:5px;
+}
+
 table {
        text-align:center;
         border:0;
@@ -62,3 +68,8 @@ button {
 .fluid {
        display: none;
 }
+
+.rules {
+       width: 60em;
+       text-align: left;
+}
\ No newline at end of file