use of io.shardingjdbc.core.rule.MasterSlaveRule in project sharding-jdbc by shardingjdbc.
the class MasterSlaveDataSource method renew.
/**
* Renew master-slave data source.
*
* @param dataSourceMap data source map
* @param masterSlaveRuleConfig new master-slave rule configuration
*/
public void renew(final Map<String, DataSource> dataSourceMap, final MasterSlaveRuleConfiguration masterSlaveRuleConfig) {
this.dataSourceMap = dataSourceMap;
this.masterSlaveRule = new MasterSlaveRule(masterSlaveRuleConfig);
}
use of io.shardingjdbc.core.rule.MasterSlaveRule in project sharding-jdbc by shardingjdbc.
the class MasterSlaveNamespaceTest method assertRefMasterSlaveDataSource.
@Test
public void assertRefMasterSlaveDataSource() {
MasterSlaveLoadBalanceAlgorithm randomStrategy = this.applicationContext.getBean("randomStrategy", MasterSlaveLoadBalanceAlgorithm.class);
MasterSlaveRule masterSlaveRule = getMasterSlaveRule("refMasterSlaveDataSource");
assertTrue(masterSlaveRule.getLoadBalanceAlgorithm() == randomStrategy);
}
use of io.shardingjdbc.core.rule.MasterSlaveRule in project sharding-jdbc by shardingjdbc.
the class OrchestrationMasterSlaveNamespaceTest method assertRefMasterSlaveDataSource.
@Test
public void assertRefMasterSlaveDataSource() {
MasterSlaveLoadBalanceAlgorithm randomStrategy = this.applicationContext.getBean("randomStrategy", MasterSlaveLoadBalanceAlgorithm.class);
MasterSlaveRule masterSlaveRule = getMasterSlaveRule("refMasterSlaveDataSource");
assertTrue(EqualsBuilder.reflectionEquals(masterSlaveRule.getLoadBalanceAlgorithm(), randomStrategy));
}
use of io.shardingjdbc.core.rule.MasterSlaveRule in project sharding-jdbc by shardingjdbc.
the class OrchestrationMasterSlaveNamespaceTest method assertTypeMasterSlaveDataSource.
@Test
public void assertTypeMasterSlaveDataSource() {
MasterSlaveRule randomSlaveRule = getMasterSlaveRule("randomMasterSlaveDataSource");
MasterSlaveRule roundRobinSlaveRule = getMasterSlaveRule("roundRobinMasterSlaveDataSource");
assertTrue(randomSlaveRule.getLoadBalanceAlgorithm() instanceof RandomMasterSlaveLoadBalanceAlgorithm);
assertTrue(roundRobinSlaveRule.getLoadBalanceAlgorithm() instanceof RoundRobinMasterSlaveLoadBalanceAlgorithm);
}
use of io.shardingjdbc.core.rule.MasterSlaveRule in project sharding-jdbc by shardingjdbc.
the class OrchestrationMasterSlaveNamespaceTest method assertDefaultMaserSlaveDataSource.
@Test
public void assertDefaultMaserSlaveDataSource() {
MasterSlaveRule masterSlaveRule = getMasterSlaveRule("defaultMasterSlaveDataSource");
assertThat(masterSlaveRule.getMasterDataSourceName(), is("dbtbl_0_master"));
assertTrue(masterSlaveRule.getSlaveDataSourceNames().contains("dbtbl_0_slave_0"));
assertTrue(masterSlaveRule.getSlaveDataSourceNames().contains("dbtbl_0_slave_1"));
}
Aggregations