Search in sources :

Example 1 with JobEventRdbConfiguration

use of com.dangdang.ddframe.job.event.rdb.JobEventRdbConfiguration in project elastic-job by dangdangdotcom.

the class BootstrapEnvironmentTest method assertGetEventTraceRdbConfiguration.

@Test
public void assertGetEventTraceRdbConfiguration() throws NoSuchFieldException {
    Properties properties = new Properties();
    properties.setProperty(EnvironmentArgument.EVENT_TRACE_RDB_DRIVER.getKey(), "org.h2.Driver");
    properties.setProperty(EnvironmentArgument.EVENT_TRACE_RDB_URL.getKey(), "jdbc:h2:mem:job_event_trace");
    properties.setProperty(EnvironmentArgument.EVENT_TRACE_RDB_USERNAME.getKey(), "sa");
    properties.setProperty(EnvironmentArgument.EVENT_TRACE_RDB_PASSWORD.getKey(), "password");
    ReflectionUtils.setFieldValue(bootstrapEnvironment, "properties", properties);
    Optional<JobEventRdbConfiguration> jobEventRdbConfiguration = bootstrapEnvironment.getJobEventRdbConfiguration();
    if (jobEventRdbConfiguration.isPresent()) {
        assertThat(jobEventRdbConfiguration.get().getDataSource(), instanceOf(BasicDataSource.class));
    }
}
Also used : JobEventRdbConfiguration(com.dangdang.ddframe.job.event.rdb.JobEventRdbConfiguration) Properties(java.util.Properties) BasicDataSource(org.apache.commons.dbcp.BasicDataSource) Test(org.junit.Test)

Example 2 with JobEventRdbConfiguration

use of com.dangdang.ddframe.job.event.rdb.JobEventRdbConfiguration in project elastic-job by dangdangdotcom.

the class BootstrapEnvironment method getJobEventRdbConfiguration.

/**
     * 获取作业数据库事件配置.
     *
     * @return 作业数据库事件配置
     */
public Optional<JobEventRdbConfiguration> getJobEventRdbConfiguration() {
    String driver = getValue(EnvironmentArgument.EVENT_TRACE_RDB_DRIVER);
    String url = getValue(EnvironmentArgument.EVENT_TRACE_RDB_URL);
    String username = getValue(EnvironmentArgument.EVENT_TRACE_RDB_USERNAME);
    String password = getValue(EnvironmentArgument.EVENT_TRACE_RDB_PASSWORD);
    if (!Strings.isNullOrEmpty(driver) && !Strings.isNullOrEmpty(url) && !Strings.isNullOrEmpty(username)) {
        BasicDataSource dataSource = new BasicDataSource();
        dataSource.setDriverClassName(driver);
        dataSource.setUrl(url);
        dataSource.setUsername(username);
        dataSource.setPassword(password);
        return Optional.of(new JobEventRdbConfiguration(dataSource));
    }
    return Optional.absent();
}
Also used : JobEventRdbConfiguration(com.dangdang.ddframe.job.event.rdb.JobEventRdbConfiguration) BasicDataSource(org.apache.commons.dbcp.BasicDataSource)

Example 3 with JobEventRdbConfiguration

use of com.dangdang.ddframe.job.event.rdb.JobEventRdbConfiguration in project elastic-job by dangdangdotcom.

the class TaskExecutor method registered.

@Override
public void registered(final ExecutorDriver executorDriver, final Protos.ExecutorInfo executorInfo, final Protos.FrameworkInfo frameworkInfo, final Protos.SlaveInfo slaveInfo) {
    if (!executorInfo.getData().isEmpty()) {
        Map<String, String> data = SerializationUtils.deserialize(executorInfo.getData().toByteArray());
        BasicDataSource dataSource = new BasicDataSource();
        dataSource.setDriverClassName(data.get("event_trace_rdb_driver"));
        dataSource.setUrl(data.get("event_trace_rdb_url"));
        dataSource.setPassword(data.get("event_trace_rdb_password"));
        dataSource.setUsername(data.get("event_trace_rdb_username"));
        jobEventBus = new JobEventBus(new JobEventRdbConfiguration(dataSource));
    }
}
Also used : JobEventBus(com.dangdang.ddframe.job.event.JobEventBus) JobEventRdbConfiguration(com.dangdang.ddframe.job.event.rdb.JobEventRdbConfiguration) BasicDataSource(org.apache.commons.dbcp.BasicDataSource)

Example 4 with JobEventRdbConfiguration

use of com.dangdang.ddframe.job.event.rdb.JobEventRdbConfiguration in project elastic-job by dangdangdotcom.

