use of com.dangdang.ddframe.job.config.dataflow.DataflowJobConfiguration in project elastic-job by dangdangdotcom.
the class ExecutionContextServiceTest method assertGetShardingContextWhenAssignShardingItems.
@Test
public void assertGetShardingContextWhenAssignShardingItems() {
when(configService.load(false)).thenReturn(LiteJobConfiguration.newBuilder(new DataflowJobConfiguration(JobCoreConfiguration.newBuilder("test_job", "0/1 * * * * ?", 3).shardingItemParameters("0=A,1=B,2=C").build(), TestDataflowJob.class.getCanonicalName(), true)).monitorExecution(false).build());
Map<Integer, String> map = new HashMap<>(3);
map.put(0, "A");
map.put(1, "B");
ShardingContexts expected = new ShardingContexts("fake_task_id", "test_job", 3, "", map);
assertShardingContext(executionContextService.getJobShardingContext(Arrays.asList(0, 1)), expected);
verify(configService).load(false);
}
use of com.dangdang.ddframe.job.config.dataflow.DataflowJobConfiguration in project elastic-job by dangdangdotcom.
the class ExecutionContextServiceTest method assertGetShardingContextWhenHasRunningItems.
@Test
public void assertGetShardingContextWhenHasRunningItems() {
when(configService.load(false)).thenReturn(LiteJobConfiguration.newBuilder(new DataflowJobConfiguration(JobCoreConfiguration.newBuilder("test_job", "0/1 * * * * ?", 3).shardingItemParameters("0=A,1=B,2=C").build(), TestDataflowJob.class.getCanonicalName(), true)).monitorExecution(true).build());
when(jobNodeStorage.isJobNodeExisted("execution/0/running")).thenReturn(false);
when(jobNodeStorage.isJobNodeExisted("execution/1/running")).thenReturn(true);
Map<Integer, String> map = new HashMap<>(1, 1);
map.put(0, "A");
ShardingContexts expected = new ShardingContexts("fake_task_id", "test_job", 3, "", map);
assertShardingContext(executionContextService.getJobShardingContext(Lists.newArrayList(0, 1)), expected);
verify(configService).load(false);
verify(jobNodeStorage).isJobNodeExisted("execution/0/running");
verify(jobNodeStorage).isJobNodeExisted("execution/1/running");
}
use of com.dangdang.ddframe.job.config.dataflow.DataflowJobConfiguration in project elastic-job by dangdangdotcom.
the class LiteJobConfigurationGsonFactoryTest method assertToJsonForDataflowJob.
@Test
public void assertToJsonForDataflowJob() {
LiteJobConfiguration actual = LiteJobConfiguration.newBuilder(new DataflowJobConfiguration(JobCoreConfiguration.newBuilder("test_job", "0/1 * * * * ?", 3).build(), TestDataflowJob.class.getCanonicalName(), true)).build();
assertThat(LiteJobConfigurationGsonFactory.toJson(actual), is(dataflowJobJson));
}
use of com.dangdang.ddframe.job.config.dataflow.DataflowJobConfiguration in project elastic-job by dangdangdotcom.
the class SchedulerFacadeTest method assertRegisterStartUpInfo.
@Test
public void assertRegisterStartUpInfo() {
when(configService.load(false)).thenReturn(LiteJobConfiguration.newBuilder(new DataflowJobConfiguration(JobCoreConfiguration.newBuilder("test_job", "0/1 * * * * ?", 3).build(), TestDataflowJob.class.getCanonicalName(), false)).build());
schedulerFacade.registerStartUpInfo(liteJobConfig);
verify(listenerManager).startAllListeners();
verify(leaderElectionService).leaderForceElection();
verify(configService).persist(liteJobConfig);
verify(serverService).persistServerOnline(true);
verify(serverService).clearJobPausedStatus();
verify(shardingService).setReshardingFlag();
verify(monitorService).listen();
verify(configService).load(false);
verify(listenerManager).setCurrentShardingTotalCount(3);
}
use of com.dangdang.ddframe.job.config.dataflow.DataflowJobConfiguration in project elastic-job by dangdangdotcom.
the class LiteJobFacadeTest method assertEligibleForJobRunningWhenNotJobPausedManuallyAndNotNeedShardingAndStreamingProcess.
@Test
public void assertEligibleForJobRunningWhenNotJobPausedManuallyAndNotNeedShardingAndStreamingProcess() {
when(serverService.isJobPausedManually()).thenReturn(false);
when(shardingService.isNeedSharding()).thenReturn(false);
when(configService.load(true)).thenReturn(LiteJobConfiguration.newBuilder(new DataflowJobConfiguration(JobCoreConfiguration.newBuilder("test_job", "0/1 * * * * ?", 3).build(), TestDataflowJob.class.getCanonicalName(), true)).build());
assertThat(liteJobFacade.isEligibleForJobRunning(), is(true));
verify(serverService).isJobPausedManually();
verify(shardingService).isNeedSharding();
verify(configService).load(true);
}
Aggregations