use of com.dangdang.ddframe.job.executor.ShardingContexts in project elastic-job by dangdangdotcom.
the class WrongJobExecutorTest method assertWrongJobExecutorWithMultipleItems.
@Test
public void assertWrongJobExecutorWithMultipleItems() throws NoSuchFieldException {
Map<Integer, String> map = new HashMap<>(1, 1);
map.put(0, "A");
map.put(1, "B");
ShardingContexts shardingContexts = new ShardingContexts("fake_task_id", "test_job", 10, "", map);
when(jobFacade.getShardingContexts()).thenReturn(shardingContexts);
wrongSimpleJobExecutor.execute();
verify(jobFacade).getShardingContexts();
verify(jobFacade).postJobStatusTraceEvent("fake_task_id", State.TASK_RUNNING, "");
}
use of com.dangdang.ddframe.job.executor.ShardingContexts in project elastic-job by dangdangdotcom.
the class ExecutionContextService method getJobShardingContext.
/**
* 获取当前作业服务器分片上下文.
*
* @param shardingItems 分片项
* @return 分片上下文
*/
public ShardingContexts getJobShardingContext(final List<Integer> shardingItems) {
LiteJobConfiguration liteJobConfig = configService.load(false);
removeRunningIfMonitorExecution(liteJobConfig.isMonitorExecution(), shardingItems);
if (shardingItems.isEmpty()) {
return new ShardingContexts(buildTaskId(liteJobConfig, shardingItems), liteJobConfig.getJobName(), liteJobConfig.getTypeConfig().getCoreConfig().getShardingTotalCount(), liteJobConfig.getTypeConfig().getCoreConfig().getJobParameter(), Collections.<Integer, String>emptyMap());
}
Map<Integer, String> shardingItemParameterMap = new ShardingItemParameters(liteJobConfig.getTypeConfig().getCoreConfig().getShardingItemParameters()).getMap();
return new ShardingContexts(buildTaskId(liteJobConfig, shardingItems), liteJobConfig.getJobName(), liteJobConfig.getTypeConfig().getCoreConfig().getShardingTotalCount(), liteJobConfig.getTypeConfig().getCoreConfig().getJobParameter(), getAssignedShardingItemParameterMap(shardingItems, shardingItemParameterMap));
}
use of com.dangdang.ddframe.job.executor.ShardingContexts in project elastic-job by dangdangdotcom.
the class LiteJobFacadeTest method assertAfterJobExecuted.
@Test
public void assertAfterJobExecuted() {
liteJobFacade.afterJobExecuted(new ShardingContexts("fake_task_id", "test_job", 10, "", Collections.<Integer, String>emptyMap()));
verify(caller).after();
}
use of com.dangdang.ddframe.job.executor.ShardingContexts in project elastic-job by dangdangdotcom.
the class ExecutionContextServiceTest method assertGetShardingContextWhenNotAssignShardingItem.
@Test
public void assertGetShardingContextWhenNotAssignShardingItem() {
when(configService.load(false)).thenReturn(LiteJobConfiguration.newBuilder(new DataflowJobConfiguration(JobCoreConfiguration.newBuilder("test_job", "0/1 * * * * ?", 3).build(), TestDataflowJob.class.getCanonicalName(), true)).monitorExecution(false).build());
ShardingContexts shardingContexts = executionContextService.getJobShardingContext(Collections.<Integer>emptyList());
assertTrue(shardingContexts.getTaskId().startsWith("test_job@-@@-@READY@-@"));
assertThat(shardingContexts.getShardingTotalCount(), is(3));
verify(configService).load(false);
}
use of com.dangdang.ddframe.job.executor.ShardingContexts in project elastic-job by dangdangdotcom.
the class ExecutionServiceTest method assertRegisterJobBeginWhenNotAssignAnyItem.
@Test
public void assertRegisterJobBeginWhenNotAssignAnyItem() {
executionService.registerJobBegin(new ShardingContexts("fake_task_id", "test_job", 10, "", Collections.<Integer, String>emptyMap()));
verify(configService, times(0)).load(true);
}
Aggregations