74行 int offsetWeight = random.nextInt(totalWeight);//这里totalWeight是没有经过warmup降权的值的和 78 offsetWeight -= getWeight(invokers.get(leastIndex), invocation);//这个是经过warmup降权的。
当服务刚启动,经过warmup降权后的getWeight返回的值,可能经过leastCount次循环后,还是offsetWeight >0 造成选不到invoker for (int i = 0; i < leastCount; i++) { int leastIndex = leastIndexs[i]; offsetWeight -= getWeight(invokers.get(leastIndex), invocation); if (offsetWeight <= 0) return invokers.get(leastIndex); }