QiangYuan0828 commented on code in PR #24934:
URL: https://github.com/apache/shardingsphere/pull/24934#discussion_r1169423555
##########
features/readwrite-splitting/core/src/main/java/org/apache/shardingsphere/readwritesplitting/algorithm/loadbalance/RandomReadQueryLoadBalanceAlgorithm.java:
##########
@@ -29,7 +30,10 @@ public final class RandomReadQueryLoadBalanceAlgorithm
implements ReadQueryLoadB
@Override
public String getDataSource(final String name, final String
writeDataSourceName, final List<String> readDataSourceNames) {
- return
readDataSourceNames.get(ThreadLocalRandom.current().nextInt(readDataSourceNames.size()));
+ Preconditions.checkState(readDataSourceNames.size() > 0, "read data
need at least 1 source.");
Review Comment:
I’m sorry for the misunderstanding. In the first commit, I misunderstand
this issue, I change the `getDataSource` function rather than `init` function.
After your suggetions in #24752 , I imporve the properties verification of
`init` in `WeightReadQueryLoadBalanceAlgorithm` in the second commit but forget
cancel the first commit. Sould I continue or cancel the first commit?
By the way, I didn't find 'init' function in
`RandomReadQueryLoadBalanceAlgorithm` and
`RoundRobinReadQueryLoadBalanceAlgorithm`, should I write `init` function by
myself like `WeightReadQueryLoadBalanceAlgorithm`?
Sorry for the inconvenience.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]