aurora-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jco...@apache.org
Subject aurora git commit: Expose finer grained offer veto stats
Date Wed, 25 Jan 2017 19:27:17 GMT
Repository: aurora
Updated Branches:
  refs/heads/master 52ddce919 -> 3cdcd17a5


Expose finer grained offer veto stats

Bugs closed: AURORA-1835

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


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

Branch: refs/heads/master
Commit: 3cdcd17a5591f7d6f4db81e1b52657e0e080c93e
Parents: 52ddce9
Author: Mehrdad Nurolahzade <mehrdad@nurolahzade.com>
Authored: Wed Jan 25 13:26:56 2017 -0600
Committer: Joshua Cohen <jcohen@apache.org>
Committed: Wed Jan 25 13:26:56 2017 -0600

----------------------------------------------------------------------
 .../java/org/apache/aurora/scheduler/TaskVars.java    | 13 +++++++++++++
 .../org/apache/aurora/scheduler/TaskVarsTest.java     | 14 ++++++++++++++
 2 files changed, 27 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/aurora/blob/3cdcd17a/src/main/java/org/apache/aurora/scheduler/TaskVars.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/aurora/scheduler/TaskVars.java b/src/main/java/org/apache/aurora/scheduler/TaskVars.java
index 6351cc7..676dfd9 100644
--- a/src/main/java/org/apache/aurora/scheduler/TaskVars.java
+++ b/src/main/java/org/apache/aurora/scheduler/TaskVars.java
@@ -43,6 +43,7 @@ import org.apache.aurora.scheduler.events.PubsubEvent.TasksDeleted;
 import org.apache.aurora.scheduler.events.PubsubEvent.Vetoed;
 import org.apache.aurora.scheduler.filter.SchedulingFilter.Veto;
 import org.apache.aurora.scheduler.filter.SchedulingFilter.VetoGroup;
+import org.apache.aurora.scheduler.filter.SchedulingFilter.VetoType;
 import org.apache.aurora.scheduler.storage.AttributeStore;
 import org.apache.aurora.scheduler.storage.Storage;
 import org.apache.aurora.scheduler.storage.entities.IAttribute;
@@ -67,6 +68,15 @@ class TaskVars extends AbstractIdleService implements EventSubscriber {
       VetoGroup.MIXED, "scheduling_veto_mixed"
   );
 
+  @VisibleForTesting
+  static final Map<VetoType, String> VETO_TYPE_TO_COUNTERS = ImmutableMap.of(
+      VetoType.CONSTRAINT_MISMATCH, "scheduling_veto_constraint_mismatch",
+      VetoType.DEDICATED_CONSTRAINT_MISMATCH, "scheduling_veto_dedicated_constraint_mismatch",
+      VetoType.INSUFFICIENT_RESOURCES, "scheduling_veto_insufficient_resources",
+      VetoType.LIMIT_NOT_SATISFIED, "scheduling_veto_limit_not_satisfied",
+      VetoType.MAINTENANCE, "scheduling_veto_maintenance"
+  );
+
   private final LoadingCache<String, Counter> counters;
   private final LoadingCache<String, Counter> untrackedCounters;
   private final Storage storage;
