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();
}
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();
}
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);
}
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();
}
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();
}
Aggregations