aurora-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jco...@apache.org
Subject aurora git commit: AURORA-1828 Expose stats on the number of offers evaluated before a task is assigned
Date Mon, 23 Jan 2017 20:56:32 GMT
Repository: aurora
Updated Branches:
  refs/heads/master dc6f27ed3 -> e36e07720


AURORA-1828 Expose stats on the number of offers evaluated before a task is assigned

Bugs closed: AURORA-1828

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


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

Branch: refs/heads/master
Commit: e36e07720844fac9c1b3d2e97fdb06aaf26a9c3d
Parents: dc6f27e
Author: Mehrdad Nurolahzade <mehrdad@nurolahzade.com>
Authored: Mon Jan 23 14:56:17 2017 -0600
Committer: Joshua Cohen <jcohen@apache.org>
Committed: Mon Jan 23 14:56:17 2017 -0600

----------------------------------------------------------------------
 .../aurora/scheduler/state/TaskAssigner.java    | 16 +++++++++--
 .../scheduler/state/TaskAssignerImplTest.java   | 29 +++++++++++++++++++-
 2 files changed, 41 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/aurora/blob/e36e0772/src/main/java/org/apache/aurora/scheduler/state/TaskAssigner.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/aurora/scheduler/state/TaskAssigner.java b/src/main/java/org/apache/aurora/scheduler/state/TaskAssigner.java
index c1e7b03..a030ceb 100644
--- a/src/main/java/org/apache/aurora/scheduler/state/TaskAssigner.java
+++ b/src/main/java/org/apache/aurora/scheduler/state/TaskAssigner.java
@@ -26,7 +26,7 @@ import com.google.common.collect.ImmutableSet;
 import com.google.common.collect.Iterables;
 
 import org.apache.aurora.common.inject.TimedInterceptor.Timed;
-import org.apache.aurora.common.stats.Stats;
+import org.apache.aurora.common.stats.StatsProvider;
 import org.apache.aurora.scheduler.HostOffer;
 import org.apache.aurora.scheduler.TierInfo;
 import org.apache.aurora.scheduler.TierManager;