@@ -217,6 +227,9 @@ class TaskVars extends AbstractIdleService implements EventSubscriber
{
     if (vetoGroup != VetoGroup.EMPTY) {
       counters.getUnchecked(VETO_GROUPS_TO_COUNTERS.get(vetoGroup)).increment();
     }
+    for (Veto veto : event.getVetoes()) {
+      counters.getUnchecked(VETO_TYPE_TO_COUNTERS.get(veto.getVetoType())).increment();
+    }
   }
 
   private static class Counter implements Supplier<Long> {

http://git-wip-us.apache.org/repos/asf/aurora/blob/3cdcd17a/src/test/java/org/apache/aurora/scheduler/TaskVarsTest.java
----------------------------------------------------------------------
diff --git a/src/test/java/org/apache/aurora/scheduler/TaskVarsTest.java b/src/test/java/org/apache/aurora/scheduler/TaskVarsTest.java
index 05cd78f..a4741c3 100644
--- a/src/test/java/org/apache/aurora/scheduler/TaskVarsTest.java
+++ b/src/test/java/org/apache/aurora/scheduler/TaskVarsTest.java
@@ -36,6 +36,7 @@ import org.apache.aurora.scheduler.events.PubsubEvent.TaskStateChange;
 import org.apache.aurora.scheduler.events.PubsubEvent.TasksDeleted;
 import org.apache.aurora.scheduler.filter.SchedulingFilter.Veto;
 import org.apache.aurora.scheduler.filter.SchedulingFilter.VetoGroup;
+import org.apache.aurora.scheduler.filter.SchedulingFilter.VetoType;
 import org.apache.aurora.scheduler.storage.entities.IHostAttributes;
 import org.apache.aurora.scheduler.storage.entities.IJobKey;
 import org.apache.aurora.scheduler.storage.entities.IScheduledTask;
@@ -53,6 +54,7 @@ import static org.apache.aurora.gen.ScheduleStatus.LOST;
 import static org.apache.aurora.gen.ScheduleStatus.PENDING;
 import static org.apache.aurora.gen.ScheduleStatus.RUNNING;
 import static org.apache.aurora.scheduler.TaskVars.VETO_GROUPS_TO_COUNTERS;
+import static org.apache.aurora.scheduler.TaskVars.VETO_TYPE_TO_COUNTERS;
 import static org.apache.aurora.scheduler.TaskVars.jobStatName;
 import static org.apache.aurora.scheduler.TaskVars.rackStatName;
 import static org.easymock.EasyMock.expect;
@@ -68,6 +70,10 @@ public class TaskVarsTest extends EasyMockTest {
   private static final String STATIC_COUNTER = VETO_GROUPS_TO_COUNTERS.get(VetoGroup.STATIC);
   private static final String DYNAMIC_COUNTER = VETO_GROUPS_TO_COUNTERS.get(VetoGroup.DYNAMIC);
   private static final String MIXED_COUNTER = VETO_GROUPS_TO_COUNTERS.get(VetoGroup.MIXED);
+  private static final String INSUFFICIENT_RESOURCES_COUNTER = VETO_TYPE_TO_COUNTERS.get(
+      VetoType.INSUFFICIENT_RESOURCES);
+  private static final String LIMIT_NOT_SATISFIED_COUNTER = VETO_TYPE_TO_COUNTERS.get(
+      VetoType.LIMIT_NOT_SATISFIED);
 
   private StorageTestUtil storageUtil;
   private StatsProvider trackedProvider;
@@ -211,6 +217,7 @@ public class TaskVarsTest extends EasyMockTest {
   public void testStaticVetoGroup() {
     expectStatusCountersInitialized();
     expectStatExport(STATIC_COUNTER);
+    expectStatExport(INSUFFICIENT_RESOURCES_COUNTER);
 
     replayAndBuild();
     schedulerActivated();
@@ -221,24 +228,29 @@ public class TaskVarsTest extends EasyMockTest {
         Veto.insufficientResources("cpu", 500));
 
     assertEquals(1, getValue(STATIC_COUNTER));
+    assertEquals(2, getValue(INSUFFICIENT_RESOURCES_COUNTER));
   }
 
   @Test
   public void testDynamicVetoGroup() {
     expectStatusCountersInitialized();
     expectStatExport(DYNAMIC_COUNTER);
+    expectStatExport(LIMIT_NOT_SATISFIED_COUNTER);
 
     replayAndBuild();
     schedulerActivated();
 
     applyVeto(makeTask(JOB_A, PENDING), Veto.unsatisfiedLimit("constraint"));
     assertEquals(1, getValue(DYNAMIC_COUNTER));
+    assertEquals(1, getValue(LIMIT_NOT_SATISFIED_COUNTER));
   }
 
   @Test
   public void testMixedVetoGroup() {
     expectStatusCountersInitialized();
     expectStatExport(MIXED_COUNTER);
+    expectStatExport(LIMIT_NOT_SATISFIED_COUNTER);
+    expectStatExport(INSUFFICIENT_RESOURCES_COUNTER);
 
     replayAndBuild();
     schedulerActivated();
@@ -248,6 +260,8 @@ public class TaskVarsTest extends EasyMockTest {
         Veto.insufficientResources("ram", 500));
 
     assertEquals(1, getValue(MIXED_COUNTER));
+    assertEquals(1, getValue(LIMIT_NOT_SATISFIED_COUNTER));
+    assertEquals(1, getValue(INSUFFICIENT_RESOURCES_COUNTER));
   }
 
   @Test


Mime
View raw message