use of com.dangdang.ddframe.job.config.dataflow.DataflowJobConfiguration in project elastic-job by dangdangdotcom.
the class SchedulerFacadeTest method setUp.
@Before
public void setUp() throws NoSuchFieldException {
MockitoAnnotations.initMocks(this);
schedulerFacade = new SchedulerFacade(null, "test_job", Collections.<ElasticJobListener>emptyList());
when(configService.load(true)).thenReturn(LiteJobConfiguration.newBuilder(new DataflowJobConfiguration(JobCoreConfiguration.newBuilder("test_job", "0/1 * * * * ?", 3).build(), TestDataflowJob.class.getCanonicalName(), false)).build());
ReflectionUtils.setFieldValue(schedulerFacade, "configService", configService);
ReflectionUtils.setFieldValue(schedulerFacade, "leaderElectionService", leaderElectionService);
ReflectionUtils.setFieldValue(schedulerFacade, "serverService", serverService);
ReflectionUtils.setFieldValue(schedulerFacade, "shardingService", shardingService);
ReflectionUtils.setFieldValue(schedulerFacade, "executionService", executionService);
ReflectionUtils.setFieldValue(schedulerFacade, "monitorService", monitorService);
ReflectionUtils.setFieldValue(schedulerFacade, "listenerManager", listenerManager);
}
use of com.dangdang.ddframe.job.config.dataflow.DataflowJobConfiguration in project elastic-job by dangdangdotcom.
the class GuaranteeServiceTest method assertIsNotAllStarted.
@Test
public void assertIsNotAllStarted() {
when(configService.load(false)).thenReturn(LiteJobConfiguration.newBuilder(new DataflowJobConfiguration(JobCoreConfiguration.newBuilder("test_job", "0/1 * * * * ?", 3).build(), TestDataflowJob.class.getCanonicalName(), true)).build());
when(jobNodeStorage.isJobNodeExisted("guarantee/started")).thenReturn(true);
when(jobNodeStorage.getJobNodeChildrenKeys("guarantee/started")).thenReturn(Arrays.asList("0", "1"));
assertFalse(guaranteeService.isAllStarted());
}
use of com.dangdang.ddframe.job.config.dataflow.DataflowJobConfiguration 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.config.dataflow.DataflowJobConfiguration in project elastic-job by dangdangdotcom.
the class JavaMain method setUpDataflowJob.
private static void setUpDataflowJob(final CoordinatorRegistryCenter regCenter, final JobEventConfiguration jobEventConfig) {
JobCoreConfiguration coreConfig = JobCoreConfiguration.newBuilder("javaDataflowElasticJob", "0/5 * * * * ?", 3).shardingItemParameters("0=Beijing,1=Shanghai,2=Guangzhou").build();
DataflowJobConfiguration dataflowJobConfig = new DataflowJobConfiguration(coreConfig, JavaDataflowJob.class.getCanonicalName(), true);
new JobScheduler(regCenter, LiteJobConfiguration.newBuilder(dataflowJobConfig).build(), jobEventConfig).init();
}
use of com.dangdang.ddframe.job.config.dataflow.DataflowJobConfiguration in project elastic-job by dangdangdotcom.
the class AbstractJobConfigurationGsonTypeAdapter method getJobTypeConfiguration.
private JobTypeConfiguration getJobTypeConfiguration(final JobCoreConfiguration coreConfig, final JobType jobType, final String jobClass, final boolean streamingProcess, final String scriptCommandLine) {
JobTypeConfiguration result;
Preconditions.checkNotNull(jobType, "jobType cannot be null.");
switch(jobType) {
case SIMPLE:
Preconditions.checkArgument(!Strings.isNullOrEmpty(jobClass), "jobClass cannot be empty.");
result = new SimpleJobConfiguration(coreConfig, jobClass);
break;
case DATAFLOW:
Preconditions.checkArgument(!Strings.isNullOrEmpty(jobClass), "jobClass cannot be empty.");
result = new DataflowJobConfiguration(coreConfig, jobClass, streamingProcess);
break;
case SCRIPT:
result = new ScriptJobConfiguration(coreConfig, scriptCommandLine);
break;
default:
throw new UnsupportedOperationException(jobType.name());
}
return result;
}
Aggregations