use of io.shardingjdbc.core.yaml.sharding.YamlShardingRuleConfiguration in project sharding-jdbc by shardingjdbc.
the class OrchestrationShardingDataSourceFactory method createDataSource.
/**
* Create sharding data source.
*
* @param dataSourceMap data source map
* @param yamlFile yaml file for rule configuration of databases and tables sharding without data sources
* @return sharding data source
* @throws SQLException SQL exception
* @throws IOException IO exception
*/
public static DataSource createDataSource(final Map<String, DataSource> dataSourceMap, final File yamlFile) throws SQLException, IOException {
YamlOrchestrationShardingRuleConfiguration config = unmarshal(yamlFile);
YamlShardingRuleConfiguration shardingRuleConfig = config.getShardingRule();
return createDataSource(dataSourceMap, shardingRuleConfig, config.getOrchestration().getOrchestrationConfiguration());
}
use of io.shardingjdbc.core.yaml.sharding.YamlShardingRuleConfiguration in project sharding-jdbc by shardingjdbc.
the class OrchestrationShardingDataSourceFactory method createDataSource.
/**
* Create sharding data source.
*
* @param yamlByteArray yaml byte array for rule configuration of databases and tables sharding with data sources
* @return sharding data source
* @throws SQLException SQL exception
*/
public static DataSource createDataSource(final byte[] yamlByteArray) throws SQLException {
YamlOrchestrationShardingRuleConfiguration config = unmarshal(yamlByteArray);
YamlShardingRuleConfiguration shardingRuleConfig = config.getShardingRule();
return createDataSource(config.getDataSources(), shardingRuleConfig, config.getOrchestration().getOrchestrationConfiguration());
}
use of io.shardingjdbc.core.yaml.sharding.YamlShardingRuleConfiguration 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.core.yaml.sharding.YamlShardingRuleConfiguration in project sharding-jdbc by shardingjdbc.
the class OrchestrationShardingDataSourceFactory method createDataSource.
/**
* Create sharding data source.
*
* @param dataSourceMap data source map
* @param yamlByteArray yaml byte array for rule configuration of databases and tables sharding without data sources
* @return sharding data source
* @throws SQLException SQL exception
*/
public static DataSource createDataSource(final Map<String, DataSource> dataSourceMap, final byte[] yamlByteArray) throws SQLException {
YamlOrchestrationShardingRuleConfiguration config = unmarshal(yamlByteArray);
YamlShardingRuleConfiguration shardingRuleConfig = config.getShardingRule();
return createDataSource(dataSourceMap, shardingRuleConfig, config.getOrchestration().getOrchestrationConfiguration());
}
use of io.shardingjdbc.core.yaml.sharding.YamlShardingRuleConfiguration in project sharding-jdbc by shardingjdbc.
the class OrchestrationShardingDataSourceFactory method createDataSource.
/**
* Create sharding data source.
*
* @param yamlFile yaml file for rule configuration of databases and tables sharding with data sources
* @return sharding data source
* @throws SQLException SQL exception
* @throws IOException IO exception
*/
public static DataSource createDataSource(final File yamlFile) throws SQLException, IOException {
YamlOrchestrationShardingRuleConfiguration config = unmarshal(yamlFile);
YamlShardingRuleConfiguration shardingRuleConfig = config.getShardingRule();
return createDataSource(config.getDataSources(), shardingRuleConfig, config.getOrchestration().getOrchestrationConfiguration());
}
Aggregations