本文整理了Java中org.apache.shardingsphere.core.yaml.masterslave.YamlMasterSlaveRuleConfiguration
类的一些代码示例,展示了YamlMasterSlaveRuleConfiguration
类的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。YamlMasterSlaveRuleConfiguration
类的具体详情如下:
包路径:org.apache.shardingsphere.core.yaml.masterslave.YamlMasterSlaveRuleConfiguration
类名称:YamlMasterSlaveRuleConfiguration
[英]Master-slave rule configuration for YAML.
[中]
代码示例来源:origin: apache/incubator-shardingsphere
@Override
public MasterSlaveRuleConfiguration load(final String data) {
return new Yaml().loadAs(data, YamlMasterSlaveRuleConfiguration.class).getMasterSlaveRuleConfiguration();
}
}
代码示例来源:origin: apache/incubator-shardingsphere
@Override
public String dump(final MasterSlaveRuleConfiguration masterSlaveRuleConfiguration) {
return new Yaml(new DefaultYamlRepresenter()).dumpAsMap(new YamlMasterSlaveRuleConfiguration(masterSlaveRuleConfiguration));
}
}
代码示例来源:origin: apache/incubator-shardingsphere
/**
* Get master-slave rule configuration.
*
* @return master-slave rule configuration
*/
public MasterSlaveRuleConfiguration getMasterSlaveRuleConfiguration() {
MasterSlaveLoadBalanceAlgorithm loadBalanceAlgorithm = null;
if (!Strings.isNullOrEmpty(loadBalanceAlgorithmClassName)) {
loadBalanceAlgorithm = newInstance(loadBalanceAlgorithmClassName);
} else if (null != loadBalanceAlgorithmType) {
loadBalanceAlgorithm = loadBalanceAlgorithmType.getAlgorithm();
}
return new MasterSlaveRuleConfiguration(name, masterDataSourceName, slaveDataSourceNames, loadBalanceAlgorithm);
}
代码示例来源:origin: apache/incubator-shardingsphere
for (Entry<String, YamlMasterSlaveRuleConfiguration> entry : masterSlaveRules.entrySet()) {
YamlMasterSlaveRuleConfiguration each = entry.getValue();
each.setName(entry.getKey());
masterSlaveRuleConfigs.add(entry.getValue().getMasterSlaveRuleConfiguration());
代码示例来源:origin: apache/incubator-shardingsphere
private static Map<String, RuleConfiguration> getRuleConfiguration(final Map<String, YamlProxyRuleConfiguration> localRuleConfigs) {
Map<String, RuleConfiguration> result = new HashMap<>();
for (Entry<String, YamlProxyRuleConfiguration> entry : localRuleConfigs.entrySet()) {
result.put(entry.getKey(), null != entry.getValue().getShardingRule() ? entry.getValue().getShardingRule().getShardingRuleConfiguration()
: entry.getValue().getMasterSlaveRule().getMasterSlaveRuleConfiguration());
}
return result;
}
}
代码示例来源:origin: apache/incubator-shardingsphere
private YamlShardingRuleConfiguration createYamlShardingRuleConfiguration(final ShardingRuleConfiguration shardingRuleConfiguration) {
YamlShardingRuleConfiguration result = new YamlShardingRuleConfiguration();
for (TableRuleConfiguration each : shardingRuleConfiguration.getTableRuleConfigs()) {
result.getTables().put(each.getLogicTable(), createYamlTableRuleConfiguration(each));
}
result.getBindingTables().addAll(shardingRuleConfiguration.getBindingTableGroups());
result.getBroadcastTables().addAll(shardingRuleConfiguration.getBroadcastTables());
result.setDefaultDataSourceName(shardingRuleConfiguration.getDefaultDataSourceName());
result.setDefaultDatabaseStrategy(new YamlShardingStrategyConfiguration(shardingRuleConfiguration.getDefaultDatabaseShardingStrategyConfig()));
result.setDefaultTableStrategy(new YamlShardingStrategyConfiguration(shardingRuleConfiguration.getDefaultTableShardingStrategyConfig()));
if (null != shardingRuleConfiguration.getDefaultKeyGeneratorConfig()) {
result.setDefaultKeyGenerator(createYamlKeyGeneratorConfiguration(shardingRuleConfiguration.getDefaultKeyGeneratorConfig()));
}
for (MasterSlaveRuleConfiguration each : shardingRuleConfiguration.getMasterSlaveRuleConfigs()) {
result.getMasterSlaveRules().put(each.getName(), new YamlMasterSlaveRuleConfiguration(each));
}
return result;
}
代码示例来源:origin: apache/incubator-shardingsphere
private static Map<String, RuleConfiguration> getRuleConfiguration(final Map<String, YamlProxyRuleConfiguration> localRuleConfigs) {
Map<String, RuleConfiguration> result = new HashMap<>();
for (Entry<String, YamlProxyRuleConfiguration> entry : localRuleConfigs.entrySet()) {
result.put(entry.getKey(), null != entry.getValue().getShardingRule() ? entry.getValue().getShardingRule().getShardingRuleConfiguration()
: entry.getValue().getMasterSlaveRule().getMasterSlaveRuleConfiguration());
}
return result;
}
}
代码示例来源:origin: apache/incubator-shardingsphere
private static DataSource createDataSource(final Map<String, DataSource> dataSourceMap, final YamlMasterSlaveRuleConfiguration yamlConfig,
final Map<String, Object> configMap, final Properties props, final OrchestrationConfiguration orchestrationConfig) throws SQLException {
if (null == yamlConfig) {
return new OrchestrationMasterSlaveDataSource(orchestrationConfig);
} else {
MasterSlaveDataSource masterSlaveDataSource = new MasterSlaveDataSource(dataSourceMap, yamlConfig.getMasterSlaveRuleConfiguration(), configMap, props);
return new OrchestrationMasterSlaveDataSource(masterSlaveDataSource, orchestrationConfig);
}
}
代码示例来源:origin: apache/incubator-shardingsphere
/**
* Create master-slave data source.
*
* @param dataSourceMap data source map
* @param yamlFile yaml file for master-slave rule configuration without data sources
* @return master-slave 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 {
YamlMasterSlaveConfiguration config = YamlMasterSlaveConfiguration.unmarshal(yamlFile);
return MasterSlaveDataSourceFactory.createDataSource(dataSourceMap, config.getMasterSlaveRule().getMasterSlaveRuleConfiguration(), config.getConfigMap(), config.getProps());
}
代码示例来源:origin: apache/incubator-shardingsphere
/**
* Create master-slave data source.
*
* @param dataSourceMap data source map
* @param yamlBytes yaml bytes for master-slave rule configuration without data sources
* @return master-slave data source
* @throws SQLException SQL exception
* @throws IOException IO exception
*/
public static DataSource createDataSource(final Map<String, DataSource> dataSourceMap, final byte[] yamlBytes) throws SQLException, IOException {
YamlMasterSlaveConfiguration config = YamlMasterSlaveConfiguration.unmarshal(yamlBytes);
return MasterSlaveDataSourceFactory.createDataSource(dataSourceMap, config.getMasterSlaveRule().getMasterSlaveRuleConfiguration(), config.getConfigMap(), config.getProps());
}
}
代码示例来源:origin: apache/incubator-shardingsphere
/**
* Create master-slave data source.
*
* @param yamlFile yaml file for master-slave rule configuration with data sources
* @return master-slave data source
* @throws SQLException SQL exception
* @throws IOException IO exception
*/
public static DataSource createDataSource(final File yamlFile) throws SQLException, IOException {
YamlMasterSlaveConfiguration config = YamlMasterSlaveConfiguration.unmarshal(yamlFile);
return MasterSlaveDataSourceFactory.createDataSource(config.getDataSources(), config.getMasterSlaveRule().getMasterSlaveRuleConfiguration(), config.getConfigMap(), config.getProps());
}
代码示例来源:origin: apache/incubator-shardingsphere
/**
* Create master-slave data source.
*
* @param yamlBytes yaml bytes for master-slave rule configuration with data sources
* @return master-slave data source
* @throws SQLException SQL exception
* @throws IOException IO exception
*/
public static DataSource createDataSource(final byte[] yamlBytes) throws SQLException, IOException {
YamlMasterSlaveConfiguration config = YamlMasterSlaveConfiguration.unmarshal(yamlBytes);
return MasterSlaveDataSourceFactory.createDataSource(config.getDataSources(), config.getMasterSlaveRule().getMasterSlaveRuleConfiguration(), config.getConfigMap(), config.getProps());
}
内容来源于网络,如有侵权,请联系作者删除!