Search in sources :

Example 1 with JobSettings

use of com.dangdang.ddframe.job.lite.lifecycle.domain.JobSettings in project elastic-job by dangdangdotcom.

the class JobSettingsAPIImplTest method assertGetScriptJobSettings.

@Test
public void assertGetScriptJobSettings() {
    when(regCenter.get("/test_job/config")).thenReturn(LifecycleJsonConstants.getScriptJobJson());
    JobSettings actual = jobSettingsAPI.getJobSettings("test_job");
    assertJobSettings(actual, "SCRIPT", "com.dangdang.ddframe.job.api.script.ScriptJob");
    verify(regCenter).get("/test_job/config");
}
Also used : JobSettings(com.dangdang.ddframe.job.lite.lifecycle.domain.JobSettings) Test(org.junit.Test)

Example 2 with JobSettings

use of com.dangdang.ddframe.job.lite.lifecycle.domain.JobSettings in project elastic-job by dangdangdotcom.

the class JobSettingsAPIImplTest method assertUpdateJobSettings.

@Test
public void assertUpdateJobSettings() {
    when(regCenter.get("/test_job/config")).thenReturn(LifecycleJsonConstants.getDataflowJobJson());
    JobSettings jobSettings = new JobSettings();
    jobSettings.setJobName("test_job");
    jobSettings.setJobClass("com.dangdang.ddframe.job.lite.fixture.TestDataflowJob");
    jobSettings.setShardingTotalCount(10);
    jobSettings.setMaxTimeDiffSeconds(-1);
    jobSettings.setMonitorExecution(true);
    jobSettings.setCron("0/1 * * * * ?");
    jobSettings.setStreamingProcess(true);
    jobSettings.setFailover(false);
    jobSettings.setMisfire(true);
    jobSettings.getJobProperties().put(JobPropertiesEnum.EXECUTOR_SERVICE_HANDLER.getKey(), DefaultExecutorServiceHandler.class.getCanonicalName());
    jobSettings.getJobProperties().put(JobPropertiesEnum.JOB_EXCEPTION_HANDLER.getKey(), DefaultJobExceptionHandler.class.getCanonicalName());
    jobSettings.setReconcileIntervalMinutes(70);
    jobSettingsAPI.updateJobSettings(jobSettings);
    verify(regCenter).update("/test_job/config", "{\"jobName\":\"test_job\",\"jobClass\":\"com.dangdang.ddframe.job.lite.fixture.TestDataflowJob\"," + "\"cron\":\"0/1 * * * * ?\",\"shardingTotalCount\":10,\"monitorExecution\":true,\"streamingProcess\":true," + "\"maxTimeDiffSeconds\":-1,\"monitorPort\":-1,\"failover\":false,\"misfire\":true," + "\"jobProperties\":{\"executor_service_handler\":\"" + DefaultExecutorServiceHandler.class.getCanonicalName() + "\"," + "\"job_exception_handler\":\"" + DefaultJobExceptionHandler.class.getCanonicalName() + "\"},\"reconcileIntervalMinutes\":70}");
}
Also used : JobSettings(com.dangdang.ddframe.job.lite.lifecycle.domain.JobSettings) DefaultJobExceptionHandler(com.dangdang.ddframe.job.executor.handler.impl.DefaultJobExceptionHandler) DefaultExecutorServiceHandler(com.dangdang.ddframe.job.executor.handler.impl.DefaultExecutorServiceHandler) Test(org.junit.Test)

Example 3 with JobSettings

use of com.dangdang.ddframe.job.lite.lifecycle.domain.JobSettings in project elastic-job by dangdangdotcom.

the class JobSettingsAPIImpl method getJobSettings.

@Override
public JobSettings getJobSettings(final String jobName) {
    JobSettings result = new JobSettings();
    JobNodePath jobNodePath = new JobNodePath(jobName);
    LiteJobConfiguration liteJobConfig = LiteJobConfigurationGsonFactory.fromJson(regCenter.get(jobNodePath.getConfigNodePath()));
    String jobType = liteJobConfig.getTypeConfig().getJobType().name();
    buildSimpleJobSettings(jobName, result, liteJobConfig);
    if (JobType.DATAFLOW.name().equals(jobType)) {
        buildDataflowJobSettings(result, (DataflowJobConfiguration) liteJobConfig.getTypeConfig());
    }
    if (JobType.SCRIPT.name().equals(jobType)) {
        buildScriptJobSettings(result, (ScriptJobConfiguration) liteJobConfig.getTypeConfig());
    }
    return result;
}
Also used : JobSettings(com.dangdang.ddframe.job.lite.lifecycle.domain.JobSettings) LiteJobConfiguration(com.dangdang.ddframe.job.lite.config.LiteJobConfiguration) JobNodePath(com.dangdang.ddframe.job.lite.internal.storage.JobNodePath)

Example 4 with JobSettings

use of com.dangdang.ddframe.job.lite.lifecycle.domain.JobSettings in project elastic-job by dangdangdotcom.

the class JobSettingsAPIImplTest method assertGetDataflowJobSettings.

@Test
public void assertGetDataflowJobSettings() {
    when(regCenter.get("/test_job/config")).thenReturn(LifecycleJsonConstants.getDataflowJobJson());
    JobSettings actual = jobSettingsAPI.getJobSettings("test_job");
    assertJobSettings(actual, "DATAFLOW", "com.dangdang.ddframe.job.lite.fixture.TestDataflowJob");
    verify(regCenter).get("/test_job/config");
}
Also used : JobSettings(com.dangdang.ddframe.job.lite.lifecycle.domain.JobSettings) Test(org.junit.Test)

Aggregations

JobSettings (com.dangdang.ddframe.job.lite.lifecycle.domain.JobSettings)4 Test (org.junit.Test)3 DefaultExecutorServiceHandler (com.dangdang.ddframe.job.executor.handler.impl.DefaultExecutorServiceHandler)1 DefaultJobExceptionHandler (com.dangdang.ddframe.job.executor.handler.impl.DefaultJobExceptionHandler)1 LiteJobConfiguration (com.dangdang.ddframe.job.lite.config.LiteJobConfiguration)1 JobNodePath (com.dangdang.ddframe.job.lite.internal.storage.JobNodePath)1