@Test public void assertGetJobExecutionShardingContextWhenNotAssignShardingItem() { when(configService.getShardingTotalCount()).thenReturn(3); when(configService.isFailover()).thenReturn(false); when(configService.isMonitorExecution()).thenReturn(false); when(configService.getFetchDataCount()).thenReturn(10); JobExecutionMultipleShardingContext expected = new JobExecutionMultipleShardingContext(); expected.setJobName("testJob"); expected.setShardingTotalCount(3); expected.setFetchDataCount(10); assertThat(executionContextService.getJobExecutionShardingContext(Collections.<Integer>emptyList()), new ReflectionEquals(expected)); verify(configService).getShardingTotalCount(); verify(configService).isMonitorExecution(); verify(configService).getFetchDataCount(); }
public JobExecutionMultipleShardingContext getJobExecutionShardingContext(final List<Integer> shardingItems) { JobExecutionMultipleShardingContext result = new JobExecutionMultipleShardingContext(); result.setJobName(jobConfiguration.getJobName()); result.setShardingTotalCount(configService.getShardingTotalCount()); result.setShardingItems(shardingItems); boolean isMonitorExecution = configService.isMonitorExecution(); if (isMonitorExecution) { removeRunningItems(shardingItems); } result.setJobParameter(configService.getJobParameter()); result.setMonitorExecution(isMonitorExecution); result.setFetchDataCount(configService.getFetchDataCount()); if (result.getShardingItems().isEmpty()) { return result; } Map<Integer, String> shardingItemParameters = configService.getShardingItemParameters(); for (int each : result.getShardingItems()) { if (shardingItemParameters.containsKey(each)) { result.getShardingItemParameters().put(each, shardingItemParameters.get(each)); } } result.setOffsets(offsetService.getOffsets(result.getShardingItems())); return result; }
ExecutionContextService { public JobExecutionMultipleShardingContext getJobExecutionShardingContext(final List<Integer> shardingItems) { JobExecutionMultipleShardingContext result = new JobExecutionMultipleShardingContext(); result.setJobName(jobConfiguration.getJobName()); result.setShardingTotalCount(configService.getShardingTotalCount()); result.setShardingItems(shardingItems); boolean isMonitorExecution = configService.isMonitorExecution(); if (isMonitorExecution) { removeRunningItems(shardingItems); } result.setJobParameter(configService.getJobParameter()); result.setMonitorExecution(isMonitorExecution); result.setFetchDataCount(configService.getFetchDataCount()); if (result.getShardingItems().isEmpty()) { return result; } Map<Integer, String> shardingItemParameters = configService.getShardingItemParameters(); for (int each : result.getShardingItems()) { if (shardingItemParameters.containsKey(each)) { result.getShardingItemParameters().put(each, shardingItemParameters.get(each)); } } result.setOffsets(offsetService.getOffsets(result.getShardingItems())); return result; } }
ExecutionContextService { public JobExecutionMultipleShardingContext getJobExecutionShardingContext(final List<Integer> shardingItems) { JobExecutionMultipleShardingContext result = new JobExecutionMultipleShardingContext(); result.setJobName(jobConfiguration.getJobName()); result.setShardingTotalCount(configService.getShardingTotalCount()); result.setShardingItems(shardingItems); boolean isMonitorExecution = configService.isMonitorExecution(); if (isMonitorExecution) { removeRunningItems(shardingItems); } result.setJobParameter(configService.getJobParameter()); result.setMonitorExecution(isMonitorExecution); result.setFetchDataCount(configService.getFetchDataCount()); if (result.getShardingItems().isEmpty()) { return result; } Map<Integer, String> shardingItemParameters = configService.getShardingItemParameters(); for (int each : result.getShardingItems()) { if (shardingItemParameters.containsKey(each)) { result.getShardingItemParameters().put(each, shardingItemParameters.get(each)); } } result.setOffsets(offsetService.getOffsets(result.getShardingItems())); return result; } ExecutionContextService(final CoordinatorRegistryCenter coordinatorRegistryCenter, final JobConfiguration jobConfiguration); }
ExecutionContextService { public JobExecutionMultipleShardingContext getJobExecutionShardingContext(final List<Integer> shardingItems) { JobExecutionMultipleShardingContext result = new JobExecutionMultipleShardingContext(); result.setJobName(jobConfiguration.getJobName()); result.setShardingTotalCount(configService.getShardingTotalCount()); result.setShardingItems(shardingItems); boolean isMonitorExecution = configService.isMonitorExecution(); if (isMonitorExecution) { removeRunningItems(shardingItems); } result.setJobParameter(configService.getJobParameter()); result.setMonitorExecution(isMonitorExecution); result.setFetchDataCount(configService.getFetchDataCount()); if (result.getShardingItems().isEmpty()) { return result; } Map<Integer, String> shardingItemParameters = configService.getShardingItemParameters(); for (int each : result.getShardingItems()) { if (shardingItemParameters.containsKey(each)) { result.getShardingItemParameters().put(each, shardingItemParameters.get(each)); } } result.setOffsets(offsetService.getOffsets(result.getShardingItems())); return result; } ExecutionContextService(final CoordinatorRegistryCenter coordinatorRegistryCenter, final JobConfiguration jobConfiguration); JobExecutionMultipleShardingContext getJobExecutionShardingContext(final List<Integer> shardingItems); }
ExecutionContextService { public JobExecutionMultipleShardingContext getJobExecutionShardingContext(final List<Integer> shardingItems) { JobExecutionMultipleShardingContext result = new JobExecutionMultipleShardingContext(); result.setJobName(jobConfiguration.getJobName()); result.setShardingTotalCount(configService.getShardingTotalCount()); result.setShardingItems(shardingItems); boolean isMonitorExecution = configService.isMonitorExecution(); if (isMonitorExecution) { removeRunningItems(shardingItems); } result.setJobParameter(configService.getJobParameter()); result.setMonitorExecution(isMonitorExecution); result.setFetchDataCount(configService.getFetchDataCount()); if (result.getShardingItems().isEmpty()) { return result; } Map<Integer, String> shardingItemParameters = configService.getShardingItemParameters(); for (int each : result.getShardingItems()) { if (shardingItemParameters.containsKey(each)) { result.getShardingItemParameters().put(each, shardingItemParameters.get(each)); } } result.setOffsets(offsetService.getOffsets(result.getShardingItems())); return result; } ExecutionContextService(final CoordinatorRegistryCenter coordinatorRegistryCenter, final JobConfiguration jobConfiguration); JobExecutionMultipleShardingContext getJobExecutionShardingContext(final List<Integer> shardingItems);  }