Search in sources :

Example 6 with MasterSlaveRule

use of io.shardingjdbc.core.rule.MasterSlaveRule in project sharding-jdbc by shardingjdbc.

the class MasterSlaveNamespaceTest 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"));
}
Also used : MasterSlaveRule(io.shardingjdbc.core.rule.MasterSlaveRule) Test(org.junit.Test)

Example 7 with MasterSlaveRule

use of io.shardingjdbc.core.rule.MasterSlaveRule in project sharding-jdbc by shardingjdbc.

the class MasterSlaveNamespaceTest method assertTypeMasterSlaveDataSource.

@Test
public void assertTypeMasterSlaveDataSource() {
    MasterSlaveRule randomSlaveRule = getMasterSlaveRule("randomMasterSlaveDataSource");
    MasterSlaveRule roundRobinSlaveRule = getMasterSlaveRule("roundRobinMasterSlaveDataSource");
    assertTrue(randomSlaveRule.getLoadBalanceAlgorithm() instanceof RandomMasterSlaveLoadBalanceAlgorithm);
    assertTrue(roundRobinSlaveRule.getLoadBalanceAlgorithm() instanceof RoundRobinMasterSlaveLoadBalanceAlgorithm);
}
Also used : RoundRobinMasterSlaveLoadBalanceAlgorithm(io.shardingjdbc.core.api.algorithm.masterslave.RoundRobinMasterSlaveLoadBalanceAlgorithm) RandomMasterSlaveLoadBalanceAlgorithm(io.shardingjdbc.core.api.algorithm.masterslave.RandomMasterSlaveLoadBalanceAlgorithm) MasterSlaveRule(io.shardingjdbc.core.rule.MasterSlaveRule) Test(org.junit.Test)

Aggregations

MasterSlaveRule (io.shardingjdbc.core.rule.MasterSlaveRule)7 Test (org.junit.Test)6 RandomMasterSlaveLoadBalanceAlgorithm (io.shardingjdbc.core.api.algorithm.masterslave.RandomMasterSlaveLoadBalanceAlgorithm)4 RoundRobinMasterSlaveLoadBalanceAlgorithm (io.shardingjdbc.core.api.algorithm.masterslave.RoundRobinMasterSlaveLoadBalanceAlgorithm)4 MasterSlaveLoadBalanceAlgorithm (io.shardingjdbc.core.api.algorithm.masterslave.MasterSlaveLoadBalanceAlgorithm)2