aurora-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ma...@apache.org
Subject git commit: Calculate median SLA stats over sampling interval.
Date Wed, 24 Sep 2014 21:10:53 GMT
Repository: incubator-aurora
Updated Branches:
  refs/heads/master 24bcbdc53 -> 2298914ef


Calculate median SLA stats over sampling interval.

Bugs closed: AURORA-733

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


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

Branch: refs/heads/master
Commit: 2298914ef4c74b0c7ac4dc0fd160365f4510c657
Parents: 24bcbdc
Author: Maxim Khutornenko <maxim@apache.org>
Authored: Wed Sep 24 14:09:03 2014 -0700
Committer: Maxim Khutornenko <maxim@apache.org>
Committed: Wed Sep 24 14:09:03 2014 -0700

----------------------------------------------------------------------
 .../aurora/scheduler/sla/SlaAlgorithm.java      |  6 ++--
 .../aurora/scheduler/sla/SlaAlgorithmTest.java  | 30 ++++++++++++++------
 2 files changed, 26 insertions(+), 10 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-aurora/blob/2298914e/src/main/java/org/apache/aurora/scheduler/sla/SlaAlgorithm.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/aurora/scheduler/sla/SlaAlgorithm.java b/src/main/java/org/apache/aurora/scheduler/sla/SlaAlgorithm.java
index 82f1894..33b6bbe 100644
--- a/src/main/java/org/apache/aurora/scheduler/sla/SlaAlgorithm.java
+++ b/src/main/java/org/apache/aurora/scheduler/sla/SlaAlgorithm.java
@@ -99,7 +99,9 @@ interface SlaAlgorithm {
    * <pre>
    *    MT =  MEDIAN(Wait_times)
    * where:
-   *    Wait_times - a collection of time intervals between PENDING and specified task state.
+   *    Wait_times - a collection of qualifying time intervals between PENDING and specified
task
+   *                 state. An interval is qualified if its end point is contained by the
sample
+   *                 time frame.
    *</pre>
    */
   final class MedianAlgorithm implements SlaAlgorithm {
@@ -121,7 +123,7 @@ interface SlaAlgorithm {
         for (ITaskEvent event : task.getTaskEvents()) {
           if (event.getStatus() == ScheduleStatus.PENDING) {
             pendingTs = event.getTimestamp();
-          } else if (event.getStatus() == status) {
+          } else if (event.getStatus() == status && timeFrame.contains(event.getTimestamp()))
{
 
             if (pendingTs == 0) {
               throw new IllegalArgumentException("SLA: missing PENDING status for:"

http://git-wip-us.apache.org/repos/asf/incubator-aurora/blob/2298914e/src/test/java/org/apache/aurora/scheduler/sla/SlaAlgorithmTest.java
----------------------------------------------------------------------
diff --git a/src/test/java/org/apache/aurora/scheduler/sla/SlaAlgorithmTest.java b/src/test/java/org/apache/aurora/scheduler/sla/SlaAlgorithmTest.java
index e775527..eccf0c7 100644
--- a/src/test/java/org/apache/aurora/scheduler/sla/SlaAlgorithmTest.java
+++ b/src/test/java/org/apache/aurora/scheduler/sla/SlaAlgorithmTest.java
@@ -55,7 +55,7 @@ public class SlaAlgorithmTest {
             makeTask(ImmutableMap.of(50L, PENDING, 200L, ASSIGNED, 250L, KILLED)),
             makeTask(ImmutableMap.of(100L, PENDING, 200L, ASSIGNED, 300L, RUNNING)),
             makeTask(ImmutableMap.of(200L, PENDING, 250L, ASSIGNED, 350L, STARTING))),
-        Range.<Long>all());
+        Range.closedOpen(0L, 300L));
     assertEquals(50L, actual);
   }
 
@@ -66,7 +66,7 @@ public class SlaAlgorithmTest {
             makeTask(ImmutableMap.of(50L, PENDING, 200L, ASSIGNED, 250L, RUNNING)),
             makeTask(ImmutableMap.of(100L, PENDING, 200L, ASSIGNED, 300L, RUNNING)),
             makeTask(ImmutableMap.of(200L, PENDING, 250L, ASSIGNED, 350L, STARTING))),
-        Range.<Long>all());
+        Range.closedOpen(0L, 300L));
     assertEquals(100L, actual);
   }
 
@@ -76,7 +76,7 @@ public class SlaAlgorithmTest {
         ImmutableSet.of(
             makeTask(ImmutableMap.of(50L, PENDING)),
             makeTask(ImmutableMap.of(100L, PENDING, 200L, ASSIGNED, 300L, KILLED))),
-        Range.<Long>all());
+        Range.closedOpen(0L, 300L));
     assertEquals(0L, actual);
   }
 
