Search in sources :

Example 26 with LiteJobConfiguration

use of com.dangdang.ddframe.job.lite.config.LiteJobConfiguration in project elastic-job by dangdangdotcom.

the class LiteJobConfigurationGsonFactoryTest method assertToJsonForSimpleJob.

@Test
public void assertToJsonForSimpleJob() {
    LiteJobConfiguration actual = LiteJobConfiguration.newBuilder(new SimpleJobConfiguration(JobCoreConfiguration.newBuilder("test_job", "0/1 * * * * ?", 3).failover(true).misfire(false).build(), TestSimpleJob.class.getCanonicalName())).monitorExecution(false).maxTimeDiffSeconds(1000).monitorPort(8888).jobShardingStrategyClass("testClass").disabled(true).overwrite(true).reconcileIntervalMinutes(15).build();
    assertThat(LiteJobConfigurationGsonFactory.toJson(actual), is(simpleJobJson));
}
Also used : LiteJobConfiguration(com.dangdang.ddframe.job.lite.config.LiteJobConfiguration) SimpleJobConfiguration(com.dangdang.ddframe.job.config.simple.SimpleJobConfiguration) Test(org.junit.Test)

Example 27 with LiteJobConfiguration

use of com.dangdang.ddframe.job.lite.config.LiteJobConfiguration in project elastic-job by dangdangdotcom.

the class LiteJobConfigurationGsonFactoryTest method assertToJsonForDataflowJob.

@Test
public void assertToJsonForDataflowJob() {
    LiteJobConfiguration actual = LiteJobConfiguration.newBuilder(new DataflowJobConfiguration(JobCoreConfiguration.newBuilder("test_job", "0/1 * * * * ?", 3).build(), TestDataflowJob.class.getCanonicalName(), true)).build();
    assertThat(LiteJobConfigurationGsonFactory.toJson(actual), is(dataflowJobJson));
}
Also used : LiteJobConfiguration(com.dangdang.ddframe.job.lite.config.LiteJobConfiguration) DataflowJobConfiguration(com.dangdang.ddframe.job.config.dataflow.DataflowJobConfiguration) TestDataflowJob(com.dangdang.ddframe.job.lite.fixture.TestDataflowJob) Test(org.junit.Test)

Example 28 with LiteJobConfiguration

use of com.dangdang.ddframe.job.lite.config.LiteJobConfiguration in project elastic-job by dangdangdotcom.

the class SchedulerFacadeTest method assertLoadJobConfiguration.

@Test
public void assertLoadJobConfiguration() {
    LiteJobConfiguration expected = LiteJobConfiguration.newBuilder(null).build();
    when(configService.load(false)).thenReturn(expected);
    assertThat(schedulerFacade.loadJobConfiguration(), is(expected));
}
Also used : LiteJobConfiguration(com.dangdang.ddframe.job.lite.config.LiteJobConfiguration) Test(org.junit.Test)

Example 29 with LiteJobConfiguration

use of com.dangdang.ddframe.job.lite.config.LiteJobConfiguration in project LinkAgent by shulieTech.

the class ElasticJobConfig method createJobConfiguration.

public static LiteJobConfiguration createJobConfiguration(final Class<? extends SimpleJob> jobClass, final String cron, final int shardingTotalCount, final String shardingItemParameters) {
    // JobCoreConfigurationBuilder
    JobCoreConfiguration.Builder JobCoreConfigurationBuilder = JobCoreConfiguration.newBuilder(jobClass.getName(), cron, shardingTotalCount);
    // 设置shardingItemParameters
    if (!StringUtils.isEmpty(shardingItemParameters)) {
        JobCoreConfigurationBuilder.shardingItemParameters(shardingItemParameters);
    }
    JobCoreConfiguration jobCoreConfiguration = JobCoreConfigurationBuilder.build();
    // 创建SimpleJobConfiguration
    SimpleJobConfiguration simpleJobConfiguration = new SimpleJobConfiguration(jobCoreConfiguration, jobClass.getCanonicalName());
    // 设置dump端口
    // 创建LiteJobConfiguration
    LiteJobConfiguration liteJobConfiguration = LiteJobConfiguration.newBuilder(simpleJobConfiguration).overwrite(true).build();
    return liteJobConfiguration;
}
Also used : LiteJobConfiguration(com.dangdang.ddframe.job.lite.config.LiteJobConfiguration) JobCoreConfiguration(com.dangdang.ddframe.job.config.JobCoreConfiguration) SimpleJobConfiguration(com.dangdang.ddframe.job.config.simple.SimpleJobConfiguration)

