aurora-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ma...@apache.org
Subject aurora git commit: Improving scheduling loop performance.
Date Thu, 19 May 2016 21:34:29 GMT
Repository: aurora
Updated Branches:
  refs/heads/master 9ad153f0f -> f25c9c1de


Improving scheduling loop performance.

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


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

Branch: refs/heads/master
Commit: f25c9c1deb6bce225addf3b8ed97bb0a5c2b8300
Parents: 9ad153f
Author: Maxim Khutornenko <maxim@apache.org>
Authored: Thu May 19 14:34:14 2016 -0700
Committer: Maxim Khutornenko <maxim@apache.org>
Committed: Thu May 19 14:34:14 2016 -0700

----------------------------------------------------------------------
 .../aurora/benchmark/StatusUpdateBenchmark.java |  3 +++
 .../org/apache/aurora/scheduler/HostOffer.java  | 18 ++++++++++++++
 .../scheduler/filter/SchedulingFilter.java      | 20 +++++++++++-----
 .../scheduler/filter/SchedulingFilterImpl.java  | 18 +-------------
 .../preemptor/PreemptionVictimFilter.java       |  7 +++++-
 .../scheduler/scheduling/TaskScheduler.java     | 10 +++++++-
 .../aurora/scheduler/state/TaskAssigner.java    |  6 +----
 .../events/NotifyingSchedulingFilterTest.java   |  3 ++-
 .../filter/SchedulingFilterImplTest.java        | 24 ++++++++++++-------
 .../preemptor/PreemptionVictimFilterTest.java   | 16 ++++++-------
 .../scheduling/TaskSchedulerImplTest.java       | 14 +++++++++--
 .../scheduler/state/TaskAssignerImplTest.java   | 25 +++++++++++---------
 12 files changed, 103 insertions(+), 61 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/aurora/blob/f25c9c1d/src/jmh/java/org/apache/aurora/benchmark/StatusUpdateBenchmark.java
----------------------------------------------------------------------
diff --git a/src/jmh/java/org/apache/aurora/benchmark/StatusUpdateBenchmark.java b/src/jmh/java/org/apache/aurora/benchmark/StatusUpdateBenchmark.java
index f6c8e9f..6fd9ee2 100644
--- a/src/jmh/java/org/apache/aurora/benchmark/StatusUpdateBenchmark.java
+++ b/src/jmh/java/org/apache/aurora/benchmark/StatusUpdateBenchmark.java
@@ -46,6 +46,7 @@ import org.apache.aurora.common.stats.StatsProvider;
 import org.apache.aurora.common.util.Clock;
 import org.apache.aurora.common.util.testing.FakeClock;
 import org.apache.aurora.gen.ScheduleStatus;
+import org.apache.aurora.gen.ServerInfo;
 import org.apache.aurora.scheduler.TaskIdGenerator;
 import org.apache.aurora.scheduler.TaskStatusHandler;
 import org.apache.aurora.scheduler.TaskStatusHandlerImpl;
@@ -70,6 +71,7 @@ import org.apache.aurora.scheduler.storage.Storage;
 import org.apache.aurora.scheduler.storage.Storage.MutateWork.NoResult;
 import org.apache.aurora.scheduler.storage.db.DbUtil;
 import org.apache.aurora.scheduler.storage.entities.IScheduledTask;
+import org.apache.aurora.scheduler.storage.entities.IServerInfo;
 import org.apache.mesos.Protos;
 import org.apache.mesos.Scheduler;
 import org.openjdk.jmh.annotations.Benchmark;
@@ -217,6 +219,7 @@ public class StatusUpdateBenchmark {
                 .toInstance(1000);
             bind(TaskStatusHandler.class).to(TaskStatusHandlerImpl.class);
             bind(TaskStatusHandlerImpl.class).in(Singleton.class);
+            bind(IServerInfo.class).toInstance(IServerInfo.build(new ServerInfo("jmh", "")));
           }
         }
     );

http://git-wip-us.apache.org/repos/asf/aurora/blob/f25c9c1d/src/main/java/org/apache/aurora/scheduler/HostOffer.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/aurora/scheduler/HostOffer.java b/src/main/java/org/apache/aurora/scheduler/HostOffer.java
index 53fd68c..ad30bf9 100644
--- a/src/main/java/org/apache/aurora/scheduler/HostOffer.java
+++ b/src/main/java/org/apache/aurora/scheduler/HostOffer.java
@@ -16,11 +16,17 @@ package org.apache.aurora.scheduler;
 import java.util.Objects;
 
 import com.google.common.base.MoreObjects;
+import com.google.common.cache.CacheBuilder;
+import com.google.common.cache.CacheLoader;
+import com.google.common.cache.LoadingCache;
 
+import org.apache.aurora.scheduler.resources.ResourceBag;
 import org.apache.aurora.scheduler.storage.entities.IHostAttributes;
 
 import static java.util.Objects.requireNonNull;
 
