Search in sources :

Example 6 with DataflowJobConfiguration

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);
}
Also used : ElasticJobListener(com.dangdang.ddframe.job.lite.api.listener.ElasticJobListener) DataflowJobConfiguration(com.dangdang.ddframe.job.config.dataflow.DataflowJobConfiguration) Before(org.junit.Before)

Example 7 with DataflowJobConfiguration

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());
}
Also used : DataflowJobConfiguration(com.dangdang.ddframe.job.config.dataflow.DataflowJobConfiguration) Test(org.junit.Test)

Example 8 with DataflowJobConfiguration

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);
}
Also used : ShardingContexts(com.dangdang.ddframe.job.executor.ShardingContexts) DataflowJobConfiguration(com.dangdang.ddframe.job.config.dataflow.DataflowJobConfiguration) TestDataflowJob(com.dangdang.ddframe.job.lite.fixture.TestDataflowJob) Test(org.junit.Test)

Example 9 with DataflowJobConfiguration

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();
}
Also used : JobScheduler(com.dangdang.ddframe.job.lite.api.JobScheduler) JobCoreConfiguration(com.dangdang.ddframe.job.config.JobCoreConfiguration) DataflowJobConfiguration(com.dangdang.ddframe.job.config.dataflow.DataflowJobConfiguration) JavaDataflowJob(com.dangdang.ddframe.job.example.job.dataflow.JavaDataflowJob)

Example 10 with DataflowJobConfiguration

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;
}
Also used : SimpleJobConfiguration(com.dangdang.ddframe.job.config.simple.SimpleJobConfiguration) DataflowJobConfiguration(com.dangdang.ddframe.job.config.dataflow.DataflowJobConfiguration) ScriptJobConfiguration(com.dangdang.ddframe.job.config.script.ScriptJobConfiguration) JobTypeConfiguration(com.dangdang.ddframe.job.config.JobTypeConfiguration)

Aggregations

DataflowJobConfiguration (com.dangdang.ddframe.job.config.dataflow.DataflowJobConfiguration)15 Test (org.junit.Test)10 TestDataflowJob (com.dangdang.ddframe.job.lite.fixture.TestDataflowJob)4 ScriptJobConfiguration (com.dangdang.ddframe.job.config.script.ScriptJobConfiguration)3 ShardingContexts (com.dangdang.ddframe.job.executor.ShardingContexts)3 JobCoreConfiguration (com.dangdang.ddframe.job.config.JobCoreConfiguration)2 JobTypeConfiguration (com.dangdang.ddframe.job.config.JobTypeConfiguration)2 SimpleJobConfiguration (com.dangdang.ddframe.job.config.simple.SimpleJobConfiguration)2 HashMap (java.util.HashMap)2 ScriptJob (com.dangdang.ddframe.job.api.script.ScriptJob)1 JavaDataflowJob (com.dangdang.ddframe.job.example.job.dataflow.JavaDataflowJob)1 JobScheduler (com.dangdang.ddframe.job.lite.api.JobScheduler)1 ElasticJobListener (com.dangdang.ddframe.job.lite.api.listener.ElasticJobListener)1 LiteJobConfiguration (com.dangdang.ddframe.job.lite.config.LiteJobConfiguration)1 Before (org.junit.Before)1