This is an automated email from the ASF dual-hosted git repository.
albumenj pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/dubbo-website.git
The following commit(s) were added to refs/heads/master by this push:
new dac04d2eeac Fix wrong interpretation (#1686)
dac04d2eeac is described below
commit dac04d2eeac54af72654939c614b66d6f3a16b70
Author: Poison <[email protected]>
AuthorDate: Wed Dec 7 19:30:24 2022 +0800
Fix wrong interpretation (#1686)
---
content/zh/blog/java/demos/dubbo-consistent-hash-implementation.md | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/content/zh/blog/java/demos/dubbo-consistent-hash-implementation.md
b/content/zh/blog/java/demos/dubbo-consistent-hash-implementation.md
index 24744068d45..00a63da79e6 100644
--- a/content/zh/blog/java/demos/dubbo-consistent-hash-implementation.md
+++ b/content/zh/blog/java/demos/dubbo-consistent-hash-implementation.md
@@ -279,8 +279,8 @@ private Invoker<T> selectForKey(long hash) {
argumentIndex是在初始化Selector的时候一起赋值的,代表着需要用哪几个请求参数作Hash映射获取Invoker。比如:有方法methodA(Integer
a, Integer b, Integer c),如果argumentIndex的值为{0,2},那么即用a和c拼接的字符串来计算Hash值。
-我们已经知道virtualInvokers是一个TreeMap,TreeMap的底层实现是红黑树。对于TreeMap的方法ceilingEntry(hash),它的作用是用来**获取比传入值大的第一个元素**。可以看到,这一点与一般的一致性Hash算法的处理逻辑完全是相同的。
+我们已经知道virtualInvokers是一个TreeMap,TreeMap的底层实现是红黑树。对于TreeMap的方法ceilingEntry(hash),它的作用是用来**获取大于等于传入值的首个元素**。可以看到,这一点与一般的一致性Hash算法的处理逻辑完全是相同的。
但这里的回环逻辑有点不同。对于取模运算来讲,大于最大值后,会自动回环从0开始,而这里的逻辑是:当没有比传入ceilingEntry()方法中的值大的元素的时候,virtualInvokers.ceilingEntry(hash)必然会得到null,于是,就用virtualInvokers.firstEntry()来获取整个TreeMap的第一个元素。
-从selectForKey中获取到Invoker后,负载均衡策略也就算是执行完毕了。后续获取远程调用客户端等调用流程不再赘述。
\ No newline at end of file
+从selectForKey中获取到Invoker后,负载均衡策略也就算是执行完毕了。后续获取远程调用客户端等调用流程不再赘述。