+import static org.apache.aurora.scheduler.resources.ResourceManager.bagFromMesosResources;
+import static org.apache.aurora.scheduler.resources.ResourceManager.getOfferResources;
 import static org.apache.mesos.Protos.Offer;
 
 /**
@@ -29,10 +35,18 @@ import static org.apache.mesos.Protos.Offer;
 public class HostOffer {
   private final Offer offer;
   private final IHostAttributes hostAttributes;
+  private final LoadingCache<TierInfo, ResourceBag> resourceBagCache;
 
   public HostOffer(Offer offer, IHostAttributes hostAttributes) {
     this.offer = requireNonNull(offer);
     this.hostAttributes = requireNonNull(hostAttributes);
+    this.resourceBagCache = CacheBuilder.newBuilder().build(
+        new CacheLoader<TierInfo, ResourceBag>() {
+          @Override
+          public ResourceBag load(TierInfo tierInfo) {
+            return bagFromMesosResources(getOfferResources(offer, tierInfo));
+          }
+        });
   }
 
   public Offer getOffer() {
@@ -43,6 +57,10 @@ public class HostOffer {
     return hostAttributes;
   }
 
+  public ResourceBag getResourceBag(TierInfo tierInfo) {
+    return resourceBagCache.getUnchecked(tierInfo);
+  }
+
   @Override
   public boolean equals(Object o) {
     if (!(o instanceof HostOffer)) {

http://git-wip-us.apache.org/repos/asf/aurora/blob/f25c9c1d/src/main/java/org/apache/aurora/scheduler/filter/SchedulingFilter.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/aurora/scheduler/filter/SchedulingFilter.java b/src/main/java/org/apache/aurora/scheduler/filter/SchedulingFilter.java
index c324f59..bb1a960 100644
--- a/src/main/java/org/apache/aurora/scheduler/filter/SchedulingFilter.java
+++ b/src/main/java/org/apache/aurora/scheduler/filter/SchedulingFilter.java
@@ -254,7 +254,7 @@ public interface SchedulingFilter {
       this.attributes = attributes;
     }
 
-    public ResourceBag getResourceSlot() {
+    public ResourceBag getResourceBag() {
       return offer;
     }
 
@@ -269,8 +269,8 @@ public interface SchedulingFilter {
       }
 
       UnusedResource other = (UnusedResource) o;
-      return Objects.equals(getResourceSlot(), other.getResourceSlot())
-          && Objects.equals(getAttributes(), other.getAttributes());
+      return Objects.equals(offer, other.offer)
+          && Objects.equals(attributes, other.attributes);
     }
 
     @Override
@@ -284,10 +284,12 @@ public interface SchedulingFilter {
    */
   class ResourceRequest {
     private final ITaskConfig task;
+    private final ResourceBag request;
     private final AttributeAggregate jobState;
 
-    public ResourceRequest(ITaskConfig task, AttributeAggregate jobState) {
+    public ResourceRequest(ITaskConfig task, ResourceBag request, AttributeAggregate jobState)
{
       this.task = task;
+      this.request = request;
       this.jobState = jobState;
     }
 
@@ -299,6 +301,10 @@ public interface SchedulingFilter {
       return task;
     }
 
+    public ResourceBag getResourceBag() {
+      return request;
+    }
+
     public AttributeAggregate getJobState() {
       return jobState;
     }
@@ -310,12 +316,14 @@ public interface SchedulingFilter {
       }
 
       ResourceRequest other = (ResourceRequest) o;
-      return Objects.equals(task, other.task) && Objects.equals(getJobState(), other.getJobState());
+      return Objects.equals(task, other.task)
+          && Objects.equals(request, other.request)
+          && Objects.equals(jobState, other.jobState);
     }
 
     @Override
     public int hashCode() {
-      return Objects.hash(task, jobState);
+      return Objects.hash(task, request, jobState);
     }
   }
 

http://git-wip-us.apache.org/repos/asf/aurora/blob/f25c9c1d/src/main/java/org/apache/aurora/scheduler/filter/SchedulingFilterImpl.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/aurora/scheduler/filter/SchedulingFilterImpl.java b/src/main/java/org/apache/aurora/scheduler/filter/SchedulingFilterImpl.java
index 1daf296..60097d9 100644
--- a/src/main/java/org/apache/aurora/scheduler/filter/SchedulingFilterImpl.java
+++ b/src/main/java/org/apache/aurora/scheduler/filter/SchedulingFilterImpl.java
@@ -22,22 +22,17 @@ import com.google.common.base.Optional;
 import com.google.common.collect.ImmutableSet;
 import com.google.common.collect.Iterables;
 import com.google.common.collect.Ordering;
-import com.google.inject.Inject;
 
 import org.apache.aurora.common.inject.TimedInterceptor.Timed;
 import org.apache.aurora.gen.MaintenanceMode;
 import org.apache.aurora.gen.TaskConstraint;
 import org.apache.aurora.scheduler.configuration.ConfigurationManager;
-import org.apache.aurora.scheduler.configuration.executor.ExecutorSettings;
 import org.apache.aurora.scheduler.resources.ResourceBag;
