Search in sources :

Example 11 with LiteJobConfiguration

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

Example 12 with LiteJobConfiguration

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;
}
Also used : LiteJobConfiguration(com.dangdang.ddframe.job.lite.config.LiteJobConfiguration) JobBriefInfo(com.dangdang.ddframe.job.lite.lifecycle.domain.JobBriefInfo) JobNodePath(com.dangdang.ddframe.job.lite.internal.storage.JobNodePath)

Example 13 with LiteJobConfiguration

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();
        }
    }
}
Also used : LiteJobConfiguration(com.dangdang.ddframe.job.lite.config.LiteJobConfiguration)

Example 14 with LiteJobConfiguration

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));
}
Also used : LiteJobConfiguration(com.dangdang.ddframe.job.lite.config.LiteJobConfiguration) ScriptJobConfiguration(com.dangdang.ddframe.job.config.script.ScriptJobConfiguration) AbstractBaseStdJobAutoInitTest(com.dangdang.ddframe.job.lite.integrate.AbstractBaseStdJobAutoInitTest) Test(org.junit.Test)

Example 15 with LiteJobConfiguration

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

Aggregations

LiteJobConfiguration (com.dangdang.ddframe.job.lite.config.LiteJobConfiguration)20 Test (org.junit.Test)14 ScriptJobConfiguration (com.dangdang.ddframe.job.config.script.ScriptJobConfiguration)2 JobNodePath (com.dangdang.ddframe.job.lite.internal.storage.JobNodePath)2 DataflowJobConfiguration (com.dangdang.ddframe.job.config.dataflow.DataflowJobConfiguration)1 SimpleJobConfiguration (com.dangdang.ddframe.job.config.simple.SimpleJobConfiguration)1 ShardingContexts (com.dangdang.ddframe.job.executor.ShardingContexts)1 JobShardingStrategy (com.dangdang.ddframe.job.lite.api.strategy.JobShardingStrategy)1 JobShardingStrategyOption (com.dangdang.ddframe.job.lite.api.strategy.JobShardingStrategyOption)1 TestDataflowJob (com.dangdang.ddframe.job.lite.fixture.TestDataflowJob)1 AbstractBaseStdJobAutoInitTest (com.dangdang.ddframe.job.lite.integrate.AbstractBaseStdJobAutoInitTest)1 JobBriefInfo (com.dangdang.ddframe.job.lite.lifecycle.domain.JobBriefInfo)1 JobSettings (com.dangdang.ddframe.job.lite.lifecycle.domain.JobSettings)1 ShardingItemParameters (com.dangdang.ddframe.job.util.config.ShardingItemParameters)1