Search in sources :

Example 1 with DataflowJobConfiguration

use of com.dangdang.ddframe.job.config.dataflow.DataflowJobConfiguration in project elastic-job by dangdangdotcom.

the class AbstractJobConfigurationGsonTypeAdapter method write.

@Override
public void write(final JsonWriter out, final T value) throws IOException {
    out.beginObject();
    out.name("jobName").value(value.getTypeConfig().getCoreConfig().getJobName());
    out.name("jobClass").value(value.getTypeConfig().getJobClass());
    out.name("jobType").value(value.getTypeConfig().getJobType().name());
    out.name("cron").value(value.getTypeConfig().getCoreConfig().getCron());
    out.name("shardingTotalCount").value(value.getTypeConfig().getCoreConfig().getShardingTotalCount());
    out.name("shardingItemParameters").value(value.getTypeConfig().getCoreConfig().getShardingItemParameters());
    out.name("jobParameter").value(value.getTypeConfig().getCoreConfig().getJobParameter());
    out.name("failover").value(value.getTypeConfig().getCoreConfig().isFailover());
    out.name("misfire").value(value.getTypeConfig().getCoreConfig().isMisfire());
    out.name("description").value(value.getTypeConfig().getCoreConfig().getDescription());
    out.name("jobProperties").jsonValue(value.getTypeConfig().getCoreConfig().getJobProperties().json());
    if (value.getTypeConfig().getJobType() == JobType.DATAFLOW) {
        DataflowJobConfiguration dataflowJobConfig = (DataflowJobConfiguration) value.getTypeConfig();
        out.name("streamingProcess").value(dataflowJobConfig.isStreamingProcess());
    } else if (value.getTypeConfig().getJobType() == JobType.SCRIPT) {
        ScriptJobConfiguration scriptJobConfig = (ScriptJobConfiguration) value.getTypeConfig();
        out.name("scriptCommandLine").value(scriptJobConfig.getScriptCommandLine());
    }
    writeCustomized(out, value);
    out.endObject();
}
Also used : DataflowJobConfiguration(com.dangdang.ddframe.job.config.dataflow.DataflowJobConfiguration) ScriptJobConfiguration(com.dangdang.ddframe.job.config.script.ScriptJobConfiguration)

Example 2 with DataflowJobConfiguration

use of com.dangdang.ddframe.job.config.dataflow.DataflowJobConfiguration in project elastic-job by dangdangdotcom.

the class AbstractBaseStdJobTest method initJobConfig.

private LiteJobConfiguration initJobConfig(final Class<? extends ElasticJob> elasticJobClass) {
    String cron = "0/1 * * * * ?";
    int totalShardingCount = 3;
    String shardingParameters = "0=A,1=B,2=C";
    JobCoreConfiguration jobCoreConfig = JobCoreConfiguration.newBuilder(jobName, cron, totalShardingCount).shardingItemParameters(shardingParameters).jobProperties(JobProperties.JobPropertiesEnum.JOB_EXCEPTION_HANDLER.getKey(), IgnoreJobExceptionHandler.class.getCanonicalName()).build();
    JobTypeConfiguration jobTypeConfig;
    if (DataflowJob.class.isAssignableFrom(elasticJobClass)) {
        jobTypeConfig = new DataflowJobConfiguration(jobCoreConfig, elasticJobClass.getCanonicalName(), false);
    } else if (ScriptJob.class.isAssignableFrom(elasticJobClass)) {
        jobTypeConfig = new ScriptJobConfiguration(jobCoreConfig, AbstractBaseStdJobTest.class.getResource("/script/test.sh").getPath());
    } else {
        jobTypeConfig = new SimpleJobConfiguration(jobCoreConfig, elasticJobClass.getCanonicalName());
    }
    return LiteJobConfiguration.newBuilder(jobTypeConfig).monitorPort(monitorPort).disabled(disabled).overwrite(true).build();
}
Also used : ScriptJob(com.dangdang.ddframe.job.api.script.ScriptJob) JobCoreConfiguration(com.dangdang.ddframe.job.config.JobCoreConfiguration) 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)

Example 3 with DataflowJobConfiguration

use of com.dangdang.ddframe.job.config.dataflow.DataflowJobConfiguration in project elastic-job by dangdangdotcom.

the class LiteJobFacadeTest method assertNotEligibleForJobRunningWhenUnStreamingProcess.

@Test
public void assertNotEligibleForJobRunningWhenUnStreamingProcess() {
    when(configService.load(true)).thenReturn(LiteJobConfiguration.newBuilder(new DataflowJobConfiguration(JobCoreConfiguration.newBuilder("test_job", "0/1 * * * * ?", 3).build(), TestDataflowJob.class.getCanonicalName(), false)).build());
    assertThat(liteJobFacade.isEligibleForJobRunning(), is(false));
    verify(configService).load(true);
}
Also used : DataflowJobConfiguration(com.dangdang.ddframe.job.config.dataflow.DataflowJobConfiguration) Test(org.junit.Test)

Example 4 with DataflowJobConfiguration

use of com.dangdang.ddframe.job.config.dataflow.DataflowJobConfiguration in project elastic-job by dangdangdotcom.

the class LiteJobFacadeTest method assertNotEligibleForJobRunningWhenJobPausedManually.

@Test
public void assertNotEligibleForJobRunningWhenJobPausedManually() {
    when(configService.load(true)).thenReturn(LiteJobConfiguration.newBuilder(new DataflowJobConfiguration(JobCoreConfiguration.newBuilder("test_job", "0/1 * * * * ?", 3).build(), TestDataflowJob.class.getCanonicalName(), true)).build());
    when(serverService.isJobPausedManually()).thenReturn(true);
    assertThat(liteJobFacade.isEligibleForJobRunning(), is(false));
    verify(serverService).isJobPausedManually();
}
Also used : DataflowJobConfiguration(com.dangdang.ddframe.job.config.dataflow.DataflowJobConfiguration) Test(org.junit.Test)

Example 5 with DataflowJobConfiguration

use of com.dangdang.ddframe.job.config.dataflow.DataflowJobConfiguration in project elastic-job by dangdangdotcom.

the class LiteJobFacadeTest method assertNotEligibleForJobRunningWhenNeedSharding.

@Test
public void assertNotEligibleForJobRunningWhenNeedSharding() {
    when(configService.load(true)).thenReturn(LiteJobConfiguration.newBuilder(new DataflowJobConfiguration(JobCoreConfiguration.newBuilder("test_job", "0/1 * * * * ?", 3).build(), TestDataflowJob.class.getCanonicalName(), true)).build());
    when(shardingService.isNeedSharding()).thenReturn(true);
    assertThat(liteJobFacade.isEligibleForJobRunning(), is(false));
    verify(shardingService).isNeedSharding();
}
Also used : DataflowJobConfiguration(com.dangdang.ddframe.job.config.dataflow.DataflowJobConfiguration) Test(org.junit.Test)

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