-import org.apache.aurora.scheduler.resources.ResourceManager;
 import org.apache.aurora.scheduler.resources.ResourceType;
 import org.apache.aurora.scheduler.storage.entities.IAttribute;
 import org.apache.aurora.scheduler.storage.entities.IConstraint;
 import org.apache.aurora.scheduler.storage.entities.IHostAttributes;
 
-import static java.util.Objects.requireNonNull;
-
 import static org.apache.aurora.gen.MaintenanceMode.DRAINED;
 import static org.apache.aurora.gen.MaintenanceMode.DRAINING;
 import static org.apache.aurora.scheduler.configuration.ConfigurationManager.DEDICATED_ATTRIBUTE;
@@ -92,14 +87,6 @@ public class SchedulingFilterImpl implements SchedulingFilter {
         }
       });
 
-  private final ExecutorSettings executorSettings;
-
-  @Inject
-  @VisibleForTesting
-  public SchedulingFilterImpl(ExecutorSettings executorSettings) {
-    this.executorSettings = requireNonNull(executorSettings);
-  }
-
   private Optional<Veto> getConstraintVeto(
       Iterable<IConstraint> taskConstraints,
       AttributeAggregate jobState,
@@ -159,9 +146,6 @@ public class SchedulingFilterImpl implements SchedulingFilter {
     }
 
     // 4. Resource check (lowest score).
-    return getResourceVetoes(
-        resource.getResourceSlot(),
-        ResourceManager.bagFromResources(request.getTask().getResources())
-            .add(executorSettings.getExecutorOverhead()));
+    return getResourceVetoes(resource.getResourceBag(), request.getResourceBag());
   }
 }

http://git-wip-us.apache.org/repos/asf/aurora/blob/f25c9c1d/src/main/java/org/apache/aurora/scheduler/preemptor/PreemptionVictimFilter.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/aurora/scheduler/preemptor/PreemptionVictimFilter.java
b/src/main/java/org/apache/aurora/scheduler/preemptor/PreemptionVictimFilter.java
index 53b6aee..ee6fe95 100644
--- a/src/main/java/org/apache/aurora/scheduler/preemptor/PreemptionVictimFilter.java
+++ b/src/main/java/org/apache/aurora/scheduler/preemptor/PreemptionVictimFilter.java
@@ -38,6 +38,7 @@ import org.apache.aurora.scheduler.filter.SchedulingFilter.ResourceRequest;
 import org.apache.aurora.scheduler.filter.SchedulingFilter.UnusedResource;
 import org.apache.aurora.scheduler.filter.SchedulingFilter.Veto;
 import org.apache.aurora.scheduler.resources.ResourceBag;
+import org.apache.aurora.scheduler.resources.ResourceManager;
 import org.apache.aurora.scheduler.storage.Storage.StoreProvider;
 import org.apache.aurora.scheduler.storage.entities.IHostAttributes;
 import org.apache.aurora.scheduler.storage.entities.ITaskConfig;
