Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

The strategy of master-slave-rule is not valid #2306

Closed
gitOfhouge opened this issue Apr 30, 2019 · 4 comments
Closed

The strategy of master-slave-rule is not valid #2306

gitOfhouge opened this issue Apr 30, 2019 · 4 comments

Comments

@gitOfhouge
Copy link

Version: Sharding-jdbc 4.0.0-RC1 release
Test: sharding-jdbc-spring-namespace
Database: Mysql 5.1.9
Description:
First, Im sure that my configuration of master-slave is right. I want to use my own strategy of master-slave, so, I have implemented the strategy interface of master-slave by myself, but its not valid when I debug my own strategy of master-slave. Finally, I find its master when write DB and its slave when read DB. So, I guess that it`s default strategy not my own strategy when sharding database. Thank you!

@cherrylzhao
Copy link
Member

thanks for feedback, I'll try to reproduce this problem in my local environment.

@cherrylzhao
Copy link
Member

we should add a sharding:load-balance-alogrithm tag to handle customize load-balance strategy, I'll fix this later.

terrymanu added a commit that referenced this issue May 2, 2019
for #2306 fix customize load-balance strategy can't effective in sharding master slave.
terrymanu added a commit that referenced this issue May 4, 2019
for #2306 move load-balance-algorithm tag to master-slave namespace.
@cherrylzhao
Copy link
Member

@gitOfhouge
I have resolved this issue, you can verify it from our dev branch(4.0.0-RC2-Snapshot).
for customize master-slave strategy, we defined a new tag <master-slave:load-balance-algorithm> to extend it, your strategy should implement MasterSlaveLoadBalanceAlgorithm and the type literal is what should write in the <master-slave:load-balance-algorithm>id='xxx' type='xxx' />.
As customize strategy is based on SPI mechanism, so you should config META-INF.services in your project to let service loader can find it, you can see what we have done in org.apache.shardingsphere.spi.masterslave.MasterSlaveLoadBalanceAlgorithm

@cherrylzhao cherrylzhao added this to the 4.0.0.M2 milestone May 5, 2019
@gitOfhouge
Copy link
Author

OK, I see. Thank you for your help.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants