aurora-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From wfar...@apache.org
Subject git commit: Avoid sending tasks in SANDBOX_DELETED state to the GC executor.
Date Wed, 07 May 2014 01:21:58 GMT
Repository: incubator-aurora
Updated Branches:
  refs/heads/master a4602b050 -> 0d4b1a10a


Avoid sending tasks in SANDBOX_DELETED state to the GC executor.

Bugs closed: AURORA-395

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


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

Branch: refs/heads/master
Commit: 0d4b1a10a20a660c4f06a82bbe99c6ca43c417d1
Parents: a4602b0
Author: Bill Farner <wfarner@apache.org>
Authored: Tue May 6 18:21:53 2014 -0700
Committer: Bill Farner <wfarner@apache.org>
Committed: Tue May 6 18:21:53 2014 -0700

----------------------------------------------------------------------
 .../aurora/scheduler/async/GcExecutorLauncher.java   | 11 ++++++++---
 .../scheduler/async/GcExecutorLauncherTest.java      | 15 +++++++++++++++
 2 files changed, 23 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-aurora/blob/0d4b1a10/src/main/java/org/apache/aurora/scheduler/async/GcExecutorLauncher.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/aurora/scheduler/async/GcExecutorLauncher.java b/src/main/java/org/apache/aurora/scheduler/async/GcExecutorLauncher.java
index d57b0d4..e599cac 100644
--- a/src/main/java/org/apache/aurora/scheduler/async/GcExecutorLauncher.java
+++ b/src/main/java/org/apache/aurora/scheduler/async/GcExecutorLauncher.java
@@ -15,6 +15,7 @@
  */
 package org.apache.aurora.scheduler.async;
 
+import java.util.Map;
 import java.util.Set;
 import java.util.UUID;
 import java.util.concurrent.Executor;
@@ -26,6 +27,7 @@ import javax.inject.Inject;
 
 import com.google.common.annotations.VisibleForTesting;
 import com.google.common.base.Optional;
+import com.google.common.base.Predicates;
 import com.google.common.base.Supplier;
 import com.google.common.base.Throwables;
 import com.google.common.cache.Cache;
@@ -42,6 +44,7 @@ import com.twitter.common.util.Random;
 import org.apache.aurora.Protobufs;
 import org.apache.aurora.codec.ThriftBinaryCodec;
 import org.apache.aurora.codec.ThriftBinaryCodec.CodingException;
+import org.apache.aurora.gen.ScheduleStatus;
 import org.apache.aurora.gen.comm.AdjustRetainedTasks;
 import org.apache.aurora.scheduler.Driver;
 import org.apache.aurora.scheduler.TaskLauncher;
@@ -171,10 +174,12 @@ public class GcExecutorLauncher implements TaskLauncher {
   private TaskInfo makeGcTask(String hostName, SlaveID slaveId) {
     Set<IScheduledTask> tasksOnHost =
         Storage.Util.weaklyConsistentFetchTasks(storage, Query.slaveScoped(hostName));
-    AdjustRetainedTasks message = new AdjustRetainedTasks()
-        .setRetainedTasks(Maps.transformValues(Tasks.mapById(tasksOnHost), Tasks.GET_STATUS));
+
+    Map<String, ScheduleStatus> tasks = Maps.filterValues(
+        Maps.transformValues(Tasks.mapById(tasksOnHost), Tasks.GET_STATUS),
+        Predicates.not(Predicates.equalTo(ScheduleStatus.SANDBOX_DELETED)));
     tasksCreated.incrementAndGet();
-    return makeGcTask(hostName, slaveId, message);
+    return makeGcTask(hostName, slaveId, new AdjustRetainedTasks().setRetainedTasks(tasks));
   }
 
   private boolean sufficientResources(Offer offer) {

http://git-wip-us.apache.org/repos/asf/incubator-aurora/blob/0d4b1a10/src/test/java/org/apache/aurora/scheduler/async/GcExecutorLauncherTest.java
----------------------------------------------------------------------
diff --git a/src/test/java/org/apache/aurora/scheduler/async/GcExecutorLauncherTest.java b/src/test/java/org/apache/aurora/scheduler/async/GcExecutorLauncherTest.java
index 016bed9..4dc90cb 100644
--- a/src/test/java/org/apache/aurora/scheduler/async/GcExecutorLauncherTest.java
+++ b/src/test/java/org/apache/aurora/scheduler/async/GcExecutorLauncherTest.java
@@ -55,6 +55,7 @@ import org.junit.Before;
 import org.junit.Test;
 
 import static org.apache.aurora.gen.ScheduleStatus.FAILED;
+import static org.apache.aurora.gen.ScheduleStatus.SANDBOX_DELETED;
 import static org.apache.aurora.scheduler.async.GcExecutorLauncher.SYSTEM_TASK_PREFIX;
 import static org.junit.Assert.assertFalse;
 import static org.junit.Assert.assertTrue;
@@ -173,6 +174,20 @@ public class GcExecutorLauncherTest extends EasyMockTest {
     assertFalse(gcExecutorLauncher.willUse(OFFER));
   }
 
+  @Test
+  public void testFiltersSandboxDeleted() {
+    IScheduledTask a = makeTask(JOB_A, FAILED);
+    IScheduledTask b = makeTask(JOB_A, SANDBOX_DELETED);
+
+    expectGetTasksByHost(HOST, a, b);
+    expectAdjustRetainedTasks(a);
+
+    control.replay();
+
+    // First call - no items in the cache, no tasks collected.
+    assertTrue(gcExecutorLauncher.willUse(OFFER));
+  }
+
   private void expectAdjustRetainedTasks(IScheduledTask... tasks) {
     Map<String, ScheduleStatus> statuses =
         Maps.transformValues(Tasks.mapById(ImmutableSet.copyOf(tasks)), Tasks.GET_STATUS);


Mime
View raw message