@Test public void assertGetEligibleJobContext() { Collection<JobContext> failoverJobContexts = Collections.singletonList(JobContext.from(CloudJobConfigurationBuilder .createCloudJobConfiguration("failover_job").toCloudJobConfiguration(), ExecutionType.FAILOVER)); Collection<JobContext> readyJobContexts = Collections.singletonList(JobContext.from(CloudJobConfigurationBuilder .createCloudJobConfiguration("ready_job").toCloudJobConfiguration(), ExecutionType.READY)); when(failoverService.getAllEligibleJobContexts()).thenReturn(failoverJobContexts); when(readyService.getAllEligibleJobContexts(failoverJobContexts)).thenReturn(readyJobContexts); Collection<JobContext> actual = facadeService.getEligibleJobContext(); assertThat(actual.size(), is(2)); int i = 0; for (JobContext each : actual) { switch (i) { case 0: assertThat(each.getCloudJobConfig().getJobConfig().getJobName(), is("failover_job")); break; case 1: assertThat(each.getCloudJobConfig().getJobConfig().getJobName(), is("ready_job")); break; default: break; } i++; } }
public Collection<JobContext> getEligibleJobContext() { Collection<JobContext> failoverJobContexts = failoverService.getAllEligibleJobContexts(); Collection<JobContext> readyJobContexts = readyService.getAllEligibleJobContexts(failoverJobContexts); Collection<JobContext> result = new ArrayList<>(failoverJobContexts.size() + readyJobContexts.size()); result.addAll(failoverJobContexts); result.addAll(readyJobContexts); return result; }
FacadeService { public Collection<JobContext> getEligibleJobContext() { Collection<JobContext> failoverJobContexts = failoverService.getAllEligibleJobContexts(); Collection<JobContext> readyJobContexts = readyService.getAllEligibleJobContexts(failoverJobContexts); Collection<JobContext> result = new ArrayList<>(failoverJobContexts.size() + readyJobContexts.size()); result.addAll(failoverJobContexts); result.addAll(readyJobContexts); return result; } }
FacadeService { public Collection<JobContext> getEligibleJobContext() { Collection<JobContext> failoverJobContexts = failoverService.getAllEligibleJobContexts(); Collection<JobContext> readyJobContexts = readyService.getAllEligibleJobContexts(failoverJobContexts); Collection<JobContext> result = new ArrayList<>(failoverJobContexts.size() + readyJobContexts.size()); result.addAll(failoverJobContexts); result.addAll(readyJobContexts); return result; } FacadeService(final CoordinatorRegistryCenter regCenter); }
FacadeService { public Collection<JobContext> getEligibleJobContext() { Collection<JobContext> failoverJobContexts = failoverService.getAllEligibleJobContexts(); Collection<JobContext> readyJobContexts = readyService.getAllEligibleJobContexts(failoverJobContexts); Collection<JobContext> result = new ArrayList<>(failoverJobContexts.size() + readyJobContexts.size()); result.addAll(failoverJobContexts); result.addAll(readyJobContexts); return result; } FacadeService(final CoordinatorRegistryCenter regCenter); void start(); Collection<JobContext> getEligibleJobContext(); void removeLaunchTasksFromQueue(final List<TaskContext> taskContexts); void addRunning(final TaskContext taskContext); void updateDaemonStatus(final TaskContext taskContext, final boolean isIdle); void removeRunning(final TaskContext taskContext); void recordFailoverTask(final TaskContext taskContext); void addTransient(final String jobName); Optional<CloudJobConfigurationPOJO> load(final String jobName); Optional<CloudAppConfigurationPOJO> loadAppConfig(final String appName); Optional<String> getFailoverTaskId(final MetaInfo metaInfo); void addDaemonJobToReadyQueue(final String jobName); boolean isRunning(final TaskContext taskContext); void addMapping(final String taskId, final String hostname); String popMapping(final String taskId); Map<String, Integer> getAllReadyTasks(); Map<String, Set<TaskContext>> getAllRunningTasks(); Map<String, Collection<FailoverTaskInfo>> getAllFailoverTasks(); boolean isJobDisabled(final String jobName); void enableJob(final String jobName); void disableJob(final String jobName); Collection<ExecutorStateInfo> loadExecutorInfo(); void stop(); }
FacadeService { public Collection<JobContext> getEligibleJobContext() { Collection<JobContext> failoverJobContexts = failoverService.getAllEligibleJobContexts(); Collection<JobContext> readyJobContexts = readyService.getAllEligibleJobContexts(failoverJobContexts); Collection<JobContext> result = new ArrayList<>(failoverJobContexts.size() + readyJobContexts.size()); result.addAll(failoverJobContexts); result.addAll(readyJobContexts); return result; } FacadeService(final CoordinatorRegistryCenter regCenter); void start(); Collection<JobContext> getEligibleJobContext(); void removeLaunchTasksFromQueue(final List<TaskContext> taskContexts); void addRunning(final TaskContext taskContext); void updateDaemonStatus(final TaskContext taskContext, final boolean isIdle); void removeRunning(final TaskContext taskContext); void recordFailoverTask(final TaskContext taskContext); void addTransient(final String jobName); Optional<CloudJobConfigurationPOJO> load(final String jobName); Optional<CloudAppConfigurationPOJO> loadAppConfig(final String appName); Optional<String> getFailoverTaskId(final MetaInfo metaInfo); void addDaemonJobToReadyQueue(final String jobName); boolean isRunning(final TaskContext taskContext); void addMapping(final String taskId, final String hostname); String popMapping(final String taskId); Map<String, Integer> getAllReadyTasks(); Map<String, Set<TaskContext>> getAllRunningTasks(); Map<String, Collection<FailoverTaskInfo>> getAllFailoverTasks(); boolean isJobDisabled(final String jobName); void enableJob(final String jobName); void disableJob(final String jobName); Collection<ExecutorStateInfo> loadExecutorInfo(); void stop();  }