aurora-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ma...@apache.org
Subject git commit: Returning a message when no tasks to kill.
Date Tue, 17 Jun 2014 00:54:11 GMT
Repository: incubator-aurora
Updated Branches:
  refs/heads/master d97c3e623 -> 30a410921


Returning a message when no tasks to kill.

Bugs closed: AURORA-533

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


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

Branch: refs/heads/master
Commit: 30a410921a6a30a2353e1c08beb80148d0bcaa73
Parents: d97c3e6
Author: Maxim Khutornenko <maxim@apache.org>
Authored: Mon Jun 16 17:53:38 2014 -0700
Committer: Maxim Khutornenko <maxim@apache.org>
Committed: Mon Jun 16 17:53:38 2014 -0700

----------------------------------------------------------------------
 .../scheduler/thrift/SchedulerThriftInterface.java      |  6 +++++-
 .../scheduler/thrift/SchedulerThriftInterfaceTest.java  | 12 ++++++------
 2 files changed, 11 insertions(+), 7 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-aurora/blob/30a41092/src/main/java/org/apache/aurora/scheduler/thrift/SchedulerThriftInterface.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/aurora/scheduler/thrift/SchedulerThriftInterface.java
b/src/main/java/org/apache/aurora/scheduler/thrift/SchedulerThriftInterface.java
index 94072cf..3616b3e 100644
--- a/src/main/java/org/apache/aurora/scheduler/thrift/SchedulerThriftInterface.java
+++ b/src/main/java/org/apache/aurora/scheduler/thrift/SchedulerThriftInterface.java
@@ -598,6 +598,10 @@ class SchedulerThriftInterface implements AuroraAdmin.Iface {
     }
 
     Set<IScheduledTask> tasks = Storage.Util.consistentFetchTasks(storage, Query.arbitrary(query));
+    if (Iterables.isEmpty(tasks)) {
+      // Short-circuit the call if there are no tasks to kill.
+      return addMessage(response, OK, "No tasks to kill.");
+    }
 
     Optional<SessionContext> context = isAdmin(session);
     if (context.isPresent()) {
@@ -617,7 +621,7 @@ class SchedulerThriftInterface implements AuroraAdmin.Iface {
       return addMessage(response, LOCK_ERROR, e.getMessage());
     }
 
-    return response.setResponseCode(OK);
+    return addMessage(response, OK, "Tasks killed.");
   }
 
   @Override

http://git-wip-us.apache.org/repos/asf/incubator-aurora/blob/30a41092/src/test/java/org/apache/aurora/scheduler/thrift/SchedulerThriftInterfaceTest.java
----------------------------------------------------------------------
diff --git a/src/test/java/org/apache/aurora/scheduler/thrift/SchedulerThriftInterfaceTest.java
b/src/test/java/org/apache/aurora/scheduler/thrift/SchedulerThriftInterfaceTest.java
index bab8b9f..c93daeb 100644
--- a/src/test/java/org/apache/aurora/scheduler/thrift/SchedulerThriftInterfaceTest.java
+++ b/src/test/java/org/apache/aurora/scheduler/thrift/SchedulerThriftInterfaceTest.java
@@ -426,11 +426,12 @@ public class SchedulerThriftInterfaceTest extends EasyMockTest {
 
     expectAuth(ROOT, true);
     scheduler.killTasks(query, USER);
-    storageUtil.expectTaskFetch(query);
+    storageUtil.expectTaskFetch(query, buildScheduledTask(JOB_NAME));
+    lockManager.validateIfLocked(LOCK_KEY, Optional.of(LOCK));
 
     control.replay();
 
-    assertOkResponse(thrift.killTasks(query.get(), DEFAULT_LOCK, SESSION));
+    assertOkResponse(thrift.killTasks(query.get(), LOCK.newBuilder(), SESSION));
   }
 
   @Test
@@ -448,14 +449,13 @@ public class SchedulerThriftInterfaceTest extends EasyMockTest {
   public void testKillNonExistentTasks() throws Exception {
     Query.Builder query = Query.unscoped().byJob(JOB_KEY).active();
 
-    expectAuth(ROOT, true);
-
-    scheduler.killTasks(query, USER);
     storageUtil.expectTaskFetch(query);
 
     control.replay();
 
-    assertOkResponse(thrift.killTasks(query.get(), DEFAULT_LOCK, SESSION));
+    Response response = thrift.killTasks(query.get(), DEFAULT_LOCK, SESSION);
+    assertOkResponse(response);
+    assertEquals("No tasks to kill.", response.getMessageDEPRECATED());
   }
 
   @Test


Mime
View raw message