aurora-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ma...@apache.org
Subject git commit: Fixing broken HistoryPruner
Date Thu, 24 Apr 2014 22:51:44 GMT
Repository: incubator-aurora
Updated Branches:
  refs/heads/master 9a08e2f14 -> 4bb26d097


Fixing broken HistoryPruner

Bugs closed: AURORA-359

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


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

Branch: refs/heads/master
Commit: 4bb26d097ce30fae5f67b31abe0f4eaa516333e8
Parents: 9a08e2f
Author: Maxim Khutornenko <maxim@apache.org>
Authored: Thu Apr 24 15:49:49 2014 -0700
Committer: Maxim Khutornenko <maxim@apache.org>
Committed: Thu Apr 24 15:49:49 2014 -0700

----------------------------------------------------------------------
 .../aurora/scheduler/state/StateManagerImpl.java  | 11 ++++++++---
 .../scheduler/state/StateManagerImplTest.java     | 18 ++++++++++++++++++
 2 files changed, 26 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-aurora/blob/4bb26d09/src/main/java/org/apache/aurora/scheduler/state/StateManagerImpl.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/aurora/scheduler/state/StateManagerImpl.java b/src/main/java/org/apache/aurora/scheduler/state/StateManagerImpl.java
index 74ef64d..c0c34b6 100644
--- a/src/main/java/org/apache/aurora/scheduler/state/StateManagerImpl.java
+++ b/src/main/java/org/apache/aurora/scheduler/state/StateManagerImpl.java
@@ -441,10 +441,15 @@ public class StateManagerImpl implements StateManager {
     storage.write(new MutateWork.NoResult.Quiet() {
       @Override
       protected void execute(final MutableStoreProvider storeProvider) {
-        for (String taskId : taskIds) {
+
+        Map<String, IScheduledTask> tasks = Maps.uniqueIndex(
+            storeProvider.getTaskStore().fetchTasks(Query.taskScoped(taskIds)),
+            Tasks.SCHEDULED_TO_ID);
+
+        for (Map.Entry<String, IScheduledTask> entry : tasks.entrySet()) {
           updateTaskAndExternalState(
-              taskId,
-              Optional.<IScheduledTask>absent(),
+              entry.getKey(),
+              Optional.of(entry.getValue()),
               Optional.<ScheduleStatus>absent(),
               Optional.<String>absent());
         }

http://git-wip-us.apache.org/repos/asf/incubator-aurora/blob/4bb26d09/src/test/java/org/apache/aurora/scheduler/state/StateManagerImplTest.java
----------------------------------------------------------------------
diff --git a/src/test/java/org/apache/aurora/scheduler/state/StateManagerImplTest.java b/src/test/java/org/apache/aurora/scheduler/state/StateManagerImplTest.java
index af17c2c..ceffcd3 100644
--- a/src/test/java/org/apache/aurora/scheduler/state/StateManagerImplTest.java
+++ b/src/test/java/org/apache/aurora/scheduler/state/StateManagerImplTest.java
@@ -57,6 +57,7 @@ import org.junit.Test;
 
 import static org.apache.aurora.gen.ScheduleStatus.ASSIGNED;
 import static org.apache.aurora.gen.ScheduleStatus.FAILED;
+import static org.apache.aurora.gen.ScheduleStatus.FINISHED;
 import static org.apache.aurora.gen.ScheduleStatus.INIT;
 import static org.apache.aurora.gen.ScheduleStatus.KILLING;
 import static org.apache.aurora.gen.ScheduleStatus.LOST;
@@ -378,6 +379,23 @@ public class StateManagerImplTest extends EasyMockTest {
         Optional.<String>absent()));
   }
 
+  @Test
+  public void testDeleteTasks() {
+    ITaskConfig task = makeTask(JIM, MY_JOB);
+    String taskId = "a";
+    expect(taskIdGenerator.generate(task, 0)).andReturn(taskId);
+    expectStateTransitions(taskId, INIT, PENDING, ASSIGNED, RUNNING, FINISHED);
+    eventSink.post(matchTasksDeleted(taskId));
+
+    control.replay();
+
+    insertTask(task, 0);
+    assignTask(taskId, HOST_A);
+    changeState(taskId, RUNNING);
+    changeState(taskId, FINISHED);
+    stateManager.deleteTasks(ImmutableSet.of(taskId));
+  }
+
   private void expectStateTransitions(
       String taskId,
       ScheduleStatus initial,


Mime
View raw message