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));
}
}
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();
}
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));
}
}
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);
}
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;
}
}
Aggregations