Example 30 with LiteJobConfiguration

use of com.dangdang.ddframe.job.lite.config.LiteJobConfiguration in project LinkAgent by shulieTech.

the class ElasticJobConfig method createFlowJobConfiguration.

/**
 * 创建支持dataFlow类型的作业的配置信息
 *
 * @param jobClass
 * @param cron
 * @param shardingTotalCount
 * @param shardingItemParameters
 * @return
 */
public static LiteJobConfiguration createFlowJobConfiguration(final Class<? extends ElasticJob> jobClass, final String cron, final int shardingTotalCount, final String shardingItemParameters) {
    // JobCoreConfigurationBuilder
    JobCoreConfiguration.Builder JobCoreConfigurationBuilder = JobCoreConfiguration.newBuilder(jobClass.getName(), cron, shardingTotalCount);
    // 设置shardingItemParameters
    if (!StringUtils.isEmpty(shardingItemParameters)) {
        JobCoreConfigurationBuilder.shardingItemParameters(shardingItemParameters);
    }
    JobCoreConfiguration jobCoreConfiguration = JobCoreConfigurationBuilder.build();
    // 定义数据流类型任务配置
    DataflowJobConfiguration jobConfig = new DataflowJobConfiguration(jobCoreConfiguration, jobClass.getCanonicalName(), true);
    // 创建LiteJobConfiguration
    LiteJobConfiguration liteJobConfiguration = LiteJobConfiguration.newBuilder(jobConfig).overwrite(true).build();
    return liteJobConfiguration;
}
Also used : LiteJobConfiguration(com.dangdang.ddframe.job.lite.config.LiteJobConfiguration) JobCoreConfiguration(com.dangdang.ddframe.job.config.JobCoreConfiguration) DataflowJobConfiguration(com.dangdang.ddframe.job.config.dataflow.DataflowJobConfiguration)

Aggregations

LiteJobConfiguration (com.dangdang.ddframe.job.lite.config.LiteJobConfiguration)32 Test (org.junit.Test)14 JobCoreConfiguration (com.dangdang.ddframe.job.config.JobCoreConfiguration)7 SimpleJobConfiguration (com.dangdang.ddframe.job.config.simple.SimpleJobConfiguration)6 SpringJobScheduler (com.dangdang.ddframe.job.lite.spring.api.SpringJobScheduler)5 ElasticJob (com.dangdang.ddframe.job.api.ElasticJob)4 JobTypeConfiguration (com.dangdang.ddframe.job.config.JobTypeConfiguration)4 SimpleJob (com.dangdang.ddframe.job.api.simple.SimpleJob)3 DataflowJobConfiguration (com.dangdang.ddframe.job.config.dataflow.DataflowJobConfiguration)3 JobEventRdbConfiguration (com.dangdang.ddframe.job.event.rdb.JobEventRdbConfiguration)3 ElasticJobListener (com.dangdang.ddframe.job.lite.api.listener.ElasticJobListener)3 ScriptJobConfiguration (com.dangdang.ddframe.job.config.script.ScriptJobConfiguration)2 JobNodePath (com.dangdang.ddframe.job.lite.internal.storage.JobNodePath)2 ElasticSimpleJob (com.dangdang.elasticjob.lite.annotation.ElasticSimpleJob)2 PtElasticJobSimpleJob (com.pamirs.attach.plugin.shadowjob.obj.PtElasticJobSimpleJob)2 Map (java.util.Map)2 DataSource (javax.sql.DataSource)2 BeanDefinitionBuilder (org.springframework.beans.factory.support.BeanDefinitionBuilder)2 DefaultListableBeanFactory (org.springframework.beans.factory.support.DefaultListableBeanFactory)2 DataflowJob (com.dangdang.ddframe.job.api.dataflow.DataflowJob)1