@Test public void assertGetShardingContextWhenNotAssignShardingItem() { when(configService.load(false)).thenReturn(JobConfiguration.newBuilder("test_job", 3) .cron("0/1 * * * * ?").setProperty("streaming.process", Boolean.TRUE.toString()).monitorExecution(false).build()); ShardingContexts shardingContexts = executionContextService.getJobShardingContext(Collections.emptyList()); assertTrue(shardingContexts.getTaskId().startsWith("test_job@-@@-@READY@-@")); assertThat(shardingContexts.getShardingTotalCount(), is(3)); }
public ShardingContexts getJobShardingContext(final List<Integer> shardingItems) { JobConfiguration jobConfig = configService.load(false); removeRunningIfMonitorExecution(jobConfig.isMonitorExecution(), shardingItems); if (shardingItems.isEmpty()) { return new ShardingContexts(buildTaskId(jobConfig, shardingItems), jobConfig.getJobName(), jobConfig.getShardingTotalCount(), jobConfig.getJobParameter(), Collections.emptyMap()); } Map<Integer, String> shardingItemParameterMap = new ShardingItemParameters(jobConfig.getShardingItemParameters()).getMap(); return new ShardingContexts(buildTaskId(jobConfig, shardingItems), jobConfig.getJobName(), jobConfig.getShardingTotalCount(), jobConfig.getJobParameter(), getAssignedShardingItemParameterMap(shardingItems, shardingItemParameterMap)); }
ExecutionContextService { public ShardingContexts getJobShardingContext(final List<Integer> shardingItems) { JobConfiguration jobConfig = configService.load(false); removeRunningIfMonitorExecution(jobConfig.isMonitorExecution(), shardingItems); if (shardingItems.isEmpty()) { return new ShardingContexts(buildTaskId(jobConfig, shardingItems), jobConfig.getJobName(), jobConfig.getShardingTotalCount(), jobConfig.getJobParameter(), Collections.emptyMap()); } Map<Integer, String> shardingItemParameterMap = new ShardingItemParameters(jobConfig.getShardingItemParameters()).getMap(); return new ShardingContexts(buildTaskId(jobConfig, shardingItems), jobConfig.getJobName(), jobConfig.getShardingTotalCount(), jobConfig.getJobParameter(), getAssignedShardingItemParameterMap(shardingItems, shardingItemParameterMap)); } }
ExecutionContextService { public ShardingContexts getJobShardingContext(final List<Integer> shardingItems) { JobConfiguration jobConfig = configService.load(false); removeRunningIfMonitorExecution(jobConfig.isMonitorExecution(), shardingItems); if (shardingItems.isEmpty()) { return new ShardingContexts(buildTaskId(jobConfig, shardingItems), jobConfig.getJobName(), jobConfig.getShardingTotalCount(), jobConfig.getJobParameter(), Collections.emptyMap()); } Map<Integer, String> shardingItemParameterMap = new ShardingItemParameters(jobConfig.getShardingItemParameters()).getMap(); return new ShardingContexts(buildTaskId(jobConfig, shardingItems), jobConfig.getJobName(), jobConfig.getShardingTotalCount(), jobConfig.getJobParameter(), getAssignedShardingItemParameterMap(shardingItems, shardingItemParameterMap)); } ExecutionContextService(final CoordinatorRegistryCenter regCenter, final String jobName); }
ExecutionContextService { public ShardingContexts getJobShardingContext(final List<Integer> shardingItems) { JobConfiguration jobConfig = configService.load(false); removeRunningIfMonitorExecution(jobConfig.isMonitorExecution(), shardingItems); if (shardingItems.isEmpty()) { return new ShardingContexts(buildTaskId(jobConfig, shardingItems), jobConfig.getJobName(), jobConfig.getShardingTotalCount(), jobConfig.getJobParameter(), Collections.emptyMap()); } Map<Integer, String> shardingItemParameterMap = new ShardingItemParameters(jobConfig.getShardingItemParameters()).getMap(); return new ShardingContexts(buildTaskId(jobConfig, shardingItems), jobConfig.getJobName(), jobConfig.getShardingTotalCount(), jobConfig.getJobParameter(), getAssignedShardingItemParameterMap(shardingItems, shardingItemParameterMap)); } ExecutionContextService(final CoordinatorRegistryCenter regCenter, final String jobName); ShardingContexts getJobShardingContext(final List<Integer> shardingItems); }
ExecutionContextService { public ShardingContexts getJobShardingContext(final List<Integer> shardingItems) { JobConfiguration jobConfig = configService.load(false); removeRunningIfMonitorExecution(jobConfig.isMonitorExecution(), shardingItems); if (shardingItems.isEmpty()) { return new ShardingContexts(buildTaskId(jobConfig, shardingItems), jobConfig.getJobName(), jobConfig.getShardingTotalCount(), jobConfig.getJobParameter(), Collections.emptyMap()); } Map<Integer, String> shardingItemParameterMap = new ShardingItemParameters(jobConfig.getShardingItemParameters()).getMap(); return new ShardingContexts(buildTaskId(jobConfig, shardingItems), jobConfig.getJobName(), jobConfig.getShardingTotalCount(), jobConfig.getJobParameter(), getAssignedShardingItemParameterMap(shardingItems, shardingItemParameterMap)); } ExecutionContextService(final CoordinatorRegistryCenter regCenter, final String jobName); ShardingContexts getJobShardingContext(final List<Integer> shardingItems);  }