use of io.shardingjdbc.orchestration.internal.OrchestrationFacade in project sharding-jdbc by shardingjdbc.
the class OrchestrationShardingDataSourceFactory method createDataSource.
/**
* Create sharding data source.
*
* @param dataSourceMap data source map
* @param yamlShardingRuleConfig yaml sharding rule configuration
* @param orchestrationConfig orchestration configuration
* @return sharding data source
* @throws SQLException SQL exception
*/
public static DataSource createDataSource(final Map<String, DataSource> dataSourceMap, final YamlShardingRuleConfiguration yamlShardingRuleConfig, final OrchestrationConfiguration orchestrationConfig) throws SQLException {
OrchestrationFacade orchestrationFacade = new OrchestrationFacade(orchestrationConfig);
if (null == yamlShardingRuleConfig) {
ConfigurationService configService = orchestrationFacade.getConfigService();
final ShardingRuleConfiguration cloudShardingRuleConfig = configService.loadShardingRuleConfiguration();
Preconditions.checkState(null != cloudShardingRuleConfig, "Missing the sharding rule configuration on register center");
return createDataSource(configService.loadDataSourceMap(), cloudShardingRuleConfig, configService.loadShardingConfigMap(), configService.loadShardingProperties(), orchestrationFacade);
} else {
return createDataSource(dataSourceMap, yamlShardingRuleConfig.getShardingRuleConfiguration(), yamlShardingRuleConfig.getConfigMap(), yamlShardingRuleConfig.getProps(), orchestrationFacade);
}
}
use of io.shardingjdbc.orchestration.internal.OrchestrationFacade in project sharding-jdbc by shardingjdbc.
the class OrchestrationShardingDataSourceFactory method createDataSource.
/**
* Create sharding data source.
*
* @param dataSourceMap data source map
* @param shardingRuleConfig sharding rule configuration
* @param orchestrationConfig orchestration configuration
* @param configMap config map
* @param props properties for data source
* @return sharding data source
* @throws SQLException SQL exception
*/
public static DataSource createDataSource(final Map<String, DataSource> dataSourceMap, final ShardingRuleConfiguration shardingRuleConfig, final Map<String, Object> configMap, final Properties props, final OrchestrationConfiguration orchestrationConfig) throws SQLException {
OrchestrationFacade orchestrationFacade = new OrchestrationFacade(orchestrationConfig);
if (null == shardingRuleConfig || shardingRuleConfig.getTableRuleConfigs().isEmpty()) {
ConfigurationService configService = orchestrationFacade.getConfigService();
final ShardingRuleConfiguration cloudShardingRuleConfig = configService.loadShardingRuleConfiguration();
Preconditions.checkState(null != cloudShardingRuleConfig, "Missing the sharding rule configuration on register center");
return createDataSource(configService.loadDataSourceMap(), cloudShardingRuleConfig, configService.loadShardingConfigMap(), configService.loadShardingProperties(), orchestrationFacade);
} else {
return createDataSource(dataSourceMap, shardingRuleConfig, configMap, props, orchestrationFacade);
}
}
use of io.shardingjdbc.orchestration.internal.OrchestrationFacade in project sharding-jdbc by shardingjdbc.
the class OrchestrationMasterSlaveDataSourceFactory method createDataSource.
/**
* Create master-slave data source.
*
* @param dataSourceMap data source map
* @param yamlMasterSlaveRuleConfig yaml master-slave rule configuration
* @param orchestrationConfig orchestration configuration
* @return master-slave data source
* @throws SQLException SQL exception
*/
public static DataSource createDataSource(final Map<String, DataSource> dataSourceMap, final YamlMasterSlaveRuleConfiguration yamlMasterSlaveRuleConfig, final OrchestrationConfiguration orchestrationConfig) throws SQLException {
OrchestrationFacade orchestrationFacade = new OrchestrationFacade(orchestrationConfig);
if (null == yamlMasterSlaveRuleConfig) {
ConfigurationService configService = orchestrationFacade.getConfigService();
final MasterSlaveRuleConfiguration cloudMasterSlaveRuleConfig = configService.loadMasterSlaveRuleConfiguration();
Preconditions.checkState(null != cloudMasterSlaveRuleConfig, "Missing the master-slave rule configuration on register center");
return createDataSource(configService.loadDataSourceMap(), cloudMasterSlaveRuleConfig, configService.loadMasterSlaveConfigMap(), orchestrationFacade);
} else {
return createDataSource(dataSourceMap, yamlMasterSlaveRuleConfig.getMasterSlaveRuleConfiguration(), yamlMasterSlaveRuleConfig.getConfigMap(), orchestrationFacade);
}
}
use of io.shardingjdbc.orchestration.internal.OrchestrationFacade in project sharding-jdbc by shardingjdbc.
the class OrchestrationMasterSlaveDataSourceFactory method createDataSource.
/**
* Create master-slave data source.
*
* @param dataSourceMap data source map
* @param masterSlaveRuleConfig master-slave rule configuration
* @param orchestrationConfig orchestration configuration
* @param configMap config map
* @return master-slave data source
* @throws SQLException SQL exception
*/
public static DataSource createDataSource(final Map<String, DataSource> dataSourceMap, final MasterSlaveRuleConfiguration masterSlaveRuleConfig, final Map<String, Object> configMap, final OrchestrationConfiguration orchestrationConfig) throws SQLException {
OrchestrationFacade orchestrationFacade = new OrchestrationFacade(orchestrationConfig);
if (null == masterSlaveRuleConfig || null == masterSlaveRuleConfig.getMasterDataSourceName()) {
ConfigurationService configService = orchestrationFacade.getConfigService();
final MasterSlaveRuleConfiguration cloudMasterSlaveRuleConfig = configService.loadMasterSlaveRuleConfiguration();
Preconditions.checkState(null != cloudMasterSlaveRuleConfig, "Missing the master-slave rule configuration on register center");
return createDataSource(configService.loadDataSourceMap(), cloudMasterSlaveRuleConfig, configService.loadMasterSlaveConfigMap(), orchestrationFacade);
} else {
return createDataSource(dataSourceMap, masterSlaveRuleConfig, configMap, orchestrationFacade);
}
}
Aggregations