use of com.dangdang.ddframe.job.lite.config.LiteJobConfiguration in project elastic-job by dangdangdotcom.
the class LiteJobConfigurationGsonFactoryTest method assertFromJsonForDataflowJob.
@Test
public void assertFromJsonForDataflowJob() {
LiteJobConfiguration actual = LiteJobConfigurationGsonFactory.fromJson(dataflowJobJson);
assertThat(actual.getJobName(), is("test_job"));
assertThat(actual.getTypeConfig().getJobClass(), is(TestDataflowJob.class.getCanonicalName()));
assertThat(actual.getTypeConfig().getJobType(), is(JobType.DATAFLOW));
assertThat(actual.getTypeConfig().getCoreConfig().getCron(), is("0/1 * * * * ?"));
assertThat(actual.getTypeConfig().getCoreConfig().getShardingTotalCount(), is(3));
assertThat(actual.getTypeConfig().getCoreConfig().getShardingItemParameters(), is(""));
assertThat(actual.getTypeConfig().getCoreConfig().getJobParameter(), is(""));
assertFalse(actual.getTypeConfig().getCoreConfig().isFailover());
assertTrue(actual.getTypeConfig().getCoreConfig().isMisfire());
assertThat(actual.getTypeConfig().getCoreConfig().getDescription(), is(""));
assertThat(actual.getTypeConfig().getCoreConfig().getJobProperties().get(JobProperties.JobPropertiesEnum.JOB_EXCEPTION_HANDLER), is(DefaultJobExceptionHandler.class.getCanonicalName()));
assertThat(actual.getTypeConfig().getCoreConfig().getJobProperties().get(JobProperties.JobPropertiesEnum.EXECUTOR_SERVICE_HANDLER), is(DefaultExecutorServiceHandler.class.getCanonicalName()));
assertTrue(actual.isMonitorExecution());
assertThat(actual.getMaxTimeDiffSeconds(), is(-1));
assertThat(actual.getMonitorPort(), is(-1));
assertThat(actual.getJobShardingStrategyClass(), is(""));
assertFalse(actual.isDisabled());
assertFalse(actual.isOverwrite());
assertThat(actual.getReconcileIntervalMinutes(), is(-1));
assertTrue(((DataflowJobConfiguration) actual.getTypeConfig()).isStreamingProcess());
}
use of com.dangdang.ddframe.job.lite.config.LiteJobConfiguration in project elastic-job by dangdangdotcom.
the class JobStatisticsAPIImpl method getJobBriefInfo.
@Override
public JobBriefInfo getJobBriefInfo(final String jobName) {
JobNodePath jobNodePath = new JobNodePath(jobName);
JobBriefInfo result = new JobBriefInfo();
result.setJobName(jobName);
String liteJobConfigJson = regCenter.get(jobNodePath.getConfigNodePath());
if (null == liteJobConfigJson) {
return null;
}
LiteJobConfiguration liteJobConfig = LiteJobConfigurationGsonFactory.fromJson(liteJobConfigJson);
result.setJobType(liteJobConfig.getTypeConfig().getJobType().name());
result.setDescription(liteJobConfig.getTypeConfig().getCoreConfig().getDescription());
result.setStatus(getJobStatus(jobName));
result.setCron(liteJobConfig.getTypeConfig().getCoreConfig().getCron());
return result;
}
use of com.dangdang.ddframe.job.lite.config.LiteJobConfiguration in project elastic-job by dangdangdotcom.
the class ReconcileService method runOneIteration.
@Override
protected void runOneIteration() throws Exception {
LiteJobConfiguration config = configService.load(true);
int reconcileIntervalMinutes = null == config || config.getReconcileIntervalMinutes() <= 0 ? -1 : config.getReconcileIntervalMinutes();
if (reconcileIntervalMinutes > 0 && (System.currentTimeMillis() - lastReconcileTime >= reconcileIntervalMinutes * 60 * 1000)) {
lastReconcileTime = System.currentTimeMillis();
if (leaderElectionService.isLeader() && !shardingService.isNeedSharding() && shardingService.hasNotRunningShardingNode()) {
log.warn("Elastic Job: job status node has inconsistent value,start reconciling...");
shardingService.setReshardingFlag();
}
}
}
use of com.dangdang.ddframe.job.lite.config.LiteJobConfiguration 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.lite.config.LiteJobConfiguration in project elastic-job by dangdangdotcom.
the class ConfigurationServiceTest method assertPersistExistedJobConfiguration.
@Test
public void assertPersistExistedJobConfiguration() throws NoSuchFieldException {
when(jobNodeStorage.isJobNodeExisted(ConfigurationNode.ROOT)).thenReturn(true);
when(jobNodeStorage.getJobNodeDataDirectly(ConfigurationNode.ROOT)).thenReturn(LiteJsonConstants.getJobJson());
LiteJobConfiguration liteJobConfig = JobConfigurationUtil.createSimpleLiteJobConfiguration(true);
configService.persist(liteJobConfig);
verify(jobNodeStorage).replaceJobNode("config", LiteJobConfigurationGsonFactory.toJson(liteJobConfig));
}
Aggregations