aurora-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ma...@apache.org
Subject git commit: Bug fix: Return job count instead of task count on GetRoleSummary() call.
Date Wed, 29 Jan 2014 00:29:09 GMT
Updated Branches:
  refs/heads/master 3870df32b -> e2ec0f9cf


Bug fix: Return job count instead of task count on GetRoleSummary() call.

Updated test cases to catch this bug.
Updated getJobSummary API to return results as a set instead of a list.

Testing Done:
gradle clean build
gradle run - tested in local UI.

Bugs closed: AURORA-116

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


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

Branch: refs/heads/master
Commit: e2ec0f9cff70dbd7c44a5bc0432fcb384c86b4ab
Parents: 3870df3
Author: Suman Karumuri <mansu@apache.org>
Authored: Tue Jan 28 16:24:51 2014 -0800
Committer: Suman Karumuri <skarumuri@twitter.com>
Committed: Tue Jan 28 16:24:51 2014 -0800

----------------------------------------------------------------------
 .../thrift/SchedulerThriftInterface.java        | 24 +++++++++++++-------
 .../thrift/org/apache/aurora/gen/api.thrift     |  2 +-
 .../thrift/SchedulerThriftInterfaceTest.java    | 19 ++++++++++++----
 .../org/apache/aurora/gen/api.thrift.md5        |  2 +-
 4 files changed, 32 insertions(+), 15 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-aurora/blob/e2ec0f9c/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 cf9099f..822b8b9 100644
--- a/src/main/java/org/apache/aurora/scheduler/thrift/SchedulerThriftInterface.java
+++ b/src/main/java/org/apache/aurora/scheduler/thrift/SchedulerThriftInterface.java
@@ -34,6 +34,7 @@ import com.google.common.base.Predicate;
 import com.google.common.base.Predicates;
 import com.google.common.base.Throwables;
 import com.google.common.collect.FluentIterable;
+import com.google.common.collect.HashMultimap;
 import com.google.common.collect.ImmutableMultimap;
 import com.google.common.collect.ImmutableSet;
 import com.google.common.collect.Iterables;