@@ -202,7 +203,11 @@ public interface PreemptionVictimFilter {
         totalResource = totalResource.add(victimToResources.apply(victim));
         Set<Veto> vetoes = schedulingFilter.filter(
             new UnusedResource(totalResource, attributes.get()),
-            new ResourceRequest(pendingTask, jobState));
+            new ResourceRequest(
+                pendingTask,
+                ResourceManager.bagFromResources(pendingTask.getResources())
+                    .add(executorSettings.getExecutorOverhead()),
+                jobState));
 
         if (vetoes.isEmpty()) {
           return Optional.of(ImmutableSet.copyOf(toPreemptTasks));

http://git-wip-us.apache.org/repos/asf/aurora/blob/f25c9c1d/src/main/java/org/apache/aurora/scheduler/scheduling/TaskScheduler.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/aurora/scheduler/scheduling/TaskScheduler.java b/src/main/java/org/apache/aurora/scheduler/scheduling/TaskScheduler.java
index b0c6070..3b84dbc 100644
--- a/src/main/java/org/apache/aurora/scheduler/scheduling/TaskScheduler.java
+++ b/src/main/java/org/apache/aurora/scheduler/scheduling/TaskScheduler.java
@@ -29,6 +29,7 @@ import org.apache.aurora.common.inject.TimedInterceptor.Timed;
 import org.apache.aurora.common.stats.Stats;
 import org.apache.aurora.scheduler.base.Query;
 import org.apache.aurora.scheduler.base.TaskGroupKey;
+import org.apache.aurora.scheduler.configuration.executor.ExecutorSettings;
 import org.apache.aurora.scheduler.events.PubsubEvent.EventSubscriber;
 import org.apache.aurora.scheduler.events.PubsubEvent.TaskStateChange;
 import org.apache.aurora.scheduler.filter.AttributeAggregate;
@@ -51,6 +52,7 @@ import static java.lang.annotation.RetentionPolicy.RUNTIME;
 import static java.util.Objects.requireNonNull;
 
 import static org.apache.aurora.gen.ScheduleStatus.PENDING;
+import static org.apache.aurora.scheduler.resources.ResourceManager.bagFromResources;
 
 /**
  * Enables scheduling and preemption of tasks.
@@ -86,6 +88,7 @@ public interface TaskScheduler extends EventSubscriber {
     private final Storage storage;
     private final TaskAssigner assigner;
     private final Preemptor preemptor;
+    private final ExecutorSettings executorSettings;
     private final BiCache<String, TaskGroupKey> reservations;
 
     private final AtomicLong attemptsFired = Stats.exportLong("schedule_attempts_fired");
@@ -97,11 +100,13 @@ public interface TaskScheduler extends EventSubscriber {
         Storage storage,
         TaskAssigner assigner,
         Preemptor preemptor,
+        ExecutorSettings executorSettings,
         BiCache<String, TaskGroupKey> reservations) {
 
       this.storage = requireNonNull(storage);
       this.assigner = requireNonNull(assigner);
       this.preemptor = requireNonNull(preemptor);
+      this.executorSettings = requireNonNull(executorSettings);
       this.reservations = requireNonNull(reservations);
     }
 
@@ -137,7 +142,10 @@ public interface TaskScheduler extends EventSubscriber {
 
         boolean launched = assigner.maybeAssign(
             store,
-            new ResourceRequest(task, aggregate),
+            new ResourceRequest(
+                task,
+                bagFromResources(task.getResources()).add(executorSettings.getExecutorOverhead()),
+                aggregate),
             TaskGroupKey.from(task),
             taskId,
             reservations.asMap());

http://git-wip-us.apache.org/repos/asf/aurora/blob/f25c9c1d/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 7c8079f..5be3981 100644
--- a/src/main/java/org/apache/aurora/scheduler/state/TaskAssigner.java
+++ b/src/main/java/org/apache/aurora/scheduler/state/TaskAssigner.java
@@ -46,8 +46,6 @@ import static java.util.Objects.requireNonNull;
 
 import static org.apache.aurora.gen.ScheduleStatus.LOST;
 import static org.apache.aurora.gen.ScheduleStatus.PENDING;
-import static org.apache.aurora.scheduler.resources.ResourceManager.bagFromMesosResources;
-import static org.apache.aurora.scheduler.resources.ResourceManager.getOfferResources;
 import static org.apache.aurora.scheduler.storage.Storage.MutableStoreProvider;
 import static org.apache.mesos.Protos.Offer;
 
@@ -152,9 +150,7 @@ public interface TaskAssigner {
 
         TierInfo tierInfo = tierManager.getTier(groupKey.getTask());
         Set<Veto> vetoes = filter.filter(
-            new UnusedResource(
-                bagFromMesosResources(getOfferResources(offer.getOffer(), tierInfo)),
-                offer.getAttributes()),
+            new UnusedResource(offer.getResourceBag(tierInfo), offer.getAttributes()),
             resourceRequest);
 
         if (vetoes.isEmpty()) {

http://git-wip-us.apache.org/repos/asf/aurora/blob/f25c9c1d/src/test/java/org/apache/aurora/scheduler/events/NotifyingSchedulingFilterTest.java
----------------------------------------------------------------------
diff --git a/src/test/java/org/apache/aurora/scheduler/events/NotifyingSchedulingFilterTest.java
b/src/test/java/org/apache/aurora/scheduler/events/NotifyingSchedulingFilterTest.java
index 29d4d64..ece476b 100644
--- a/src/test/java/org/apache/aurora/scheduler/events/NotifyingSchedulingFilterTest.java
+++ b/src/test/java/org/apache/aurora/scheduler/events/NotifyingSchedulingFilterTest.java
@@ -28,6 +28,7 @@ import org.apache.aurora.scheduler.filter.SchedulingFilter;
 import org.apache.aurora.scheduler.filter.SchedulingFilter.ResourceRequest;
 import org.apache.aurora.scheduler.filter.SchedulingFilter.UnusedResource;
 import org.apache.aurora.scheduler.filter.SchedulingFilter.Veto;
+import org.apache.aurora.scheduler.resources.ResourceBag;
 import org.apache.aurora.scheduler.resources.ResourceManager;
 import org.apache.aurora.scheduler.storage.entities.IHostAttributes;
 import org.apache.aurora.scheduler.storage.entities.ITaskConfig;
@@ -48,7 +49,7 @@ public class NotifyingSchedulingFilterTest extends EasyMockTest {
       ResourceManager.bagFromResources(TASK.getResources()),
       IHostAttributes.build(new HostAttributes().setHost("host").setMode(MaintenanceMode.NONE)));
   private static final ResourceRequest REQUEST =
-      new ResourceRequest(TASK, AttributeAggregate.EMPTY);
+      new ResourceRequest(TASK, ResourceBag.EMPTY, AttributeAggregate.EMPTY);
 
   private static final Veto VETO_1 = Veto.insufficientResources("ram", 1);
   private static final Veto VETO_2 = Veto.insufficientResources("ram", 2);

http://git-wip-us.apache.org/repos/asf/aurora/blob/f25c9c1d/src/test/java/org/apache/aurora/scheduler/filter/SchedulingFilterImplTest.java
----------------------------------------------------------------------
diff --git a/src/test/java/org/apache/aurora/scheduler/filter/SchedulingFilterImplTest.java
b/src/test/java/org/apache/aurora/scheduler/filter/SchedulingFilterImplTest.java
index 80126e2..d34e12f 100644
--- a/src/test/java/org/apache/aurora/scheduler/filter/SchedulingFilterImplTest.java
+++ b/src/test/java/org/apache/aurora/scheduler/filter/SchedulingFilterImplTest.java
@@ -39,6 +39,7 @@ import org.apache.aurora.scheduler.filter.SchedulingFilter.VetoGroup;
 import org.apache.aurora.scheduler.filter.SchedulingFilter.VetoType;
 import org.apache.aurora.scheduler.mesos.TaskExecutors;
 import org.apache.aurora.scheduler.resources.ResourceBag;
+import org.apache.aurora.scheduler.resources.ResourceManager;
 import org.apache.aurora.scheduler.resources.ResourceType;
 import org.apache.aurora.scheduler.storage.entities.IAttribute;
 import org.apache.aurora.scheduler.storage.entities.IHostAttributes;
@@ -89,7 +90,7 @@ public class SchedulingFilterImplTest extends EasyMockTest {
 
   @Before
   public void setUp() {
-    defaultFilter = new SchedulingFilterImpl(TaskExecutors.NO_OVERHEAD_EXECUTOR);
+    defaultFilter = new SchedulingFilterImpl();
   }
 
   @Test
@@ -126,22 +127,22 @@ public class SchedulingFilterImplTest extends EasyMockTest {
         none,
         defaultFilter.filter(
             new UnusedResource(DEFAULT_OFFER, hostA),
-            new ResourceRequest(noPortTask, EMPTY)));
+            new ResourceRequest(noPortTask, bag(noPortTask), EMPTY)));
     assertEquals(
         none,
         defaultFilter.filter(
             new UnusedResource(DEFAULT_OFFER, hostA),
-            new ResourceRequest(onePortTask, EMPTY)));
+            new ResourceRequest(onePortTask, bag(onePortTask), EMPTY)));
     assertEquals(
         none,
         defaultFilter.filter(
             new UnusedResource(DEFAULT_OFFER, hostA),
-            new ResourceRequest(twoPortTask, EMPTY)));
+            new ResourceRequest(twoPortTask, bag(twoPortTask), EMPTY)));
     assertEquals(
         ImmutableSet.of(veto(PORTS, 1)),
         defaultFilter.filter(
             new UnusedResource(DEFAULT_OFFER, hostA),
-            new ResourceRequest(threePortTask, EMPTY)));
+            new ResourceRequest(threePortTask, bag(threePortTask), EMPTY)));
   }
 
   @Test
@@ -407,7 +408,7 @@ public class SchedulingFilterImplTest extends EasyMockTest {
         ImmutableSet.of(),
         defaultFilter.filter(
             new UnusedResource(DEFAULT_OFFER, hostA),
-            new ResourceRequest(task, EMPTY)));
+            new ResourceRequest(task, bag(task), EMPTY)));
 
     Constraint jvmNegated = jvmConstraint.deepCopy();
     jvmNegated.getConstraint().getValue().setNegated(true);
@@ -519,7 +520,7 @@ public class SchedulingFilterImplTest extends EasyMockTest {
         expected,
         defaultFilter.filter(
             new UnusedResource(DEFAULT_OFFER, hostAttributes),
-            new ResourceRequest(task, aggregate))
+            new ResourceRequest(task, bag(task), aggregate))
             .isEmpty());
 
     Constraint negated = constraint.deepCopy();
@@ -529,7 +530,7 @@ public class SchedulingFilterImplTest extends EasyMockTest {
         !expected,
         defaultFilter.filter(
             new UnusedResource(DEFAULT_OFFER, hostAttributes),
-            new ResourceRequest(negatedTask, aggregate))
+            new ResourceRequest(negatedTask, bag(negatedTask), aggregate))
             .isEmpty());
     return task;
   }
@@ -560,7 +561,7 @@ public class SchedulingFilterImplTest extends EasyMockTest {
         ImmutableSet.copyOf(vetoes),
         defaultFilter.filter(
             new UnusedResource(DEFAULT_OFFER, hostAttributes),
-            new ResourceRequest(task, jobState)));
+            new ResourceRequest(task, bag(task), jobState)));
   }
 
   private static IHostAttributes hostAttributes(
@@ -631,4 +632,9 @@ public class SchedulingFilterImplTest extends EasyMockTest {
   private ITaskConfig makeTask() {
     return makeTask(DEFAULT_CPUS, DEFAULT_RAM, DEFAULT_DISK);
   }
+
+  private ResourceBag bag(ITaskConfig task) {
+    return ResourceManager.bagFromResources(task.getResources())
+        .add(TaskExecutors.NO_OVERHEAD_EXECUTOR.getExecutorOverhead());
+  }
 }

http://git-wip-us.apache.org/repos/asf/aurora/blob/f25c9c1d/src/test/java/org/apache/aurora/scheduler/preemptor/PreemptionVictimFilterTest.java
----------------------------------------------------------------------
diff --git a/src/test/java/org/apache/aurora/scheduler/preemptor/PreemptionVictimFilterTest.java
b/src/test/java/org/apache/aurora/scheduler/preemptor/PreemptionVictimFilterTest.java
index 88beda7..7eb1714 100644
--- a/src/test/java/org/apache/aurora/scheduler/preemptor/PreemptionVictimFilterTest.java
+++ b/src/test/java/org/apache/aurora/scheduler/preemptor/PreemptionVictimFilterTest.java
@@ -265,7 +265,7 @@ public class PreemptionVictimFilterTest extends EasyMockTest {
   // Ensures a production task can preempt 2 tasks on the same host.
   @Test
   public void testProductionPreemptingManyNonProduction() throws Exception {
-    schedulingFilter = new SchedulingFilterImpl(TaskExecutors.NO_OVERHEAD_EXECUTOR);
+    schedulingFilter = new SchedulingFilterImpl();
     ScheduledTask a1 = makeTask(USER_A, JOB_A, TASK_ID_A + "_a1");
     setResource(a1, CPUS, 1.0);
     setResource(a1, RAM_MB, 512.0);
@@ -293,7 +293,7 @@ public class PreemptionVictimFilterTest extends EasyMockTest {
   // Ensures we select the minimal number of tasks to preempt
   @Test
   public void testMinimalSetPreempted() throws Exception {
-    schedulingFilter = new SchedulingFilterImpl(TaskExecutors.NO_OVERHEAD_EXECUTOR);
+    schedulingFilter = new SchedulingFilterImpl();
     ScheduledTask a1 = makeTask(USER_A, JOB_A, TASK_ID_A + "_a1");
     setResource(a1, CPUS, 4.0);
     setResource(a1, RAM_MB, 4096.0);
@@ -328,7 +328,7 @@ public class PreemptionVictimFilterTest extends EasyMockTest {
   // Ensures a production task *never* preempts a production task from another job.
   @Test
   public void testProductionJobNeverPreemptsProductionJob() throws Exception {
-    schedulingFilter = new SchedulingFilterImpl(TaskExecutors.NO_OVERHEAD_EXECUTOR);
+    schedulingFilter = new SchedulingFilterImpl();
     ScheduledTask p1 = makeProductionTask(USER_A, JOB_A, TASK_ID_A + "_p1");
     p1.getAssignedTask().getTask().setNumCpus(2).setRamMb(1024);
     expectGetTier(p1, PREFERRED_TIER);
@@ -348,7 +348,7 @@ public class PreemptionVictimFilterTest extends EasyMockTest {
   // Ensures that we can preempt if a task + offer can satisfy a pending task.
   @Test
   public void testPreemptWithOfferAndTask() throws Exception {
-    schedulingFilter = new SchedulingFilterImpl(TaskExecutors.NO_OVERHEAD_EXECUTOR);
+    schedulingFilter = new SchedulingFilterImpl();
 
     setUpHost();
 
@@ -373,7 +373,7 @@ public class PreemptionVictimFilterTest extends EasyMockTest {
   // Ensures revocable offer resources are filtered out.
   @Test
   public void testRevocableOfferFiltered() throws Exception {
-    schedulingFilter = new SchedulingFilterImpl(TaskExecutors.NO_OVERHEAD_EXECUTOR);
+    schedulingFilter = new SchedulingFilterImpl();
 
     setUpHost();
 
@@ -398,7 +398,7 @@ public class PreemptionVictimFilterTest extends EasyMockTest {
   // Ensures revocable task CPU is not considered for preemption.
   @Test
   public void testRevocableVictimsFiltered() throws Exception {
-    schedulingFilter = new SchedulingFilterImpl(TaskExecutors.NO_OVERHEAD_EXECUTOR);
+    schedulingFilter = new SchedulingFilterImpl();
 
     setUpHost();
 
@@ -423,7 +423,7 @@ public class PreemptionVictimFilterTest extends EasyMockTest {
   // Ensures revocable victim non-compressible resources are still considered.
   @Test
   public void testRevocableVictimRamUsed() throws Exception {
-    schedulingFilter = new SchedulingFilterImpl(TaskExecutors.NO_OVERHEAD_EXECUTOR);
+    schedulingFilter = new SchedulingFilterImpl();
 
     setUpHost();
 
@@ -450,7 +450,7 @@ public class PreemptionVictimFilterTest extends EasyMockTest {
   // Ensures we can preempt if two tasks and an offer can satisfy a pending task.
   @Test
   public void testPreemptWithOfferAndMultipleTasks() throws Exception {
-    schedulingFilter = new SchedulingFilterImpl(TaskExecutors.NO_OVERHEAD_EXECUTOR);
+    schedulingFilter = new SchedulingFilterImpl();
 
     setUpHost();
 

http://git-wip-us.apache.org/repos/asf/aurora/blob/f25c9c1d/src/test/java/org/apache/aurora/scheduler/scheduling/TaskSchedulerImplTest.java
----------------------------------------------------------------------
diff --git a/src/test/java/org/apache/aurora/scheduler/scheduling/TaskSchedulerImplTest.java
b/src/test/java/org/apache/aurora/scheduler/scheduling/TaskSchedulerImplTest.java
index 4c447b2..fba427b 100644
--- a/src/test/java/org/apache/aurora/scheduler/scheduling/TaskSchedulerImplTest.java
+++ b/src/test/java/org/apache/aurora/scheduler/scheduling/TaskSchedulerImplTest.java
@@ -36,12 +36,15 @@ import org.apache.aurora.scheduler.base.Query;
 import org.apache.aurora.scheduler.base.TaskGroupKey;
 import org.apache.aurora.scheduler.base.TaskTestUtil;
 import org.apache.aurora.scheduler.base.Tasks;
+import org.apache.aurora.scheduler.configuration.executor.ExecutorSettings;
 import org.apache.aurora.scheduler.events.EventSink;
 import org.apache.aurora.scheduler.events.PubsubEvent.TaskStateChange;
 import org.apache.aurora.scheduler.events.PubsubEventModule;
 import org.apache.aurora.scheduler.filter.SchedulingFilter.ResourceRequest;
 import org.apache.aurora.scheduler.preemptor.BiCache;
 import org.apache.aurora.scheduler.preemptor.Preemptor;
+import org.apache.aurora.scheduler.resources.ResourceBag;
+import org.apache.aurora.scheduler.resources.ResourceManager;
 import org.apache.aurora.scheduler.scheduling.TaskScheduler.TaskSchedulerImpl;
 import org.apache.aurora.scheduler.state.PubsubTestUtil;
 import org.apache.aurora.scheduler.state.TaskAssigner;
@@ -61,6 +64,7 @@ import static org.apache.aurora.gen.ScheduleStatus.PENDING;
 import static org.apache.aurora.gen.ScheduleStatus.RUNNING;
 import static org.apache.aurora.gen.ScheduleStatus.THROTTLED;
 import static org.apache.aurora.scheduler.filter.AttributeAggregate.EMPTY;
+import static org.apache.aurora.scheduler.mesos.TestExecutorSettings.THERMOS_EXECUTOR;
 import static org.easymock.EasyMock.eq;
 import static org.easymock.EasyMock.expect;
 import static org.junit.Assert.assertFalse;
@@ -110,6 +114,7 @@ public class TaskSchedulerImplTest extends EasyMockTest {
             bind(Clock.class).toInstance(createMock(Clock.class));
             bind(StatsProvider.class).toInstance(new FakeStatsProvider());
             bind(Storage.class).toInstance(storageImpl);
+            bind(ExecutorSettings.class).toInstance(THERMOS_EXECUTOR);
             PubsubEventModule.bindSubscriber(binder(), TaskScheduler.class);
           }
         });
@@ -121,13 +126,18 @@ public class TaskSchedulerImplTest extends EasyMockTest {
         ImmutableSet.of(task));
   }
 
+  private ResourceBag bag(IScheduledTask task) {
+    return ResourceManager.bagFromResources(task.getAssignedTask().getTask().getResources())
+        .add(THERMOS_EXECUTOR.getExecutorOverhead());
+  }
+
   private IExpectationSetters<Boolean> expectAssigned(
       IScheduledTask task,
       Map<String, TaskGroupKey> reservationMap) {
 
     return expect(assigner.maybeAssign(
         storageUtil.mutableStoreProvider,
-        new ResourceRequest(task.getAssignedTask().getTask(), EMPTY),
+        new ResourceRequest(task.getAssignedTask().getTask(), bag(task), EMPTY),
         TaskGroupKey.from(task.getAssignedTask().getTask()),
         Tasks.id(task),
         reservationMap));
@@ -261,7 +271,7 @@ public class TaskSchedulerImplTest extends EasyMockTest {
     expectAsMap(NO_RESERVATION);
     expect(assigner.maybeAssign(
         EasyMock.anyObject(),
-        eq(new ResourceRequest(taskA.getAssignedTask().getTask(), EMPTY)),
+        eq(new ResourceRequest(taskA.getAssignedTask().getTask(), bag(taskA), EMPTY)),
         eq(TaskGroupKey.from(taskA.getAssignedTask().getTask())),
         eq(Tasks.id(taskA)),
         eq(NO_RESERVATION))).andReturn(true);

http://git-wip-us.apache.org/repos/asf/aurora/blob/f25c9c1d/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 50d942e..b4d27f6 100644
--- a/src/test/java/org/apache/aurora/scheduler/state/TaskAssignerImplTest.java
+++ b/src/test/java/org/apache/aurora/scheduler/state/TaskAssignerImplTest.java
@@ -34,6 +34,7 @@ import org.apache.aurora.scheduler.filter.SchedulingFilter.UnusedResource;
 import org.apache.aurora.scheduler.filter.SchedulingFilter.Veto;
 import org.apache.aurora.scheduler.mesos.MesosTaskFactory;
 import org.apache.aurora.scheduler.offers.OfferManager;
+import org.apache.aurora.scheduler.resources.ResourceBag;
 import org.apache.aurora.scheduler.state.TaskAssigner.TaskAssignerImpl;
 import org.apache.aurora.scheduler.storage.entities.IAssignedTask;
 import org.apache.aurora.scheduler.storage.entities.IHostAttributes;
@@ -90,8 +91,10 @@ public class TaskAssignerImplTest extends EasyMockTest {
   private static final UnusedResource UNUSED = new UnusedResource(
       bagFromMesosResources(MESOS_OFFER.getResourcesList()),
       OFFER.getAttributes());
-  private static final ResourceRequest RESOURCE_REQUEST =
-      new ResourceRequest(TASK.getAssignedTask().getTask(), EMPTY);
+  private static final ResourceRequest RESOURCE_REQUEST = new ResourceRequest(
+      TASK.getAssignedTask().getTask(),
+      ResourceBag.EMPTY,
+      EMPTY);
 
   private MutableStoreProvider storeProvider;
   private StateManager stateManager;
@@ -126,7 +129,7 @@ public class TaskAssignerImplTest extends EasyMockTest {
 
     assertTrue(assigner.maybeAssign(
         storeProvider,
-        new ResourceRequest(TASK.getAssignedTask().getTask(), EMPTY),
+        new ResourceRequest(TASK.getAssignedTask().getTask(), ResourceBag.EMPTY, EMPTY),
         TaskGroupKey.from(TASK.getAssignedTask().getTask()),
         Tasks.id(TASK),
         ImmutableMap.of(SLAVE_ID, GROUP_KEY)));
@@ -144,7 +147,7 @@ public class TaskAssignerImplTest extends EasyMockTest {
 
     assertFalse(assigner.maybeAssign(
         storeProvider,
-        new ResourceRequest(TASK.getAssignedTask().getTask(), EMPTY),
+        RESOURCE_REQUEST,
         TaskGroupKey.from(TASK.getAssignedTask().getTask()),
         Tasks.id(TASK),
         NO_RESERVATION));
@@ -161,7 +164,7 @@ public class TaskAssignerImplTest extends EasyMockTest {
 
     assertFalse(assigner.maybeAssign(
         storeProvider,
-        new ResourceRequest(TASK.getAssignedTask().getTask(), EMPTY),
+        RESOURCE_REQUEST,
         TaskGroupKey.from(TASK.getAssignedTask().getTask()),
         Tasks.id(TASK),
         NO_RESERVATION));
@@ -189,7 +192,7 @@ public class TaskAssignerImplTest extends EasyMockTest {
 
     assertFalse(assigner.maybeAssign(
         storeProvider,
-        new ResourceRequest(TASK.getAssignedTask().getTask(), EMPTY),
+        RESOURCE_REQUEST,
         TaskGroupKey.from(TASK.getAssignedTask().getTask()),
         Tasks.id(TASK),
         NO_RESERVATION));
@@ -203,7 +206,7 @@ public class TaskAssignerImplTest extends EasyMockTest {
 
     assertFalse(assigner.maybeAssign(
         storeProvider,
-        new ResourceRequest(TASK.getAssignedTask().getTask(), EMPTY),
+        RESOURCE_REQUEST,
         TaskGroupKey.from(TASK.getAssignedTask().getTask()),
         Tasks.id(TASK),
         ImmutableMap.of(SLAVE_ID, TaskGroupKey.from(
@@ -241,7 +244,7 @@ public class TaskAssignerImplTest extends EasyMockTest {
 
     assertTrue(assigner.maybeAssign(
         storeProvider,
-        new ResourceRequest(TASK.getAssignedTask().getTask(), EMPTY),
+        RESOURCE_REQUEST,
         TaskGroupKey.from(TASK.getAssignedTask().getTask()),
         Tasks.id(TASK),
         ImmutableMap.of(SLAVE_ID, GROUP_KEY)));
@@ -270,13 +273,13 @@ public class TaskAssignerImplTest extends EasyMockTest {
         new UnusedResource(
             bagFromMesosResources(mismatched.getOffer().getResourcesList()),
             mismatched.getAttributes()),
-        new ResourceRequest(TASK.getAssignedTask().getTask(), EMPTY)))
+        RESOURCE_REQUEST))
         .andReturn(ImmutableSet.of(Veto.constraintMismatch("constraint mismatch")));
     offerManager.banOffer(mismatched.getOffer().getId(), GROUP_KEY);
     expect(filter.filter(
         new UnusedResource(
             bagFromMesosResources(MESOS_OFFER.getResourcesList()), OFFER.getAttributes()),
-        new ResourceRequest(TASK.getAssignedTask().getTask(), EMPTY)))
+        RESOURCE_REQUEST))
         .andReturn(ImmutableSet.of());
 
     expectAssignTask(MESOS_OFFER);
@@ -288,7 +291,7 @@ public class TaskAssignerImplTest extends EasyMockTest {
 
     assertTrue(assigner.maybeAssign(
         storeProvider,
-        new ResourceRequest(TASK.getAssignedTask().getTask(), EMPTY),
+        RESOURCE_REQUEST,
         TaskGroupKey.from(TASK.getAssignedTask().getTask()),
         Tasks.id(TASK),
         ImmutableMap.of(SLAVE_ID, GROUP_KEY)));


Mime
View raw message