@@ -86,7 +86,7 @@ public class SlaAlgorithmTest {
         ImmutableSet.of(
             makeTask(ImmutableMap.of(50L, PENDING)),
             makeTask(ImmutableMap.of(100L, PENDING, 200L, ASSIGNED))),
-        Range.<Long>all());
+        Range.closedOpen(0L, 300L));
     assertEquals(100L, actual);
   }
 
@@ -95,7 +95,7 @@ public class SlaAlgorithmTest {
     MEDIAN_TIME_TO_ASSIGNED.getAlgorithm().calculate(
         ImmutableSet.of(
             makeTask(ImmutableMap.of(50L, ASSIGNED))),
-        Range.<Long>all());
+        Range.closedOpen(0L, 300L));
   }
 
   @Test
@@ -111,7 +111,7 @@ public class SlaAlgorithmTest {
                 150L, STARTING,
                 200L, RUNNING,
                 300L, KILLED))), // Ignored due to being terminal.
-        Range.<Long>all());
+        Range.closedOpen(0L, 500L));
     assertEquals(130L, actual);
   }
 
@@ -123,7 +123,7 @@ public class SlaAlgorithmTest {
             makeTask(ImmutableMap.of(50L, PENDING, 100L, ASSIGNED, 150L, STARTING, 180L,
RUNNING)),
             makeTask(ImmutableMap.of(100L, PENDING, 200L, ASSIGNED, 300L, STARTING, 400L,
RUNNING)),
             makeTask(ImmutableMap.of(50L, PENDING, 100L, ASSIGNED, 150L, STARTING, 200L,
RUNNING))),
-        Range.<Long>all());
+        Range.closedOpen(0L, 500L));
     assertEquals(150L, actual);
   }
 
@@ -133,11 +133,25 @@ public class SlaAlgorithmTest {
         ImmutableSet.of(
             makeTask(ImmutableMap.of(50L, PENDING)),
             makeTask(ImmutableMap.of(50L, PENDING, 100L, RUNNING, 200L, KILLED))),
-            Range.<Long>all());
+        Range.closedOpen(0L, 500L));
     assertEquals(0L, actual);
   }
 
   @Test
+  public void MedianTimeEventsOutsideTimeRangeIgnored() {
+    Number actual = MEDIAN_TIME_TO_ASSIGNED.getAlgorithm().calculate(
+        ImmutableSet.of(
+            makeTask(ImmutableMap.of(50L, PENDING)),
+            makeTask(ImmutableMap.of(100L, PENDING, 200L, ASSIGNED)),
+            makeTask(ImmutableMap.of(100L, PENDING, 300L, ASSIGNED)),
+            makeTask(ImmutableMap.of(100L, PENDING, 150L, ASSIGNED)),
+            makeTask(ImmutableMap.of(100L, PENDING, 260L, ASSIGNED)),
+            makeTask(ImmutableMap.of(100L, PENDING, 400L, ASSIGNED))),
+        Range.closedOpen(200L, 300L));
+    assertEquals(100L, actual);
+  }
+
+  @Test
   public void JobUptime50Test() {
     long now = System.currentTimeMillis();
     Number actual = JOB_UPTIME_50.getAlgorithm().calculate(


Mime
View raw message