@@ -380,16 +381,15 @@ class SchedulerThriftInterface implements AuroraAdmin.Iface {
 
   @Override
   public Response getJobSummary() {
-    Set<IScheduledTask> tasks = Storage.Util.weaklyConsistentFetchTasks(storage, Query.unscoped());
-    Multimap<String, IJobKey> jobsByRole = Multimaps.index(
-        FluentIterable.from(tasks).transform(Tasks.SCHEDULED_TO_JOB_KEY),
-        JobKeys.TO_ROLE);
+    Multimap<String, IJobKey> jobsByRole = mapByRole(
+        Storage.Util.weaklyConsistentFetchTasks(storage, Query.unscoped()),
+        Tasks.SCHEDULED_TO_JOB_KEY);
 
-    Multimap<String, IJobKey> cronJobsByRole = Multimaps.index(
-        FluentIterable.from(cronJobManager.getJobs()).transform(JobKeys.FROM_CONFIG),
-        JobKeys.TO_ROLE);
+    Multimap<String, IJobKey> cronJobsByRole = mapByRole(
+        cronJobManager.getJobs(),
+        JobKeys.FROM_CONFIG);
 
-    List<JobSummary> jobSummaries = Lists.newLinkedList();
+    Set<JobSummary> jobSummaries = Sets.newHashSet();
     for (String role : Sets.union(jobsByRole.keySet(), cronJobsByRole.keySet())) {
       JobSummary summary = new JobSummary();
       summary.setRole(role);
@@ -403,6 +403,14 @@ class SchedulerThriftInterface implements AuroraAdmin.Iface {
         .setResult(Result.jobSummaryResult(new JobSummaryResult(jobSummaries)));
   }
 
+  private static <T> Multimap<String, IJobKey> mapByRole(
+      Iterable<T> tasks,
+      Function<T, IJobKey> keyExtractor) {
+
+    return HashMultimap.create(
+        Multimaps.index(Iterables.transform(tasks, keyExtractor), JobKeys.TO_ROLE));
+  }
+
   @Override
   public Response getJobs(@Nullable String maybeNullRole) {
     Optional<String> ownerRole = Optional.fromNullable(maybeNullRole);

http://git-wip-us.apache.org/repos/asf/incubator-aurora/blob/e2ec0f9c/src/main/thrift/org/apache/aurora/gen/api.thrift
----------------------------------------------------------------------
diff --git a/src/main/thrift/org/apache/aurora/gen/api.thrift b/src/main/thrift/org/apache/aurora/gen/api.thrift
index 7401037..94569f9 100644
--- a/src/main/thrift/org/apache/aurora/gen/api.thrift
+++ b/src/main/thrift/org/apache/aurora/gen/api.thrift
@@ -392,7 +392,7 @@ struct EndMaintenanceResult {
 }
 
 struct JobSummaryResult {
-  1: list<JobSummary> summaries
+  1: set<JobSummary> summaries
 }
 
 // Specifies validation level for the populateJobConfig.

http://git-wip-us.apache.org/repos/asf/incubator-aurora/blob/e2ec0f9c/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 6cefdfa..02b7a27 100644
--- a/src/test/java/org/apache/aurora/scheduler/thrift/SchedulerThriftInterfaceTest.java
+++ b/src/test/java/org/apache/aurora/scheduler/thrift/SchedulerThriftInterfaceTest.java
@@ -1068,7 +1068,7 @@ public class SchedulerThriftInterfaceTest extends EasyMockTest {
         .setTaskConfig(nonProductionTask());
     JobConfiguration cronJobTwo = makeJob()
         .setCronSchedule("2 * * * *")
-        .setKey(JOB_KEY.newBuilder())
+        .setKey(JOB_KEY.newBuilder().setName("cronJob2"))
         .setTaskConfig(nonProductionTask());
 
     JobConfiguration cronJobThree = makeJob()
@@ -1082,23 +1082,32 @@ public class SchedulerThriftInterfaceTest extends EasyMockTest {
     TaskConfig immediateTaskConfig = defaultTask(false)
         .setJobName("immediate")
         .setOwner(ROLE_IDENTITY);
-    IScheduledTask immediateTask = IScheduledTask.build(new ScheduledTask()
+    IScheduledTask task1 = IScheduledTask.build(new ScheduledTask()
         .setAssignedTask(new AssignedTask().setTask(immediateTaskConfig)));
+    IScheduledTask task2 = IScheduledTask.build(new ScheduledTask()
+        .setAssignedTask(new AssignedTask().setTask(immediateTaskConfig.setNumCpus(2))));
 
     TaskConfig immediateTaskConfigTwo = defaultTask(false)
         .setJobName("immediateTwo")
         .setOwner(BAZ_ROLE_IDENTITY);
-    IScheduledTask immediateTaskTwo = IScheduledTask.build(new ScheduledTask()
+    IScheduledTask task3 = IScheduledTask.build(new ScheduledTask()
         .setAssignedTask(new AssignedTask().setTask(immediateTaskConfigTwo)));
 
-    storageUtil.expectTaskFetch(Query.unscoped(), immediateTask, immediateTaskTwo);
+    TaskConfig immediateTaskConfigThree = defaultTask(false)
+        .setJobName("immediateThree")
+        .setOwner(BAZ_ROLE_IDENTITY);
+    IScheduledTask task4 = IScheduledTask.build(new ScheduledTask()
+        .setAssignedTask(new AssignedTask().setTask(immediateTaskConfigThree)));
+
+    storageUtil.expectTaskFetch(Query.unscoped(), task1, task2, task3, task4);
+
     expect(cronJobManager.getJobs()).andReturn(IJobConfiguration.setFromBuilders(crons));
 
     JobSummaryResult expectedResult = new JobSummaryResult();
     expectedResult.addToSummaries(
         new JobSummary().setRole(ROLE).setCronJobCount(2).setJobCount(1));
     expectedResult.addToSummaries(
-        new JobSummary().setRole(BAZ_ROLE).setCronJobCount(1).setJobCount(1));
+        new JobSummary().setRole(BAZ_ROLE).setCronJobCount(1).setJobCount(2));
 
     control.replay();
 

http://git-wip-us.apache.org/repos/asf/incubator-aurora/blob/e2ec0f9c/src/test/resources/org/apache/aurora/gen/api.thrift.md5
----------------------------------------------------------------------
diff --git a/src/test/resources/org/apache/aurora/gen/api.thrift.md5 b/src/test/resources/org/apache/aurora/gen/api.thrift.md5
index 42fdca2..e88d297 100644
--- a/src/test/resources/org/apache/aurora/gen/api.thrift.md5
+++ b/src/test/resources/org/apache/aurora/gen/api.thrift.md5
@@ -1 +1 @@
-867e9ac3b98e660b6fb830527098785c
+28ec7c76c1f5d4ed162fc7f13cf0d0ff


Mime
View raw message