the class JavaMain method main.

// CHECKSTYLE:OFF
public static void main(final String[] args) throws IOException {
    // CHECKSTYLE:ON
    EmbedZookeeperServer.start(EMBED_ZOOKEEPER_PORT);
    CoordinatorRegistryCenter regCenter = setUpRegistryCenter();
    JobEventConfiguration jobEventConfig = new JobEventRdbConfiguration(setUpEventTraceDataSource());
    setUpSimpleJob(regCenter, jobEventConfig);
    setUpDataflowJob(regCenter, jobEventConfig);
    setUpScriptJob(regCenter, jobEventConfig);
}
Also used : JobEventRdbConfiguration(com.dangdang.ddframe.job.event.rdb.JobEventRdbConfiguration) JobEventConfiguration(com.dangdang.ddframe.job.event.JobEventConfiguration) CoordinatorRegistryCenter(com.dangdang.ddframe.job.reg.base.CoordinatorRegistryCenter)

Example 5 with JobEventRdbConfiguration

use of com.dangdang.ddframe.job.event.rdb.JobEventRdbConfiguration in project elastic-job by dangdangdotcom.

the class CloudJobRestfulApi method init.

/**
     * 初始化.
     * 
     * @param regCenter 注册中心
     * @param producerManager 生产管理器
     */
public static void init(final CoordinatorRegistryCenter regCenter, final ProducerManager producerManager) {
    CloudJobRestfulApi.regCenter = regCenter;
    CloudJobRestfulApi.producerManager = producerManager;
    GsonFactory.registerTypeAdapter(CloudJobConfiguration.class, new CloudJobConfigurationGsonFactory.CloudJobConfigurationGsonTypeAdapter());
    Optional<JobEventRdbConfiguration> jobEventRdbConfig = BootstrapEnvironment.getInstance().getJobEventRdbConfiguration();
    if (jobEventRdbConfig.isPresent()) {
        jobEventRdbSearch = new JobEventRdbSearch(jobEventRdbConfig.get().getDataSource());
    } else {
        jobEventRdbSearch = null;
    }
}
Also used : CloudJobConfigurationGsonFactory(com.dangdang.ddframe.job.cloud.scheduler.config.job.CloudJobConfigurationGsonFactory) JobEventRdbConfiguration(com.dangdang.ddframe.job.event.rdb.JobEventRdbConfiguration) JobEventRdbSearch(com.dangdang.ddframe.job.event.rdb.JobEventRdbSearch)

Aggregations

JobEventRdbConfiguration (com.dangdang.ddframe.job.event.rdb.JobEventRdbConfiguration)6 BasicDataSource (org.apache.commons.dbcp.BasicDataSource)3 JobEventConfiguration (com.dangdang.ddframe.job.event.JobEventConfiguration)2 ElasticJob (com.dangdang.ddframe.job.api.ElasticJob)1 DataflowJob (com.dangdang.ddframe.job.api.dataflow.DataflowJob)1 ScriptJob (com.dangdang.ddframe.job.api.script.ScriptJob)1 SimpleJob (com.dangdang.ddframe.job.api.simple.SimpleJob)1 CloudJobConfigurationGsonFactory (com.dangdang.ddframe.job.cloud.scheduler.config.job.CloudJobConfigurationGsonFactory)1 JobCoreConfiguration (com.dangdang.ddframe.job.config.JobCoreConfiguration)1 DataflowJobConfiguration (com.dangdang.ddframe.job.config.dataflow.DataflowJobConfiguration)1 ScriptJobConfiguration (com.dangdang.ddframe.job.config.script.ScriptJobConfiguration)1 SimpleJobConfiguration (com.dangdang.ddframe.job.config.simple.SimpleJobConfiguration)1 JobEventBus (com.dangdang.ddframe.job.event.JobEventBus)1 JobEventRdbSearch (com.dangdang.ddframe.job.event.rdb.JobEventRdbSearch)1 ElasticJobListener (com.dangdang.ddframe.job.lite.api.listener.ElasticJobListener)1 LiteJobConfiguration (com.dangdang.ddframe.job.lite.config.LiteJobConfiguration)1 SpringJobScheduler (com.dangdang.ddframe.job.lite.spring.api.SpringJobScheduler)1 CoordinatorRegistryCenter (com.dangdang.ddframe.job.reg.base.CoordinatorRegistryCenter)1 ZookeeperConfiguration (com.dangdang.ddframe.job.reg.zookeeper.ZookeeperConfiguration)1 ZookeeperRegistryCenter (com.dangdang.ddframe.job.reg.zookeeper.ZookeeperRegistryCenter)1