aurora-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From wfar...@apache.org
Subject aurora git commit: Use a pair of fields for caching offer resources rather than a Cache
Date Wed, 08 Nov 2017 02:45:06 GMT
Repository: aurora
Updated Branches:
  refs/heads/master b4825a37c -> 0e3e0dd71


Use a pair of fields for caching offer resources rather than a Cache

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


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

Branch: refs/heads/master
Commit: 0e3e0dd713d25ff5648a0542a278c66eae53bbf3
Parents: b4825a3
Author: Bill Farner <wfarner@apache.org>
Authored: Tue Nov 7 18:45:05 2017 -0800
Committer: Bill Farner <wfarner@apache.org>
Committed: Tue Nov 7 18:45:05 2017 -0800

----------------------------------------------------------------------
 .../aurora/benchmark/SchedulingBenchmarks.java  |  2 +
 .../org/apache/aurora/scheduler/HostOffer.java  | 23 +++---
 .../scheduler/mesos/MesosTaskFactory.java       | 17 ++--
 .../scheduler/resources/AcceptedOffer.java      |  7 +-
 .../scheduler/resources/ResourceManager.java    | 15 ++--
 .../aurora/scheduler/state/TaskAssigner.java    | 23 +++---
 .../mesos/MesosTaskFactoryImplTest.java         | 83 +++++++-------------
 .../scheduler/resources/AcceptedOfferTest.java  |  9 +--
 .../resources/ResourceManagerTest.java          |  5 +-
 .../state/FirstFitTaskAssignerTest.java         | 12 +--
 10 files changed, 80 insertions(+), 116 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/aurora/blob/0e3e0dd7/src/jmh/java/org/apache/aurora/benchmark/SchedulingBenchmarks.java
----------------------------------------------------------------------
diff --git a/src/jmh/java/org/apache/aurora/benchmark/SchedulingBenchmarks.java b/src/jmh/java/org/apache/aurora/benchmark/SchedulingBenchmarks.java
index 456e780..292bb29 100644
--- a/src/jmh/java/org/apache/aurora/benchmark/SchedulingBenchmarks.java
+++ b/src/jmh/java/org/apache/aurora/benchmark/SchedulingBenchmarks.java
@@ -49,6 +49,7 @@ import org.apache.aurora.scheduler.async.AsyncModule;
 import org.apache.aurora.scheduler.async.DelayExecutor;
 import org.apache.aurora.scheduler.base.TaskTestUtil;
 import org.apache.aurora.scheduler.config.CliOptions;
+import org.apache.aurora.scheduler.config.CommandLine;
 import org.apache.aurora.scheduler.config.types.TimeAmount;
 import org.apache.aurora.scheduler.configuration.executor.ExecutorSettings;
 import org.apache.aurora.scheduler.events.EventSink;