@@ -80,8 +80,13 @@ public interface TaskAssigner {
     @VisibleForTesting
     static final Optional<String> LAUNCH_FAILED_MSG =
         Optional.of("Unknown exception attempting to schedule task.");
+    @VisibleForTesting
+    static final String ASSIGNER_LAUNCH_FAILURES = "assigner_launch_failures";
+    @VisibleForTesting
+    static final String ASSIGNER_EVALUATED_OFFERS = "assigner_evaluated_offers";
 
-    private final AtomicLong launchFailures = Stats.exportLong("assigner_launch_failures");
+    private final AtomicLong launchFailures;
+    private final AtomicLong evaluatedOffers;
 
     private final StateManager stateManager;
     private final SchedulingFilter filter;
@@ -95,13 +100,16 @@ public interface TaskAssigner {
         SchedulingFilter filter,
         MesosTaskFactory taskFactory,
         OfferManager offerManager,
-        TierManager tierManager) {
+        TierManager tierManager,
+        StatsProvider statsProvider) {
 
       this.stateManager = requireNonNull(stateManager);
       this.filter = requireNonNull(filter);
       this.taskFactory = requireNonNull(taskFactory);
       this.offerManager = requireNonNull(offerManager);
       this.tierManager = requireNonNull(tierManager);
+      this.launchFailures = statsProvider.makeCounter(ASSIGNER_LAUNCH_FAILURES);
+      this.evaluatedOffers = statsProvider.makeCounter(ASSIGNER_EVALUATED_OFFERS);
     }
 
     @VisibleForTesting
@@ -152,6 +160,8 @@ public interface TaskAssigner {
       String taskId = remainingTasks.next();
 
       for (HostOffer offer : offerManager.getOffers(groupKey)) {
+        evaluatedOffers.incrementAndGet();
+
         Optional<TaskGroupKey> reservedGroup = Optional.fromNullable(
             slaveReservations.get(offer.getOffer().getSlaveId().getValue()));
 

http://git-wip-us.apache.org/repos/asf/aurora/blob/e36e0772/src/test/java/org/apache/aurora/scheduler/state/TaskAssignerImplTest.java
----------------------------------------------------------------------
diff --git a/src/test/java/org/apache/aurora/scheduler/state/TaskAssignerImplTest.java b/src/test/java/org/apache/aurora/scheduler/state/TaskAssignerImplTest.java
index b482be5..f8bb25b 100644
--- a/src/test/java/org/apache/aurora/scheduler/state/TaskAssignerImplTest.java
+++ b/src/test/java/org/apache/aurora/scheduler/state/TaskAssignerImplTest.java
@@ -43,6 +43,7 @@ import org.apache.aurora.scheduler.storage.entities.IAssignedTask;
 import org.apache.aurora.scheduler.storage.entities.IHostAttributes;
 import org.apache.aurora.scheduler.storage.entities.IScheduledTask;
 import org.apache.aurora.scheduler.storage.entities.ITaskConfig;
+import org.apache.aurora.scheduler.testing.FakeStatsProvider;
 import org.apache.mesos.Protos.FrameworkID;
 import org.apache.mesos.Protos.OfferID;
 import org.apache.mesos.Protos.Resource;
@@ -65,6 +66,8 @@ import static org.apache.aurora.scheduler.resources.ResourceManager.bagFromMesos
 import static org.apache.aurora.scheduler.resources.ResourceTestUtil.mesosRange;
 import static org.apache.aurora.scheduler.resources.ResourceTestUtil.offer;
 import static org.apache.aurora.scheduler.resources.ResourceType.PORTS;
+import static org.apache.aurora.scheduler.state.TaskAssigner.TaskAssignerImpl.ASSIGNER_EVALUATED_OFFERS;
+import static org.apache.aurora.scheduler.state.TaskAssigner.TaskAssignerImpl.ASSIGNER_LAUNCH_FAILURES;
 import static org.apache.aurora.scheduler.state.TaskAssigner.TaskAssignerImpl.LAUNCH_FAILED_MSG;
 import static org.apache.aurora.scheduler.storage.Storage.MutableStoreProvider;
 import static org.apache.mesos.Protos.Offer;
@@ -121,6 +124,7 @@ public class TaskAssignerImplTest extends EasyMockTest {
   private OfferManager offerManager;
   private TaskAssignerImpl assigner;
   private TierManager tierManager;
+  private FakeStatsProvider statsProvider;
 
   @Before
   public void setUp() throws Exception {
@@ -130,7 +134,14 @@ public class TaskAssignerImplTest extends EasyMockTest {
     stateManager = createMock(StateManager.class);
     offerManager = createMock(OfferManager.class);
     tierManager = createMock(TierManager.class);
-    assigner = new TaskAssignerImpl(stateManager, filter, taskFactory, offerManager, tierManager);
+    statsProvider = new FakeStatsProvider();
+    assigner = new TaskAssignerImpl(
+        stateManager,
+        filter,
+        taskFactory,
+        offerManager,
+        tierManager,
+        statsProvider);
     resourceRequest = new ResourceRequest(
         TASK.getAssignedTask().getTask(),
         ResourceBag.EMPTY,
@@ -159,6 +170,7 @@ public class TaskAssignerImplTest extends EasyMockTest {
     control.replay();
 
     AttributeAggregate aggregate = empty();
+    assertEquals(0L, statsProvider.getLongValue(ASSIGNER_EVALUATED_OFFERS));
     assertEquals(
         ImmutableSet.of(Tasks.id(TASK)),
         assigner.maybeAssign(
@@ -168,6 +180,7 @@ public class TaskAssignerImplTest extends EasyMockTest {
             ImmutableSet.of(Tasks.id(TASK), "id2", "id3"),
             ImmutableMap.of(SLAVE_ID, GROUP_KEY)));
     assertNotEquals(empty(), aggregate);
+    assertEquals(1L, statsProvider.getLongValue(ASSIGNER_EVALUATED_OFFERS));
   }
 
   @Test
@@ -180,6 +193,7 @@ public class TaskAssignerImplTest extends EasyMockTest {
 
     control.replay();
 
+    assertEquals(0L, statsProvider.getLongValue(ASSIGNER_EVALUATED_OFFERS));
     assertEquals(
         NO_ASSIGNMENT,
         assigner.maybeAssign(
@@ -188,6 +202,7 @@ public class TaskAssignerImplTest extends EasyMockTest {
             TaskGroupKey.from(TASK.getAssignedTask().getTask()),
             ImmutableSet.of(Tasks.id(TASK)),
             NO_RESERVATION));
+    assertEquals(1L, statsProvider.getLongValue(ASSIGNER_EVALUATED_OFFERS));
   }
 
   @Test
@@ -199,6 +214,7 @@ public class TaskAssignerImplTest extends EasyMockTest {
 
     control.replay();
 
+    assertEquals(0L, statsProvider.getLongValue(ASSIGNER_EVALUATED_OFFERS));
     assertEquals(
         NO_ASSIGNMENT,
         assigner.maybeAssign(
@@ -207,6 +223,7 @@ public class TaskAssignerImplTest extends EasyMockTest {
             TaskGroupKey.from(TASK.getAssignedTask().getTask()),
             ImmutableSet.of(Tasks.id(TASK)),
             NO_RESERVATION));
+    assertEquals(1L, statsProvider.getLongValue(ASSIGNER_EVALUATED_OFFERS));
   }
 
   @Test
@@ -229,6 +246,8 @@ public class TaskAssignerImplTest extends EasyMockTest {
 
     control.replay();
 
+    assertEquals(0L, statsProvider.getLongValue(ASSIGNER_LAUNCH_FAILURES));
+    assertEquals(0L, statsProvider.getLongValue(ASSIGNER_EVALUATED_OFFERS));
     // Ensures scheduling loop terminates on the first launch failure.
     assertEquals(
         NO_ASSIGNMENT,
@@ -238,6 +257,8 @@ public class TaskAssignerImplTest extends EasyMockTest {
             TaskGroupKey.from(TASK.getAssignedTask().getTask()),
             ImmutableSet.of(Tasks.id(TASK), "id2", "id3"),
             NO_RESERVATION));
+    assertEquals(1L, statsProvider.getLongValue(ASSIGNER_LAUNCH_FAILURES));
+    assertEquals(1L, statsProvider.getLongValue(ASSIGNER_EVALUATED_OFFERS));
   }
 
   @Test
@@ -247,6 +268,7 @@ public class TaskAssignerImplTest extends EasyMockTest {
 
     control.replay();
 
+    assertEquals(0L, statsProvider.getLongValue(ASSIGNER_EVALUATED_OFFERS));
     assertEquals(
         NO_ASSIGNMENT,
         assigner.maybeAssign(
@@ -256,6 +278,7 @@ public class TaskAssignerImplTest extends EasyMockTest {
             ImmutableSet.of(Tasks.id(TASK)),
             ImmutableMap.of(SLAVE_ID, TaskGroupKey.from(
                 ITaskConfig.build(new TaskConfig().setJob(new JobKey("other", "e", "n")))))));
+    assertEquals(1L, statsProvider.getLongValue(ASSIGNER_EVALUATED_OFFERS));
   }
 
   @Test
@@ -277,6 +300,7 @@ public class TaskAssignerImplTest extends EasyMockTest {
 
     control.replay();
 
+    assertEquals(0L, statsProvider.getLongValue(ASSIGNER_EVALUATED_OFFERS));
     assertEquals(
         ImmutableSet.of(Tasks.id(TASK)),
         assigner.maybeAssign(
@@ -285,6 +309,7 @@ public class TaskAssignerImplTest extends EasyMockTest {
             TaskGroupKey.from(TASK.getAssignedTask().getTask()),
             ImmutableSet.of(Tasks.id(TASK)),
             ImmutableMap.of(SLAVE_ID, GROUP_KEY)));
+    assertEquals(1L, statsProvider.getLongValue(ASSIGNER_EVALUATED_OFFERS));
   }
 
   @Test
@@ -326,6 +351,7 @@ public class TaskAssignerImplTest extends EasyMockTest {
 
     control.replay();
 
+    assertEquals(0L, statsProvider.getLongValue(ASSIGNER_EVALUATED_OFFERS));
     assertEquals(
         ImmutableSet.of(Tasks.id(TASK)),
         assigner.maybeAssign(
@@ -334,6 +360,7 @@ public class TaskAssignerImplTest extends EasyMockTest {
             TaskGroupKey.from(TASK.getAssignedTask().getTask()),
             ImmutableSet.of(Tasks.id(TASK)),
             ImmutableMap.of(SLAVE_ID, GROUP_KEY)));
+    assertEquals(2L, statsProvider.getLongValue(ASSIGNER_EVALUATED_OFFERS));
   }
 
   @Test


Mime
View raw message