ReadOnlySchedulerImpl implements ReadOnlyScheduler.Iface { @Override public Response getConfigSummary(JobKey job) throws TException { IJobKey jobKey = JobKeys.assertValid(IJobKey.build(job)); Iterable<IAssignedTask> assignedTasks = Iterables.transform( Storage.Util.fetchTasks(storage, Query.jobScoped(jobKey).active()), IScheduledTask::getAssignedTask); Map<Integer, ITaskConfig> tasksByInstance = Maps.transformValues( Maps.uniqueIndex(assignedTasks, IAssignedTask::getInstanceId), IAssignedTask::getTask); Set<ConfigGroup> groups = instancesToConfigGroups(tasksByInstance); return ok(Result.configSummaryResult( new ConfigSummaryResult().setSummary(new ConfigSummary(job, groups)))); } @Inject  ReadOnlySchedulerImpl(
      ConfigurationManager configurationManager,
      Storage storage,
      NearestFit nearestFit,
      CronPredictor cronPredictor,
      QuotaManager quotaManager); @Override Response populateJobConfig(JobConfiguration description); @Override Response getTasksStatus(TaskQuery query); @Override Response getTasksWithoutConfigs(TaskQuery query); @Override Response getPendingReason(TaskQuery query); @Override Response getConfigSummary(JobKey job); @Override Response getRoleSummary(); @Override Response getJobSummary(@Nullable String maybeNullRole); @Override Response getJobs(@Nullable String maybeNullRole); @Override Response getQuota(String ownerRole); @Override Response getJobUpdateSummaries(JobUpdateQuery mutableQuery); @Override Response getJobUpdateDetails(JobUpdateKey mutableKey); @Override Response getJobUpdateDiff(JobUpdateRequest mutableRequest);  }
@Test public void testGetConfigSummary() throws Exception { IJobKey key = JobKeys.from("test", "test", "test"); TaskConfig firstGroupTask = defaultTask(true); TaskConfig secondGroupTask = defaultTask(true).setNumCpus(2); IScheduledTask first1 = IScheduledTask.build(new ScheduledTask() .setAssignedTask(new AssignedTask().setTask(firstGroupTask).setInstanceId(0))); IScheduledTask first2 = IScheduledTask.build(new ScheduledTask() .setAssignedTask(new AssignedTask().setTask(firstGroupTask).setInstanceId(1))); IScheduledTask second = IScheduledTask.build(new ScheduledTask() .setAssignedTask(new AssignedTask().setTask(secondGroupTask).setInstanceId(2))); storageUtil.expectTaskFetch(Query.jobScoped(key).active(), first1, first2, second); ConfigGroup group1 = new ConfigGroup() .setConfig(firstGroupTask) .setInstances(IRange.toBuildersSet(convertRanges(toRanges(ImmutableSet.of(0, 1))))); ConfigGroup group2 = new ConfigGroup() .setConfig(secondGroupTask) .setInstances(IRange.toBuildersSet(convertRanges(toRanges(ImmutableSet.of(2))))); ConfigSummary summary = new ConfigSummary() .setKey(key.newBuilder()) .setGroups(Sets.newHashSet(group1, group2)); ConfigSummaryResult expected = new ConfigSummaryResult().setSummary(summary); control.replay(); Response response = assertOkResponse(thrift.getConfigSummary(key.newBuilder())); assertEquals( IConfigSummaryResult.build(expected), IConfigSummaryResult.build(response.getResult().getConfigSummaryResult())); }
@Test public void testEmptyConfigSummary() throws Exception { IJobKey key = JobKeys.from("test", "test", "test"); storageUtil.expectTaskFetch(Query.jobScoped(key).active(), ImmutableSet.of()); ConfigSummary summary = new ConfigSummary() .setKey(key.newBuilder()) .setGroups(Sets.newHashSet()); ConfigSummaryResult expected = new ConfigSummaryResult().setSummary(summary); control.replay(); Response response = assertOkResponse(thrift.getConfigSummary(key.newBuilder())); assertEquals(expected, response.getResult().getConfigSummaryResult()); }