wwbmmm commented on code in PR #1571:
URL: https://github.com/apache/incubator-brpc/pull/1571#discussion_r899783833
##########
src/brpc/policy/weighted_round_robin_load_balancer.cpp:
##########
@@ -78,17 +78,22 @@ bool WeightedRoundRobinLoadBalancer::Add(Servers& bg, const
ServerId& id) {
bg.server_list.reserve(128);
}
uint32_t weight = 0;
- if (butil::StringToUint(id.tag, &weight) &&
- weight > 0) {
- bool insert_server =
- bg.server_map.emplace(id.id, bg.server_list.size()).second;
- if (insert_server) {
- bg.server_list.emplace_back(id.id, weight);
- bg.weight_sum += weight;
- return true;
+ if (!butil::StringToUint(id.tag, &weight) || weight <= 0) {
+ if (FLAGS_default_weight_of_wlb > 0) {
+ LOG(WARNING) << "Invalid weight is set: " << id.tag
+ << ". Now, 'weight' has been set to 1 by default.";
Review Comment:
同上
##########
src/brpc/policy/weighted_randomized_load_balancer.cpp:
##########
@@ -35,18 +35,23 @@ bool WeightedRandomizedLoadBalancer::Add(Servers& bg, const
ServerId& id) {
bg.server_list.reserve(128);
}
uint32_t weight = 0;
- if (butil::StringToUint(id.tag, &weight) &&
- weight > 0) {
- bool insert_server =
- bg.server_map.emplace(id.id, bg.server_list.size()).second;
- if (insert_server) {
- uint64_t current_weight_sum = bg.weight_sum + weight;
- bg.server_list.emplace_back(id.id, weight, current_weight_sum);
- bg.weight_sum = current_weight_sum;
- return true;
+ if (!butil::StringToUint(id.tag, &weight) || weight <= 0) {
+ if (FLAGS_default_weight_of_wlb > 0) {
+ LOG(WARNING) << "Invalid weight is set: " << id.tag
+ << ". Now, 'weight' has been set to 1 by default.";
Review Comment:
这里输出的 1 应该改成 FLAGS_default_weight_of_wlb 吧
--
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]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]