sharding-jdbc中MasterSlaveRouter的作用是什么


本篇文章为大家展示了sharding-jdbc中MasterSlaveRouter的作用是什么,内容简明扼要并且容易理解,绝对能使你眼前一亮,通过这篇文章的详细介绍希望你能有所收获。incubator-shardingsphere-4.0.0-RC1/sharding-core/sharding-core-route/src/main/java/org/apache/shardingsphere/core/route/router/masterslave/MasterSlaveRouter.javaMasterSlaveRouter的route方法使用masterSlaveRule来进行路由incubator-shardingsphere-4.0.0-RC1/sharding-core/sharding-core-common/src/main/java/org/apache/shardingsphere/core/rule/MasterSlaveRule.javaMasterSlaveRule内置了loadBalanceAlgorithm、masterSlaveRuleConfigurationincubator-shardingsphere-4.0.0-RC1/sharding-core/sharding-core-api/src/main/jav 香港云主机a/org/apache/shardingsphere/spi/masterslave/MasterSlaveLoadBalanceAlgorithm.javaMasterSlaveLoadBalanceAlgorithm接口继承了TypeBasedSPI接口,它定义了getDataSource方法;它有两个实现类分别是RandomMasterSlaveLoadBalanceAlgorithm、RoundRobinMasterSlaveLoadBalanceAlgorithmincubator-shardingsphere-4.0.0-RC1/sharding-core/sharding-core-common/src/main/java/org/apache/shardingsphere/core/strategy/masterslave/RandomMasterSlaveLoadBalanceAlgorithm.javaRandomMasterSlaveLoadBalanceAlgorithm使用Random().nextInt来进行随机incubator-shardingsphere-4.0.0-RC1/sharding-core/sharding-core-common/src/main/java/org/apache/shardingsphere/core/strategy/masterslave/RoundRobinMasterSlaveLoadBalanceAlgorithm.javaRoundRobinMasterSlaveLoadBalanceAlgorithm使用Math.abs(count.getAndIncrement()) % slaveDataSourceNames.size()进行round robinincubator-shardingsphere-4.0.0-RC1/sharding-core/sharding-core-api/src/main/java/org/apache/shardingsphere/api/config/masterslave/MasterSlaveRuleConfiguration.javaMasterSlaveRuleConfiguration定义了name、masterDataSourceName、slaveDataSourceNames、loadBalanceStrategyConfiguration属性MasterSlaveRouter的route方法使用masterSlaveRule来进行路由;MasterSlaveRule内置了loadBalanceAlgorithm、masterSlaveRuleConfiguration;MasterSlaveLoadBalanceAlgorithm接口继承了TypeBasedSPI接口,它定义了getDataSource方法;它有两个实现类分别是RandomMasterSlaveLoadBalanceAlgorithm、RoundRobinMasterSlaveLoadBalanceAlgorithm上述内容就是sharding-jdbc中MasterSlaveRouter的作用是什么,你们学到知识或技能了吗?如果还想学到更多技能或者丰富自己的知识储备,欢迎关注开发云行业资讯频道。

相关推荐: PHP中怎么获取请求header

本篇文章为大家展示了PHP中怎么获取请求header,内容简明扼要并且容易理解,绝对能使你眼前一亮,通过这篇文章的详细介绍希望你能有所收获。下面方法可以获取所有请求headerfunction em_getallheaders() { foreach ($_S…

免责声明:本站发布的图片视频文字,以转载和分享为主,文章观点不代表本站立场,本站不承担相关法律责任;如果涉及侵权请联系邮箱:360163164@qq.com举报,并提供相关证据,经查实将立刻删除涉嫌侵权内容。

(0)
打赏 微信扫一扫 微信扫一扫
上一篇 07/27 20:35
下一篇 07/27 20:35

相关推荐