Skip to content

Commit

Permalink
fix typo (#292)
Browse files Browse the repository at this point in the history
  • Loading branch information
kezhenxu94 authored and lovepoem committed Feb 17, 2019
1 parent 3a22a50 commit 528736b
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion docs/zh-cn/source_code_guide/loadbalance.md
Original file line number Diff line number Diff line change
Expand Up @@ -233,7 +233,7 @@ int weight = invoker.getUrl().getMethodParameter(invocation.getMethodName(), Con
offsetWeight -= getWeight(invokers.get(leastIndex), invocation);
```

问题出在服务预热阶段,第一行代码直接从 url 中去权重值,未被降权过。第二行代码获取到的是经过降权后的权重。第一行代码获取到的权重值最终会被累加到权重总和 totalWeight 中,这个时候会导致一个问题。offsetWeight 是一个在 [0, totalWeight) 范围内的随机数,而它所减去的是经过降权的权重。很有可能在经过 leastCount 次运算后,offsetWeight 仍然是大于0的,导致无法选中 Invoker。这个问题对应的 issue 为 [#904](https://github.com/apache/incubator-dubbo/issues/904),并在 pull request [#2172](https://github.com/apache/incubator-dubbo/pull/2172) 中被修复。具体的修复逻辑是将标注一处的代码修改为:
问题出在服务预热阶段,第一行代码直接从 url 中取权重值,未被降权过。第二行代码获取到的是经过降权后的权重。第一行代码获取到的权重值最终会被累加到权重总和 totalWeight 中,这个时候会导致一个问题。offsetWeight 是一个在 [0, totalWeight) 范围内的随机数,而它所减去的是经过降权的权重。很有可能在经过 leastCount 次运算后,offsetWeight 仍然是大于0的,导致无法选中 Invoker。这个问题对应的 issue 为 [#904](https://github.com/apache/incubator-dubbo/issues/904),并在 pull request [#2172](https://github.com/apache/incubator-dubbo/pull/2172) 中被修复。具体的修复逻辑是将标注一处的代码修改为:

```java
// afterWarmup 等价于上面的 weight 变量,这样命名是为了强调该变量经过了 warmup 降权处理
Expand Down

0 comments on commit 528736b

Please sign in to comment.