use of com.dangdang.ddframe.job.config.script.ScriptJobConfiguration 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.script.ScriptJobConfiguration 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.script.ScriptJobConfiguration in project elastic-job by dangdangdotcom.
the class LiteJobConfigurationGsonFactoryTest method assertToJsonForScriptJob.
@Test
public void assertToJsonForScriptJob() {
LiteJobConfiguration actual = LiteJobConfiguration.newBuilder(new ScriptJobConfiguration(JobCoreConfiguration.newBuilder("test_job", "0/1 * * * * ?", 3).build(), "test.sh")).build();
assertThat(LiteJobConfigurationGsonFactory.toJson(actual), is(scriptJobJson));
}
use of com.dangdang.ddframe.job.config.script.ScriptJobConfiguration in project elastic-job by dangdangdotcom.
the class ScriptElasticJobTest method assertJobInit.
@Test
public void assertJobInit() throws IOException {
ScriptElasticJobUtil.buildScriptCommandLine();
WaitingUtils.waitingShortTime();
String scriptCommandLine = ((ScriptJobConfiguration) getLiteJobConfig().getTypeConfig()).getScriptCommandLine();
LiteJobConfiguration liteJobConfig = LiteJobConfigurationGsonFactory.fromJson(getRegCenter().get("/" + getJobName() + "/config"));
assertThat(((ScriptJobConfiguration) liteJobConfig.getTypeConfig()).getScriptCommandLine(), is(scriptCommandLine));
}
use of com.dangdang.ddframe.job.config.script.ScriptJobConfiguration in project elastic-job by dangdangdotcom.
the class JavaMain method setUpScriptJob.
private static void setUpScriptJob(final CoordinatorRegistryCenter regCenter, final JobEventConfiguration jobEventConfig) throws IOException {
JobCoreConfiguration coreConfig = JobCoreConfiguration.newBuilder("scriptElasticJob", "0/5 * * * * ?", 3).build();
ScriptJobConfiguration scriptJobConfig = new ScriptJobConfiguration(coreConfig, buildScriptCommandLine());
new JobScheduler(regCenter, LiteJobConfiguration.newBuilder(scriptJobConfig).build(), jobEventConfig).init();
}
Aggregations