aurora-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ma...@apache.org
Subject git commit: Include inactive tasks when computing job summaries
Date Thu, 24 Apr 2014 02:08:59 GMT
Repository: incubator-aurora
Updated Branches:
  refs/heads/master 91ff94b7c -> 03036e9b3


Include inactive tasks when computing job summaries

Currently, the getTasks query was only fetching tasks in active status.
Updated the code to fetching all tasks for getJobSummary.

Testing Done:
Tested on laptop.

Bugs closed: AURORA-338

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


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

Branch: refs/heads/master
Commit: 03036e9b3dcaada18a8e39c8f03dc4dbb0090777
Parents: 91ff94b
Author: Suman Karumuri <mansu@apache.org>
Authored: Wed Apr 23 19:05:53 2014 -0700
Committer: Suman Karumuri <skarumuri@twitter.com>
Committed: Wed Apr 23 19:05:53 2014 -0700

----------------------------------------------------------------------
 .../thrift/SchedulerThriftInterface.java        | 35 +++++++++++---------
 .../thrift/SchedulerThriftInterfaceTest.java    |  2 +-
 2 files changed, 20 insertions(+), 17 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-aurora/blob/03036e9b/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 84151a5..7c55793 100644
--- a/src/main/java/org/apache/aurora/scheduler/thrift/SchedulerThriftInterface.java
+++ b/src/main/java/org/apache/aurora/scheduler/thrift/SchedulerThriftInterface.java
@@ -142,7 +142,7 @@ import static org.apache.aurora.gen.apiConstants.CURRENT_API_VERSION;
 
 /**
  * Aurora scheduler thrift server implementation.
- * <p>
+ * <p/>
  * Interfaces between users and the scheduler to access/modify jobs and perform cluster
  * administration tasks.
  */
@@ -403,7 +403,7 @@ class SchedulerThriftInterface implements AuroraAdmin.Iface {
   public Response getJobSummary(@Nullable String maybeNullRole) {
     Optional<String> ownerRole = Optional.fromNullable(maybeNullRole);
 
-    final Multimap<IJobKey, IScheduledTask> tasks = getTasks(ownerRole);
+    final Multimap<IJobKey, IScheduledTask> tasks = getTasks(maybeRoleScoped(ownerRole));
     final Map<IJobKey, IJobConfiguration> jobs = getJobs(ownerRole, tasks);
 
     Function<IJobKey, JobSummary> makeJobSummary = new Function<IJobKey, JobSummary>()
{
@@ -426,6 +426,12 @@ class SchedulerThriftInterface implements AuroraAdmin.Iface {
     return okResponse(Result.jobSummaryResult(new JobSummaryResult().setSummaries(jobSummaries)));
   }
 
+  private Query.Builder maybeRoleScoped(Optional<String> ownerRole) {
+    return ownerRole.isPresent()
+          ? Query.roleScoped(ownerRole.get())
+          : Query.unscoped();
+  }
+
   private Map<IJobKey, IJobConfiguration> getJobs(
       Optional<String> ownerRole,
       Multimap<IJobKey, IScheduledTask> tasks) {
@@ -468,11 +474,8 @@ class SchedulerThriftInterface implements AuroraAdmin.Iface {
     return jobs;
   }
 
-  private Multimap<IJobKey, IScheduledTask> getTasks(Optional<String> ownerRole)
{
-    Query.Builder scope = ownerRole.isPresent()
-        ? Query.roleScoped(ownerRole.get())
-        : Query.unscoped();
-    return Tasks.byJobKey(Storage.Util.weaklyConsistentFetchTasks(storage, scope.active()));
+  private Multimap<IJobKey, IScheduledTask> getTasks(Query.Builder query) {
+    return Tasks.byJobKey(Storage.Util.weaklyConsistentFetchTasks(storage, query));
   }
 
   private static <T> Multimap<String, IJobKey> mapByRole(
@@ -490,7 +493,7 @@ class SchedulerThriftInterface implements AuroraAdmin.Iface {
     return okResponse(Result.getJobsResult(
         new GetJobsResult()
             .setConfigs(IJobConfiguration.toBuildersSet(
-                getJobs(ownerRole, getTasks(ownerRole)).values()))));
+                getJobs(ownerRole, getTasks(maybeRoleScoped(ownerRole).active())).values()))));
   }
 
   private void validateLockForTasks(Optional<ILock> lock, Iterable<IScheduledTask>
tasks)
@@ -665,9 +668,9 @@ class SchedulerThriftInterface implements AuroraAdmin.Iface {
 
   @Override
   public Response startMaintenance(Hosts hosts, SessionKey session) {
-      return okResponse(Result.startMaintenanceResult(
-          new StartMaintenanceResult()
-              .setStatuses(maintenance.startMaintenance(hosts.getHostNames()))));
+    return okResponse(Result.startMaintenanceResult(
+        new StartMaintenanceResult()
+            .setStatuses(maintenance.startMaintenance(hosts.getHostNames()))));
   }
 
   @Override
@@ -684,9 +687,9 @@ class SchedulerThriftInterface implements AuroraAdmin.Iface {
 
   @Override
   public Response endMaintenance(Hosts hosts, SessionKey session) {
-      return okResponse(Result.endMaintenanceResult(
-          new EndMaintenanceResult()
-              .setStatuses(maintenance.endMaintenance(hosts.getHostNames()))));
+    return okResponse(Result.endMaintenanceResult(
+        new EndMaintenanceResult()
+            .setStatuses(maintenance.endMaintenance(hosts.getHostNames()))));
   }
 
   @Override
@@ -815,8 +818,8 @@ class SchedulerThriftInterface implements AuroraAdmin.Iface {
 
     if (request.getRewriteCommandsSize() == 0) {
       return new Response()
-        .setResponseCode(ResponseCode.ERROR)
-        .setMessage("No rewrite commands provided.");
+          .setResponseCode(ResponseCode.ERROR)
+          .setMessage("No rewrite commands provided.");
     }
 
     return storage.write(new MutateWork.Quiet<Response>() {

http://git-wip-us.apache.org/repos/asf/incubator-aurora/blob/03036e9b/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 f530c53..c23c948 100644
--- a/src/test/java/org/apache/aurora/scheduler/thrift/SchedulerThriftInterfaceTest.java
+++ b/src/test/java/org/apache/aurora/scheduler/thrift/SchedulerThriftInterfaceTest.java
@@ -1003,7 +1003,7 @@ public class SchedulerThriftInterfaceTest extends EasyMockTest {
         .setOwner(ROLE_IDENTITY)
         .setInstanceCount(1)
         .setTaskConfig(ownedImmediateTaskInfo);
-    Query.Builder query = Query.roleScoped(ROLE).active();
+    Query.Builder query = Query.roleScoped(ROLE);
 
     Set<JobSummary> ownedImmedieteJobSummaryOnly = ImmutableSet.of(
         new JobSummary().setJob(ownedImmediateJob).setStats(new JobStats().setActiveTaskCount(1)));


Mime
View raw message