aurora-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ma...@apache.org
Subject git commit: Improving sla_list_safe_domain performance
Date Tue, 25 Feb 2014 23:08:23 GMT
Repository: incubator-aurora
Updated Branches:
  refs/heads/master d37a833ee -> a3eb57838


Improving sla_list_safe_domain performance

Bugs closed: AURORA-233

Reviewed at https://reviews.apache.org/r/18485/


Project: http://git-wip-us.apache.org/repos/asf/incubator-aurora/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-aurora/commit/a3eb5783
Tree: http://git-wip-us.apache.org/repos/asf/incubator-aurora/tree/a3eb5783
Diff: http://git-wip-us.apache.org/repos/asf/incubator-aurora/diff/a3eb5783

Branch: refs/heads/master
Commit: a3eb578380fab0710b65712f00997fdc7ecccd23
Parents: d37a833
Author: Maxim Khutornenko <maxim@apache.org>
Authored: Tue Feb 25 15:07:40 2014 -0800
Committer: Maxim Khutornenko <maxim@apache.org>
Committed: Tue Feb 25 15:07:40 2014 -0800

----------------------------------------------------------------------
 src/main/python/apache/aurora/client/api/sla.py      | 13 +++++++++----
 src/test/python/apache/aurora/client/api/test_sla.py | 12 ++++++++----
 2 files changed, 17 insertions(+), 8 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-aurora/blob/a3eb5783/src/main/python/apache/aurora/client/api/sla.py
----------------------------------------------------------------------
diff --git a/src/main/python/apache/aurora/client/api/sla.py b/src/main/python/apache/aurora/client/api/sla.py
index 4fcc075..131c357 100644
--- a/src/main/python/apache/aurora/client/api/sla.py
+++ b/src/main/python/apache/aurora/client/api/sla.py
@@ -23,7 +23,7 @@ from copy import deepcopy
 from apache.aurora.client.base import check_and_log_response
 from apache.aurora.common.aurora_job_key import AuroraJobKey
 
-from gen.apache.aurora.constants import ACTIVE_STATES
+from gen.apache.aurora.constants import LIVE_STATES
 from gen.apache.aurora.ttypes import (
   Identity,
   Quota,
@@ -34,6 +34,9 @@ from gen.apache.aurora.ttypes import (
 )
 
 
+SLA_LIVE_STATES = LIVE_STATES | set([ScheduleStatus.STARTING])
+
+
 class JobUpTimeSlaVector(object):
   """A grouping of job active tasks by:
       - instance: Map of instance ID -> instance uptime in seconds.
@@ -194,12 +197,14 @@ class DomainUpTimeSlaVector(object):
     return probed_hosts
 
   def _simulate_host_down(self, job_key, host, duration):
+    unfiltered_tasks = self._jobs[job_key]
+
     # Get total job task count to use in SLA calculation.
-    total_count = JobUpTimeSlaVector(self._jobs[job_key]).total_tasks()
+    total_count = len(unfiltered_tasks)
 
     # Get a list of job tasks that would remain after the affected host goes down
     # and create an SLA vector with these tasks.
-    filtered_tasks = [task for task in self._jobs[job_key]
+    filtered_tasks = [task for task in unfiltered_tasks
                       if task.assignedTask.slaveHost != host]
     filtered_vector = JobUpTimeSlaVector(filtered_tasks, self._now)
 
@@ -256,4 +261,4 @@ class Sla(object):
         environment=job_key.env if job_key else None,
         jobName=job_key.name if job_key else None,
         slaveHost=host,
-        statuses=ACTIVE_STATES)
+        statuses=SLA_LIVE_STATES)

http://git-wip-us.apache.org/repos/asf/incubator-aurora/blob/a3eb5783/src/test/python/apache/aurora/client/api/test_sla.py
----------------------------------------------------------------------
diff --git a/src/test/python/apache/aurora/client/api/test_sla.py b/src/test/python/apache/aurora/client/api/test_sla.py
index 4f0a2c0..79ec921 100644
--- a/src/test/python/apache/aurora/client/api/test_sla.py
+++ b/src/test/python/apache/aurora/client/api/test_sla.py
@@ -17,12 +17,16 @@
 import unittest
 import time
 
-from apache.aurora.client.api.sla import DomainUpTimeSlaVector, JobUpTimeSlaVector, Sla
+from apache.aurora.client.api.sla import (
+    DomainUpTimeSlaVector,
+    JobUpTimeSlaVector,
+    Sla,
+    SLA_LIVE_STATES
+)
 from apache.aurora.common.aurora_job_key import AuroraJobKey
 from apache.aurora.common.cluster import Cluster
 
 from gen.apache.aurora.AuroraSchedulerManager import Client as scheduler_client
-from gen.apache.aurora.constants import ACTIVE_STATES
 from gen.apache.aurora.ttypes import (
     AssignedTask,
     Identity,
@@ -149,11 +153,11 @@ class SlaTest(unittest.TestCase):
             owner=Identity(role=self._role),
             environment=self._env,
             jobName=self._name,
-            statuses=ACTIVE_STATES)
+            statuses=SLA_LIVE_STATES)
     )
 
   def expect_task_status_call_cluster_scoped(self):
-    self._scheduler.getTasksStatus.assert_called_once_with(TaskQuery(statuses=ACTIVE_STATES))
+    self._scheduler.getTasksStatus.assert_called_once_with(TaskQuery(statuses=SLA_LIVE_STATES))
 
 
   def test_count_0(self):


Mime
View raw message