@Test public void assertGetAllEligibleJobContextsWithoutRootNode() { when(regCenter.isExisted("/state/ready")).thenReturn(false); assertTrue(readyService.getAllEligibleJobContexts(Collections.emptyList()).isEmpty()); verify(regCenter).isExisted("/state/ready"); }
public Collection<JobContext> getAllEligibleJobContexts(final Collection<JobContext> ineligibleJobContexts) { if (!regCenter.isExisted(ReadyNode.ROOT)) { return Collections.emptyList(); } Collection<String> ineligibleJobNames = ineligibleJobContexts.stream().map(input -> input.getCloudJobConfig().getJobConfig().getJobName()).collect(Collectors.toList()); List<String> jobNames = regCenter.getChildrenKeys(ReadyNode.ROOT); List<JobContext> result = new ArrayList<>(jobNames.size()); for (String each : jobNames) { if (ineligibleJobNames.contains(each)) { continue; } Optional<CloudJobConfigurationPOJO> jobConfig = configService.load(each); if (!jobConfig.isPresent()) { regCenter.remove(ReadyNode.getReadyJobNodePath(each)); continue; } if (!runningService.isJobRunning(each)) { result.add(JobContext.from(jobConfig.get().toCloudJobConfiguration(), ExecutionType.READY)); } } return result; }
ReadyService { public Collection<JobContext> getAllEligibleJobContexts(final Collection<JobContext> ineligibleJobContexts) { if (!regCenter.isExisted(ReadyNode.ROOT)) { return Collections.emptyList(); } Collection<String> ineligibleJobNames = ineligibleJobContexts.stream().map(input -> input.getCloudJobConfig().getJobConfig().getJobName()).collect(Collectors.toList()); List<String> jobNames = regCenter.getChildrenKeys(ReadyNode.ROOT); List<JobContext> result = new ArrayList<>(jobNames.size()); for (String each : jobNames) { if (ineligibleJobNames.contains(each)) { continue; } Optional<CloudJobConfigurationPOJO> jobConfig = configService.load(each); if (!jobConfig.isPresent()) { regCenter.remove(ReadyNode.getReadyJobNodePath(each)); continue; } if (!runningService.isJobRunning(each)) { result.add(JobContext.from(jobConfig.get().toCloudJobConfiguration(), ExecutionType.READY)); } } return result; } }
ReadyService { public Collection<JobContext> getAllEligibleJobContexts(final Collection<JobContext> ineligibleJobContexts) { if (!regCenter.isExisted(ReadyNode.ROOT)) { return Collections.emptyList(); } Collection<String> ineligibleJobNames = ineligibleJobContexts.stream().map(input -> input.getCloudJobConfig().getJobConfig().getJobName()).collect(Collectors.toList()); List<String> jobNames = regCenter.getChildrenKeys(ReadyNode.ROOT); List<JobContext> result = new ArrayList<>(jobNames.size()); for (String each : jobNames) { if (ineligibleJobNames.contains(each)) { continue; } Optional<CloudJobConfigurationPOJO> jobConfig = configService.load(each); if (!jobConfig.isPresent()) { regCenter.remove(ReadyNode.getReadyJobNodePath(each)); continue; } if (!runningService.isJobRunning(each)) { result.add(JobContext.from(jobConfig.get().toCloudJobConfiguration(), ExecutionType.READY)); } } return result; } ReadyService(final CoordinatorRegistryCenter regCenter); }
ReadyService { public Collection<JobContext> getAllEligibleJobContexts(final Collection<JobContext> ineligibleJobContexts) { if (!regCenter.isExisted(ReadyNode.ROOT)) { return Collections.emptyList(); } Collection<String> ineligibleJobNames = ineligibleJobContexts.stream().map(input -> input.getCloudJobConfig().getJobConfig().getJobName()).collect(Collectors.toList()); List<String> jobNames = regCenter.getChildrenKeys(ReadyNode.ROOT); List<JobContext> result = new ArrayList<>(jobNames.size()); for (String each : jobNames) { if (ineligibleJobNames.contains(each)) { continue; } Optional<CloudJobConfigurationPOJO> jobConfig = configService.load(each); if (!jobConfig.isPresent()) { regCenter.remove(ReadyNode.getReadyJobNodePath(each)); continue; } if (!runningService.isJobRunning(each)) { result.add(JobContext.from(jobConfig.get().toCloudJobConfiguration(), ExecutionType.READY)); } } return result; } ReadyService(final CoordinatorRegistryCenter regCenter); void addTransient(final String jobName); void addDaemon(final String jobName); void setMisfireDisabled(final String jobName); Collection<JobContext> getAllEligibleJobContexts(final Collection<JobContext> ineligibleJobContexts); void remove(final Collection<String> jobNames); Map<String, Integer> getAllReadyTasks(); }
ReadyService { public Collection<JobContext> getAllEligibleJobContexts(final Collection<JobContext> ineligibleJobContexts) { if (!regCenter.isExisted(ReadyNode.ROOT)) { return Collections.emptyList(); } Collection<String> ineligibleJobNames = ineligibleJobContexts.stream().map(input -> input.getCloudJobConfig().getJobConfig().getJobName()).collect(Collectors.toList()); List<String> jobNames = regCenter.getChildrenKeys(ReadyNode.ROOT); List<JobContext> result = new ArrayList<>(jobNames.size()); for (String each : jobNames) { if (ineligibleJobNames.contains(each)) { continue; } Optional<CloudJobConfigurationPOJO> jobConfig = configService.load(each); if (!jobConfig.isPresent()) { regCenter.remove(ReadyNode.getReadyJobNodePath(each)); continue; } if (!runningService.isJobRunning(each)) { result.add(JobContext.from(jobConfig.get().toCloudJobConfiguration(), ExecutionType.READY)); } } return result; } ReadyService(final CoordinatorRegistryCenter regCenter); void addTransient(final String jobName); void addDaemon(final String jobName); void setMisfireDisabled(final String jobName); Collection<JobContext> getAllEligibleJobContexts(final Collection<JobContext> ineligibleJobContexts); void remove(final Collection<String> jobNames); Map<String, Integer> getAllReadyTasks();  }