@@ -117,6 +118,7 @@ public class SchedulingBenchmarks {
      */
     @Setup(Level.Trial)
     public void setUpBenchmark() {
+      CommandLine.initializeForTest();
       storage = MemStorageModule.newEmptyStorage();
       eventBus = new EventBus();
       final FakeClock clock = new FakeClock();

http://git-wip-us.apache.org/repos/asf/aurora/blob/0e3e0dd7/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 acc637a..d7d9773 100644
--- a/src/main/java/org/apache/aurora/scheduler/HostOffer.java
+++ b/src/main/java/org/apache/aurora/scheduler/HostOffer.java
@@ -15,12 +15,11 @@ package org.apache.aurora.scheduler;
 
 import java.time.Instant;
 import java.util.Objects;
+import java.util.function.Supplier;
 
 import com.google.common.base.MoreObjects;
 import com.google.common.base.Optional;
-import com.google.common.cache.CacheBuilder;
-import com.google.common.cache.CacheLoader;
-import com.google.common.cache.LoadingCache;
+import com.google.common.base.Suppliers;
 
 import org.apache.aurora.scheduler.base.Conversions;
 import org.apache.aurora.scheduler.resources.ResourceBag;
@@ -39,7 +38,8 @@ import static org.apache.mesos.v1.Protos.Offer;
 public class HostOffer {
   private final Offer offer;
   private final IHostAttributes hostAttributes;
-  private final LoadingCache<TierInfo, ResourceBag> resourceBagCache;
+  private final Supplier<ResourceBag> revocableResources;
+  private final Supplier<ResourceBag> nonRevocableResources;
 
   // Offers lacking CPU or mem are flagged so that they may be efficiently ignored during
   // scheduling.  However, they are retained for other purposes such as preemption and cluster
@@ -52,13 +52,10 @@ public class HostOffer {
     this.offer = requireNonNull(offer);
     this.hostAttributes = requireNonNull(hostAttributes);
     this.nonZeroCpuAndMem = offerHasCpuAndMem(offer);
-    this.resourceBagCache = CacheBuilder.newBuilder().build(
-        new CacheLoader<TierInfo, ResourceBag>() {
-          @Override
-          public ResourceBag load(TierInfo tierInfo) {
-            return bagFromMesosResources(getOfferResources(offer, tierInfo));
-          }
-        });
+    this.revocableResources =
+        Suppliers.memoize(() -> bagFromMesosResources(getOfferResources(offer, true)));
+    this.nonRevocableResources =
+        Suppliers.memoize(() -> bagFromMesosResources(getOfferResources(offer, false)));
   }
 
   private static boolean offerHasCpuAndMem(Offer offer) {
@@ -79,8 +76,8 @@ public class HostOffer {
     return nonZeroCpuAndMem;
   }
 
-  public ResourceBag getResourceBag(TierInfo tierInfo) {
-    return resourceBagCache.getUnchecked(tierInfo);
+  public ResourceBag getResourceBag(boolean revocable) {
+    return revocable ? revocableResources.get() : nonRevocableResources.get();
   }
 
   public Optional<Instant> getUnavailabilityStart() {

http://git-wip-us.apache.org/repos/asf/aurora/blob/0e3e0dd7/src/main/java/org/apache/aurora/scheduler/mesos/MesosTaskFactory.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/aurora/scheduler/mesos/MesosTaskFactory.java b/src/main/java/org/apache/aurora/scheduler/mesos/MesosTaskFactory.java
index 34ed820..727be58 100644
--- a/src/main/java/org/apache/aurora/scheduler/mesos/MesosTaskFactory.java
+++ b/src/main/java/org/apache/aurora/scheduler/mesos/MesosTaskFactory.java
@@ -27,7 +27,6 @@ import com.google.protobuf.ByteString;
 
 import org.apache.aurora.Protobufs;
 import org.apache.aurora.codec.ThriftBinaryCodec;
-import org.apache.aurora.scheduler.TierManager;
 import org.apache.aurora.scheduler.base.JobKeys;
 import org.apache.aurora.scheduler.base.SchedulerException;
 import org.apache.aurora.scheduler.base.Tasks;
@@ -77,7 +76,7 @@ public interface MesosTaskFactory {
    * @return A new task.
    * @throws SchedulerException If the task could not be encoded.
    */
-  TaskInfo createFrom(IAssignedTask task, Offer offer) throws SchedulerException;
+  TaskInfo createFrom(IAssignedTask task, Offer offer, boolean revocable) throws SchedulerException;
 
   // TODO(wfarner): Move this class to its own file to reduce visibility to package private.
   class MesosTaskFactoryImpl implements MesosTaskFactory {
@@ -100,17 +99,11 @@ public interface MesosTaskFactory {
     static final String TIER_LABEL = AURORA_LABEL_PREFIX + ".tier";
 
     private final ExecutorSettings executorSettings;
-    private final TierManager tierManager;
     private final IServerInfo serverInfo;
 
     @Inject
-    MesosTaskFactoryImpl(
-        ExecutorSettings executorSettings,
-        TierManager tierManager,
-        IServerInfo serverInfo) {
-
+    MesosTaskFactoryImpl(ExecutorSettings executorSettings, IServerInfo serverInfo) {
       this.executorSettings = requireNonNull(executorSettings);
-      this.tierManager = requireNonNull(tierManager);
       this.serverInfo = requireNonNull(serverInfo);
     }
 
@@ -151,7 +144,9 @@ public interface MesosTaskFactory {
     }
 
     @Override
-    public TaskInfo createFrom(IAssignedTask task, Offer offer) throws SchedulerException
{
+    public TaskInfo createFrom(IAssignedTask task, Offer offer, boolean revocable)
+        throws SchedulerException {
+
       requireNonNull(task);
       requireNonNull(offer);
 
@@ -171,7 +166,7 @@ public interface MesosTaskFactory {
             offer,
             task,
             executorOverhead,
-            tierManager.getTier(task.getTask()));
+            revocable);
       } catch (ResourceManager.InsufficientResourcesException e) {
         throw new SchedulerException(e);
       }

http://git-wip-us.apache.org/repos/asf/aurora/blob/0e3e0dd7/src/main/java/org/apache/aurora/scheduler/resources/AcceptedOffer.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/aurora/scheduler/resources/AcceptedOffer.java b/src/main/java/org/apache/aurora/scheduler/resources/AcceptedOffer.java
index 291d5c9..e8ea3f2 100644
--- a/src/main/java/org/apache/aurora/scheduler/resources/AcceptedOffer.java
+++ b/src/main/java/org/apache/aurora/scheduler/resources/AcceptedOffer.java
@@ -20,7 +20,6 @@ import java.util.stream.StreamSupport;
 import com.google.common.annotations.VisibleForTesting;
 import com.google.common.collect.ImmutableList;
 
-import org.apache.aurora.scheduler.TierInfo;
 import org.apache.aurora.scheduler.storage.entities.IAssignedTask;
 import org.apache.mesos.v1.Protos.Offer;
 import org.apache.mesos.v1.Protos.Resource;
@@ -63,7 +62,7 @@ public final class AcceptedOffer {
       Offer offer,
       IAssignedTask task,
       ResourceBag executorOverhead,
-      TierInfo tierInfo) throws ResourceManager.InsufficientResourcesException {
+      boolean revocable) throws ResourceManager.InsufficientResourcesException {
 
     ImmutableList.Builder<Resource> taskResources = ImmutableList.builder();
     ImmutableList.Builder<Resource> executorResources = ImmutableList.builder();
@@ -73,13 +72,13 @@ public final class AcceptedOffer {
         .forEach(entry -> {
           ResourceType type = entry.getKey();
           Iterable<Resource.Builder> offerResources = StreamSupport
-              .stream(getOfferResources(offer, tierInfo, entry.getKey()).spliterator(), false)
+              .stream(getOfferResources(offer, revocable, entry.getKey()).spliterator(),
false)
               // Note the reverse order of args in .compare(): we want RESERVED resources
first.
               .sorted((l, r) -> Boolean.compare(RESERVED.test(r), RESERVED.test(l)))
               .map(Resource::toBuilder)
               .collect(toList());
 
-          boolean isRevocable = type.isMesosRevocable() && tierInfo.isRevocable();
+          boolean isRevocable = type.isMesosRevocable() && revocable;
 
           taskResources.addAll(type.getMesosResourceConverter().toMesosResource(
               offerResources,

http://git-wip-us.apache.org/repos/asf/aurora/blob/0e3e0dd7/src/main/java/org/apache/aurora/scheduler/resources/ResourceManager.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/aurora/scheduler/resources/ResourceManager.java b/src/main/java/org/apache/aurora/scheduler/resources/ResourceManager.java
index 9aa263a..f9dee22 100644
--- a/src/main/java/org/apache/aurora/scheduler/resources/ResourceManager.java
+++ b/src/main/java/org/apache/aurora/scheduler/resources/ResourceManager.java
@@ -26,7 +26,6 @@ import com.google.common.base.Predicates;
 import com.google.common.collect.Iterables;
 
 import org.apache.aurora.gen.ResourceAggregate;
-import org.apache.aurora.scheduler.TierInfo;
 import org.apache.aurora.scheduler.storage.entities.IAssignedTask;
 import org.apache.aurora.scheduler.storage.entities.IResource;
 import org.apache.aurora.scheduler.storage.entities.IResourceAggregate;
@@ -118,11 +117,12 @@ public final class ResourceManager {
    * Gets offer resources filtered by the provided {@code tierInfo} instance.
    *
    * @param offer Offer to get resources from.
-   * @param tierInfo Tier info.
+   * @param revocable if {@code true} return only revocable resources,
+   *                  if {@code false} return non-revocable.
    * @return Offer resources filtered by {@code tierInfo}.
    */
-  public static Iterable<Resource> getOfferResources(Offer offer, TierInfo tierInfo)
{
-    return tierInfo.isRevocable()
+  public static Iterable<Resource> getOfferResources(Offer offer, boolean revocable)
{
+    return revocable
         ? getRevocableOfferResources(offer)
         : getNonRevocableOfferResources(offer);
   }
@@ -131,16 +131,17 @@ public final class ResourceManager {
    * Gets offer resoruces filtered by the {@code tierInfo} and {@code type}.
    *
    * @param offer Offer to get resources from.
-   * @param tierInfo Tier info.
+   * @param revocable if {@code true} return only revocable resources,
+   *                  if {@code false} return non-revocable.
    * @param type Resource type.
    * @return Offer resources filtered by {@code tierInfo} and {@code type}.
    */
   public static Iterable<Resource> getOfferResources(
       Offer offer,
-      TierInfo tierInfo,
+      boolean revocable,
       ResourceType type) {
 
-    return Iterables.filter(getOfferResources(offer, tierInfo), r -> fromResource(r).equals(type));
+    return Iterables.filter(getOfferResources(offer, revocable), r -> fromResource(r).equals(type));
   }
 
   /**

http://git-wip-us.apache.org/repos/asf/aurora/blob/0e3e0dd7/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 549fd29..cdd0d15 100644
--- a/src/main/java/org/apache/aurora/scheduler/state/TaskAssigner.java
+++ b/src/main/java/org/apache/aurora/scheduler/state/TaskAssigner.java
@@ -28,7 +28,6 @@ import com.google.common.collect.Iterables;
 import org.apache.aurora.common.inject.TimedInterceptor.Timed;
 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;
 import org.apache.aurora.scheduler.base.InstanceKeys;
 import org.apache.aurora.scheduler.base.TaskGroupKey;
@@ -133,7 +132,8 @@ public interface TaskAssigner {
     private TaskInfo assign(
         MutableStoreProvider storeProvider,
         Offer offer,
-        String taskId) {
+        String taskId,
+        boolean revocable) {
 
       String host = offer.getHostname();
       IAssignedTask assigned = stateManager.assignTask(
@@ -145,12 +145,12 @@ public interface TaskAssigner {
       LOG.info(
           "Offer on agent {} (id {}) is being assigned task for {}.",
           host, offer.getAgentId().getValue(), taskId);
-      return taskFactory.createFrom(assigned, offer);
+      return taskFactory.createFrom(assigned, offer, revocable);
     }
 
     private boolean evaluateOffer(
         MutableStoreProvider storeProvider,
-        TierInfo tierInfo,
+        boolean revocable,
         ResourceRequest resourceRequest,
         TaskGroupKey groupKey,
         IAssignedTask task,
@@ -160,7 +160,7 @@ public interface TaskAssigner {
       String taskId = task.getTaskId();
       Set<Veto> vetoes = filter.filter(
           new UnusedResource(
-              offer.getResourceBag(tierInfo),
+              offer.getResourceBag(revocable),
               offer.getAttributes(),
               offer.getUnavailabilityStart()),
           resourceRequest);
@@ -169,7 +169,8 @@ public interface TaskAssigner {
         TaskInfo taskInfo = assign(
             storeProvider,
             offer.getOffer(),
-            taskId);
+            taskId,
+            revocable);
         resourceRequest.getJobState().updateAttributeAggregate(offer.getAttributes());
 
         try {
@@ -206,7 +207,7 @@ public interface TaskAssigner {
     private Iterable<IAssignedTask> maybeAssignReserved(
         Iterable<IAssignedTask> tasks,
         MutableStoreProvider storeProvider,
-        TierInfo tierInfo,
+        boolean revocable,
         ResourceRequest resourceRequest,
         TaskGroupKey groupKey,
         ImmutableSet.Builder<String> assignmentResult) {
@@ -233,7 +234,7 @@ public interface TaskAssigner {
               // Scheduler hasn't been updated by Mesos yet...
               if (evaluateOffer(
                   storeProvider,
-                  tierInfo,
+                  revocable,
                   resourceRequest,
                   groupKey,
                   task,
@@ -276,13 +277,13 @@ public interface TaskAssigner {
         return ImmutableSet.of();
       }
 
-      TierInfo tierInfo = tierManager.getTier(groupKey.getTask());
+      boolean revocable = tierManager.getTier(groupKey.getTask()).isRevocable();
       ImmutableSet.Builder<String> assignmentResult = ImmutableSet.builder();
 
       Iterable<IAssignedTask> nonReservedTasks = maybeAssignReserved(
           tasks,
           storeProvider,
-          tierInfo,
+          revocable,
           resourceRequest,
           groupKey,
           assignmentResult);
@@ -317,7 +318,7 @@ public interface TaskAssigner {
           evaluatedOffers.incrementAndGet();
           try {
             boolean offerUsed = evaluateOffer(
-                storeProvider, tierInfo, resourceRequest, groupKey, task, offer, assignmentResult);
+                storeProvider, revocable, resourceRequest, groupKey, task, offer, assignmentResult);
             if (offerUsed) {
               if (remainingTasks.hasNext()) {
                 task = remainingTasks.next();

http://git-wip-us.apache.org/repos/asf/aurora/blob/0e3e0dd7/src/test/java/org/apache/aurora/scheduler/mesos/MesosTaskFactoryImplTest.java
----------------------------------------------------------------------
diff --git a/src/test/java/org/apache/aurora/scheduler/mesos/MesosTaskFactoryImplTest.java
b/src/test/java/org/apache/aurora/scheduler/mesos/MesosTaskFactoryImplTest.java
index d91b540..c27a662 100644
--- a/src/test/java/org/apache/aurora/scheduler/mesos/MesosTaskFactoryImplTest.java
+++ b/src/test/java/org/apache/aurora/scheduler/mesos/MesosTaskFactoryImplTest.java
@@ -33,7 +33,6 @@ import org.apache.aurora.gen.Image;
 import org.apache.aurora.gen.MesosContainer;
 import org.apache.aurora.gen.ServerInfo;
 import org.apache.aurora.gen.TaskConfig;
-import org.apache.aurora.scheduler.TierManager;
 import org.apache.aurora.scheduler.base.TaskTestUtil;
 import org.apache.aurora.scheduler.configuration.executor.ExecutorConfig;
 import org.apache.aurora.scheduler.configuration.executor.ExecutorSettings;
@@ -62,10 +61,7 @@ import org.junit.Before;
 import org.junit.Test;
 
 import static org.apache.aurora.gen.apiConstants.TASK_FILESYSTEM_MOUNT_POINT;
-import static org.apache.aurora.scheduler.base.TaskTestUtil.DEV_TIER;
-import static org.apache.aurora.scheduler.base.TaskTestUtil.PREFERRED_TIER;
 import static org.apache.aurora.scheduler.base.TaskTestUtil.PROD_TIER_NAME;
-import static org.apache.aurora.scheduler.base.TaskTestUtil.REVOCABLE_TIER;
 import static org.apache.aurora.scheduler.mesos.MesosTaskFactory.MesosTaskFactoryImpl.DEFAULT_PORT_PROTOCOL;
 import static org.apache.aurora.scheduler.mesos.MesosTaskFactory.MesosTaskFactoryImpl.METADATA_LABEL_PREFIX;
 import static org.apache.aurora.scheduler.mesos.MesosTaskFactory.MesosTaskFactoryImpl.SOURCE_LABEL;
@@ -82,7 +78,6 @@ import static org.apache.aurora.scheduler.resources.ResourceTestUtil.mesosRange;
 import static org.apache.aurora.scheduler.resources.ResourceTestUtil.mesosScalarFromBag;
 import static org.apache.aurora.scheduler.resources.ResourceTestUtil.resetPorts;
 import static org.apache.aurora.scheduler.resources.ResourceType.PORTS;
-import static org.easymock.EasyMock.expect;
 import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertFalse;
 import static org.junit.Assert.assertTrue;
@@ -147,14 +142,12 @@ public class MesosTaskFactoryImplTest extends EasyMockTest {
 
   private MesosTaskFactory taskFactory;
   private ExecutorSettings config;
-  private TierManager tierManager;
 
   private static final ExecutorInfo DEFAULT_EXECUTOR = THERMOS_CONFIG.getExecutor();
 
   @Before
   public void setUp() {
     config = THERMOS_EXECUTOR;
-    tierManager = createMock(TierManager.class);
 
     ResourceType.initializeEmptyCliArgsForTest();
   }
@@ -205,12 +198,11 @@ public class MesosTaskFactoryImplTest extends EasyMockTest {
 
   @Test
   public void testExecutorInfoUnchanged() {
-    expect(tierManager.getTier(TASK_CONFIG)).andReturn(DEV_TIER);
-    taskFactory = new MesosTaskFactoryImpl(config, tierManager, SERVER_INFO);
+    taskFactory = new MesosTaskFactoryImpl(config, SERVER_INFO);
 
     control.replay();
 
-    TaskInfo task = taskFactory.createFrom(TASK, OFFER_THERMOS_EXECUTOR);
+    TaskInfo task = taskFactory.createFrom(TASK, OFFER_THERMOS_EXECUTOR, false);
 
     assertEquals(populateDynamicFields(DEFAULT_EXECUTOR, TASK), makeComparable(task.getExecutor()));
     checkTaskResources(TASK.getTask(), task);
@@ -219,8 +211,7 @@ public class MesosTaskFactoryImplTest extends EasyMockTest {
 
   @Test
   public void testTaskInfoRevocable() {
-    expect(tierManager.getTier(TASK_CONFIG)).andReturn(REVOCABLE_TIER);
-    taskFactory = new MesosTaskFactoryImpl(config, tierManager, SERVER_INFO);
+    taskFactory = new MesosTaskFactoryImpl(config, SERVER_INFO);
 
     List<Resource> revocable = OFFER_THERMOS_EXECUTOR.getResourcesList().stream()
         .map(r -> {
@@ -239,7 +230,7 @@ public class MesosTaskFactoryImplTest extends EasyMockTest {
 
     control.replay();
 
-    TaskInfo task = taskFactory.createFrom(TASK, withRevocable);
+    TaskInfo task = taskFactory.createFrom(TASK, withRevocable, true);
     checkTaskResources(TASK.getTask(), task);
     assertTrue(task.getResourcesList().stream().anyMatch(Resource::hasRevocable));
     checkDiscoveryInfoUnset(task);
@@ -251,13 +242,12 @@ public class MesosTaskFactoryImplTest extends EasyMockTest {
     builder.unsetAssignedPorts();
     builder.setTask(
         resetPorts(ITaskConfig.build(builder.getTask()), ImmutableSet.of()).newBuilder());
-    IAssignedTask assignedTask = IAssignedTask.build(builder);
-    expect(tierManager.getTier(assignedTask.getTask())).andReturn(DEV_TIER);
-    taskFactory = new MesosTaskFactoryImpl(config, tierManager, SERVER_INFO);
+    taskFactory = new MesosTaskFactoryImpl(config, SERVER_INFO);
 
     control.replay();
 
-    TaskInfo task = taskFactory.createFrom(IAssignedTask.build(builder), OFFER_THERMOS_EXECUTOR);
+    TaskInfo task =
+        taskFactory.createFrom(IAssignedTask.build(builder), OFFER_THERMOS_EXECUTOR, false);
     checkTaskResources(ITaskConfig.build(builder.getTask()), task);
     checkDiscoveryInfoUnset(task);
   }
@@ -267,12 +257,11 @@ public class MesosTaskFactoryImplTest extends EasyMockTest {
     // Here the ram required for the executor is greater than the sum of task resources
     // + executor overhead. We need to ensure we allocate a non-zero amount of ram in this
case.
     config = NO_OVERHEAD_EXECUTOR;
-    expect(tierManager.getTier(TASK_CONFIG)).andReturn(DEV_TIER);
-    taskFactory = new MesosTaskFactoryImpl(config, tierManager, SERVER_INFO);
+    taskFactory = new MesosTaskFactoryImpl(config, SERVER_INFO);
 
     control.replay();
 
-    TaskInfo task = taskFactory.createFrom(TASK, OFFER_THERMOS_EXECUTOR);
+    TaskInfo task = taskFactory.createFrom(TASK, OFFER_THERMOS_EXECUTOR, false);
     assertEquals(
         purgeZeroResources(populateDynamicFields(
             NO_OVERHEAD_EXECUTOR.getExecutorConfig(TASK.getTask()
@@ -331,13 +320,11 @@ public class MesosTaskFactoryImplTest extends EasyMockTest {
 
   private TaskInfo getDockerTaskInfo(IAssignedTask task) {
     config = SOME_OVERHEAD_EXECUTOR;
-
-    expect(tierManager.getTier(task.getTask())).andReturn(DEV_TIER);
-    taskFactory = new MesosTaskFactoryImpl(config, tierManager, SERVER_INFO);
+    taskFactory = new MesosTaskFactoryImpl(config, SERVER_INFO);
 
     control.replay();
 
-    return taskFactory.createFrom(task, OFFER_SOME_OVERHEAD_EXECUTOR);
+    return taskFactory.createFrom(task, OFFER_SOME_OVERHEAD_EXECUTOR, false);
   }
 
   @Test
@@ -358,13 +345,11 @@ public class MesosTaskFactoryImplTest extends EasyMockTest {
   @Test
   public void testGlobalMounts() {
     config = EXECUTOR_SETTINGS_WITH_VOLUMES;
-
-    expect(tierManager.getTier(TASK_WITH_DOCKER.getTask())).andReturn(DEV_TIER);
-    taskFactory = new MesosTaskFactoryImpl(config, tierManager, SERVER_INFO);
+    taskFactory = new MesosTaskFactoryImpl(config, SERVER_INFO);
 
     control.replay();
 
-    TaskInfo taskInfo = taskFactory.createFrom(TASK_WITH_DOCKER, OFFER_THERMOS_EXECUTOR);
+    TaskInfo taskInfo = taskFactory.createFrom(TASK_WITH_DOCKER, OFFER_THERMOS_EXECUTOR,
false);
     assertEquals(
         config.getExecutorConfig(TASK_WITH_DOCKER.getTask().getExecutorConfig().getName()).get()
             .getVolumeMounts(),
@@ -385,11 +370,10 @@ public class MesosTaskFactoryImplTest extends EasyMockTest {
                         .setImage(Image.docker(new DockerImage(imageName, imageTag)))
                         .setVolumes(ImmutableList.of(volume)))))));
 
-    expect(tierManager.getTier(taskWithImageAndVolumes.getTask())).andReturn(DEV_TIER);
     control.replay();
 
-    taskFactory = new MesosTaskFactoryImpl(config, tierManager, SERVER_INFO);
-    TaskInfo task = taskFactory.createFrom(taskWithImageAndVolumes, OFFER_THERMOS_EXECUTOR);
+    taskFactory = new MesosTaskFactoryImpl(config, SERVER_INFO);
+    TaskInfo task = taskFactory.createFrom(taskWithImageAndVolumes, OFFER_THERMOS_EXECUTOR,
false);
 
     assertEquals(
         ContainerInfo.newBuilder()
@@ -412,12 +396,11 @@ public class MesosTaskFactoryImplTest extends EasyMockTest {
 
   @Test
   public void testMetadataLabelMapping() {
-    expect(tierManager.getTier(TASK.getTask())).andReturn(DEV_TIER);
-    taskFactory = new MesosTaskFactoryImpl(config, tierManager, SERVER_INFO);
+    taskFactory = new MesosTaskFactoryImpl(config, SERVER_INFO);
 
     control.replay();
 
-    TaskInfo task = taskFactory.createFrom(TASK, OFFER_THERMOS_EXECUTOR);
+    TaskInfo task = taskFactory.createFrom(TASK, OFFER_THERMOS_EXECUTOR, false);
     ImmutableSet<String> labels = task.getLabels().getLabelsList().stream()
         .filter(l -> l.getKey().startsWith(METADATA_LABEL_PREFIX))
         .map(l -> l.getKey() + l.getValue())
@@ -433,12 +416,11 @@ public class MesosTaskFactoryImplTest extends EasyMockTest {
 
   @Test
   public void testTierLabel() {
-    expect(tierManager.getTier(TASK.getTask())).andReturn(PREFERRED_TIER);
-    taskFactory = new MesosTaskFactoryImpl(config, tierManager, SERVER_INFO);
+    taskFactory = new MesosTaskFactoryImpl(config, SERVER_INFO);
 
     control.replay();
 
-    TaskInfo task = taskFactory.createFrom(TASK, OFFER_THERMOS_EXECUTOR);
+    TaskInfo task = taskFactory.createFrom(TASK, OFFER_THERMOS_EXECUTOR, false);
 
     assertTrue(task.getLabels().getLabelsList().stream().anyMatch(
         l -> l.getKey().equals(TIER_LABEL) && l.getValue().equals(PROD_TIER_NAME)));
@@ -476,12 +458,12 @@ public class MesosTaskFactoryImplTest extends EasyMockTest {
     builder.setTask(
         resetPorts(ITaskConfig.build(builder.getTask()), ImmutableSet.of()).newBuilder());
     IAssignedTask assignedTask = IAssignedTask.build(builder);
-    expect(tierManager.getTier(assignedTask.getTask())).andReturn(DEV_TIER);
-    taskFactory = new MesosTaskFactoryImpl(config, tierManager, SERVER_INFO);
+    taskFactory = new MesosTaskFactoryImpl(config, SERVER_INFO);
 
     control.replay();
 
-    TaskInfo task = taskFactory.createFrom(IAssignedTask.build(builder), OFFER_THERMOS_EXECUTOR);
+    TaskInfo task =
+        taskFactory.createFrom(IAssignedTask.build(builder), OFFER_THERMOS_EXECUTOR, false);
     checkTaskResources(ITaskConfig.build(builder.getTask()), task);
     checkDiscoveryInfo(task, ImmutableMap.of(), assignedTask.getTask().getJob());
   }
@@ -492,11 +474,10 @@ public class MesosTaskFactoryImplTest extends EasyMockTest {
         ImmutableMap.<String, ExecutorConfig>builder().put(THERMOS_CONFIG.getExecutor().getName(),
             THERMOS_CONFIG).build(),
         true /* populate discovery info */);
-    expect(tierManager.getTier(TASK_CONFIG)).andReturn(DEV_TIER);
-    taskFactory = new MesosTaskFactoryImpl(config, tierManager, SERVER_INFO);
+    taskFactory = new MesosTaskFactoryImpl(config, SERVER_INFO);
 
     control.replay();
-    TaskInfo task = taskFactory.createFrom(TASK, OFFER_THERMOS_EXECUTOR);
+    TaskInfo task = taskFactory.createFrom(TASK, OFFER_THERMOS_EXECUTOR, false);
     checkTaskResources(TASK.getTask(), task);
     checkDiscoveryInfo(task, ImmutableMap.of("http", 80), TASK.getTask().getJob());
   }
@@ -512,14 +493,10 @@ public class MesosTaskFactoryImplTest extends EasyMockTest {
                     new MesosContainer().setImage(
                         Image.docker(new DockerImage(imageName, imageTag))))))));
 
-    expect(tierManager.getTier(taskWithDockerImage.getTask())).andReturn(DEV_TIER);
     control.replay();
 
-    taskFactory = new MesosTaskFactoryImpl(
-        EXECUTOR_SETTINGS_WITH_VOLUMES,
-        tierManager,
-        SERVER_INFO);
-    TaskInfo task = taskFactory.createFrom(taskWithDockerImage, OFFER_THERMOS_EXECUTOR);
+    taskFactory = new MesosTaskFactoryImpl(EXECUTOR_SETTINGS_WITH_VOLUMES, SERVER_INFO);
+    TaskInfo task = taskFactory.createFrom(taskWithDockerImage, OFFER_THERMOS_EXECUTOR, false);
     assertEquals(
         ContainerInfo.newBuilder()
             .setType(Type.MESOS)
@@ -548,15 +525,11 @@ public class MesosTaskFactoryImplTest extends EasyMockTest {
                     new MesosContainer().setImage(
                         Image.appc(new AppcImage(imageName, imageId))))))));
 
-    expect(tierManager.getTier(taskWithAppcImage.getTask())).andReturn(DEV_TIER);
     control.replay();
 
-    taskFactory = new MesosTaskFactoryImpl(
-        EXECUTOR_SETTINGS_WITH_VOLUMES,
-        tierManager,
-        SERVER_INFO);
+    taskFactory = new MesosTaskFactoryImpl(EXECUTOR_SETTINGS_WITH_VOLUMES, SERVER_INFO);
 
-    TaskInfo task = taskFactory.createFrom(taskWithAppcImage, OFFER_THERMOS_EXECUTOR);
+    TaskInfo task = taskFactory.createFrom(taskWithAppcImage, OFFER_THERMOS_EXECUTOR, false);
     assertEquals(
         ContainerInfo.newBuilder()
             .setType(Type.MESOS)

http://git-wip-us.apache.org/repos/asf/aurora/blob/0e3e0dd7/src/test/java/org/apache/aurora/scheduler/resources/AcceptedOfferTest.java
----------------------------------------------------------------------
diff --git a/src/test/java/org/apache/aurora/scheduler/resources/AcceptedOfferTest.java b/src/test/java/org/apache/aurora/scheduler/resources/AcceptedOfferTest.java
index c47f7c9..468dcac 100644
--- a/src/test/java/org/apache/aurora/scheduler/resources/AcceptedOfferTest.java
+++ b/src/test/java/org/apache/aurora/scheduler/resources/AcceptedOfferTest.java
@@ -21,7 +21,6 @@ import com.google.common.collect.ImmutableSet;
 
 import org.apache.aurora.gen.AssignedTask;
 import org.apache.aurora.gen.TaskConfig;
-import org.apache.aurora.scheduler.TierInfo;
 import org.apache.aurora.scheduler.storage.entities.IAssignedTask;
 import org.apache.mesos.v1.Protos;
 import org.apache.mesos.v1.Protos.Resource;
@@ -74,7 +73,7 @@ public class AcceptedOfferTest {
         offer(),
         IAssignedTask.build(new AssignedTask().setTask(new TaskConfig())),
         ResourceBag.EMPTY,
-        DEV_TIER);
+        DEV_TIER.isRevocable());
     assertEquals(Collections.emptyList(), acceptedOffer.getTaskResources());
     assertEquals(Collections.emptyList(), acceptedOffer.getExecutorResources());
   }
@@ -94,8 +93,7 @@ public class AcceptedOfferTest {
         mesosScalar(DISK_MB, TOTAL_BAG.valueOf(DISK_MB), false),
         mesosRange(PORTS, role, TASK_PORTS));
 
-    AcceptedOffer offerAllocation = AcceptedOffer.create(
-        offer, TASK, EXECUTOR_BAG, new TierInfo(false, revocable));
+    AcceptedOffer offerAllocation = AcceptedOffer.create(offer, TASK, EXECUTOR_BAG, revocable);
 
     ResourceBag bag = bagFromResources(TASK.getTask().getResources());
     Set<Resource> taskResources = ImmutableSet.<Resource>builder()
@@ -132,8 +130,7 @@ public class AcceptedOfferTest {
         mesosScalar(DISK_MB, TEST_ROLE, false, TOTAL_BAG.valueOf(DISK_MB)),
         mesosRange(PORTS, TEST_ROLE, TASK_PORTS));
 
-    AcceptedOffer offerAllocation = AcceptedOffer.create(
-        offer, TASK, EXECUTOR_BAG, new TierInfo(false, revocable));
+    AcceptedOffer offerAllocation = AcceptedOffer.create(offer, TASK, EXECUTOR_BAG, revocable);
 
     Set<Resource> taskSet = ImmutableSet.<Resource>builder()
         .add(mesosScalar(CPUS, TEST_ROLE, revocable, EXECUTOR_BAG.valueOf(CPUS)))

http://git-wip-us.apache.org/repos/asf/aurora/blob/0e3e0dd7/src/test/java/org/apache/aurora/scheduler/resources/ResourceManagerTest.java
----------------------------------------------------------------------
diff --git a/src/test/java/org/apache/aurora/scheduler/resources/ResourceManagerTest.java
b/src/test/java/org/apache/aurora/scheduler/resources/ResourceManagerTest.java
index 37dfcbc..a5623ca 100644
--- a/src/test/java/org/apache/aurora/scheduler/resources/ResourceManagerTest.java
+++ b/src/test/java/org/apache/aurora/scheduler/resources/ResourceManagerTest.java
@@ -21,7 +21,6 @@ import com.google.common.collect.ImmutableSet;
 import com.google.common.collect.Iterables;
 
 import org.apache.aurora.gen.AssignedTask;
-import org.apache.aurora.scheduler.TierInfo;
 import org.apache.aurora.scheduler.storage.entities.IAssignedTask;
 import org.apache.aurora.scheduler.storage.entities.IResource;
 import org.apache.mesos.v1.Protos;
@@ -92,10 +91,10 @@ public class ResourceManagerTest {
         ImmutableSet.copyOf(ResourceManager.getRevocableOfferResources(offer)));
     assertEquals(
         ImmutableSet.of(resource1, resource3),
-        ImmutableSet.copyOf(ResourceManager.getOfferResources(offer, new TierInfo(false,
false))));
+        ImmutableSet.copyOf(ResourceManager.getOfferResources(offer, false)));
     assertEquals(
         ImmutableSet.of(resource2, resource3),
-        ImmutableSet.copyOf(ResourceManager.getOfferResources(offer, new TierInfo(false,
true))));
+        ImmutableSet.copyOf(ResourceManager.getOfferResources(offer, true)));
   }
 
   @Test

http://git-wip-us.apache.org/repos/asf/aurora/blob/0e3e0dd7/src/test/java/org/apache/aurora/scheduler/state/FirstFitTaskAssignerTest.java
----------------------------------------------------------------------
diff --git a/src/test/java/org/apache/aurora/scheduler/state/FirstFitTaskAssignerTest.java
b/src/test/java/org/apache/aurora/scheduler/state/FirstFitTaskAssignerTest.java
index 5837250..58f9de2 100644
--- a/src/test/java/org/apache/aurora/scheduler/state/FirstFitTaskAssignerTest.java
+++ b/src/test/java/org/apache/aurora/scheduler/state/FirstFitTaskAssignerTest.java
@@ -172,7 +172,7 @@ public class FirstFitTaskAssignerTest extends EasyMockTest {
     expect(tierManager.getTier(TASK.getAssignedTask().getTask())).andReturn(DEV_TIER);
     expect(filter.filter(UNUSED, resourceRequest)).andReturn(ImmutableSet.of());
     expectAssignTask(MESOS_OFFER);
-    expect(taskFactory.createFrom(TASK.getAssignedTask(), MESOS_OFFER))
+    expect(taskFactory.createFrom(TASK.getAssignedTask(), MESOS_OFFER, false))
         .andReturn(TASK_INFO);
 
     control.replay();
@@ -255,7 +255,7 @@ public class FirstFitTaskAssignerTest extends EasyMockTest {
         LOST,
         LAUNCH_FAILED_MSG))
         .andReturn(StateChangeResult.SUCCESS);
-    expect(taskFactory.createFrom(TASK.getAssignedTask(), MESOS_OFFER))
+    expect(taskFactory.createFrom(TASK.getAssignedTask(), MESOS_OFFER, false))
         .andReturn(TASK_INFO);
 
     control.replay();
@@ -313,7 +313,7 @@ public class FirstFitTaskAssignerTest extends EasyMockTest {
             OFFER_2.getAttributes()),
         resourceRequest)).andReturn(ImmutableSet.of());
     expectAssignTask(OFFER_2.getOffer());
-    expect(taskFactory.createFrom(TASK.getAssignedTask(), OFFER_2.getOffer()))
+    expect(taskFactory.createFrom(TASK.getAssignedTask(), OFFER_2.getOffer(), false))
         .andReturn(TASK_INFO);
     offerManager.launchTask(OFFER_2.getOffer().getId(), TASK_INFO);
 
@@ -363,7 +363,7 @@ public class FirstFitTaskAssignerTest extends EasyMockTest {
         .andReturn(ImmutableSet.of());
 
     expectAssignTask(MESOS_OFFER);
-    expect(taskFactory.createFrom(TASK.getAssignedTask(), OFFER.getOffer()))
+    expect(taskFactory.createFrom(TASK.getAssignedTask(), OFFER.getOffer(), false))
         .andReturn(TASK_INFO);
     offerManager.launchTask(OFFER.getOffer().getId(), TASK_INFO);
 
@@ -404,7 +404,7 @@ public class FirstFitTaskAssignerTest extends EasyMockTest {
     offerManager.launchTask(MESOS_OFFER.getId(), TASK_INFO);
     expect(tierManager.getTier(TASK.getAssignedTask().getTask())).andReturn(DEV_TIER);
 
-    expect(taskFactory.createFrom(TASK.getAssignedTask(), MESOS_OFFER))
+    expect(taskFactory.createFrom(TASK.getAssignedTask(), MESOS_OFFER, false))
         .andReturn(TASK_INFO);
 
     control.replay();
@@ -465,7 +465,7 @@ public class FirstFitTaskAssignerTest extends EasyMockTest {
     offerManager.launchTask(MESOS_OFFER.getId(), TASK_INFO);
     expect(tierManager.getTier(TASK.getAssignedTask().getTask())).andReturn(DEV_TIER);
 
-    expect(taskFactory.createFrom(TASK.getAssignedTask(), MESOS_OFFER))
+    expect(taskFactory.createFrom(TASK.getAssignedTask(), MESOS_OFFER, false))
         .andReturn(TASK_INFO);
 
     // Normal scheduling loop for the remaining task...


Mime
View raw message