You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@dubbo.apache.org by ca...@apache.org on 2018/09/18 09:21:46 UTC
[incubator-dubbo] branch master updated: typo:
leastIndexs->leastIndexes (#2520)
This is an automated email from the ASF dual-hosted git repository.
carryxyh pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-dubbo.git
The following commit(s) were added to refs/heads/master by this push:
new 6dc2308 typo: leastIndexs->leastIndexes (#2520)
6dc2308 is described below
commit 6dc230864a8aebae948b371cad5a6a28bbd034c8
Author: 张皮皮 <36...@qq.com>
AuthorDate: Tue Sep 18 17:21:38 2018 +0800
typo: leastIndexs->leastIndexes (#2520)
typo: leastIndexs->leastIndexes in leastActiveLoadbalance
---
.../rpc/cluster/loadbalance/LeastActiveLoadBalance.java | 12 ++++++------
1 file changed, 6 insertions(+), 6 deletions(-)
diff --git a/dubbo-cluster/src/main/java/org/apache/dubbo/rpc/cluster/loadbalance/LeastActiveLoadBalance.java b/dubbo-cluster/src/main/java/org/apache/dubbo/rpc/cluster/loadbalance/LeastActiveLoadBalance.java
index fd83cf2..956ff77 100644
--- a/dubbo-cluster/src/main/java/org/apache/dubbo/rpc/cluster/loadbalance/LeastActiveLoadBalance.java
+++ b/dubbo-cluster/src/main/java/org/apache/dubbo/rpc/cluster/loadbalance/LeastActiveLoadBalance.java
@@ -38,7 +38,7 @@ public class LeastActiveLoadBalance extends AbstractLoadBalance {
int length = invokers.size(); // Number of invokers
int leastActive = -1; // The least active value of all invokers
int leastCount = 0; // The number of invokers having the same least active value (leastActive)
- int[] leastIndexs = new int[length]; // The index of invokers having the same least active value (leastActive)
+ int[] leastIndexes = new int[length]; // The index of invokers having the same least active value (leastActive)
int totalWeight = 0; // The sum of weights
int firstWeight = 0; // Initial value, used for comparision
boolean sameWeight = true; // Every invoker has the same weight value?
@@ -49,12 +49,12 @@ public class LeastActiveLoadBalance extends AbstractLoadBalance {
if (leastActive == -1 || active < leastActive) { // Restart, when find a invoker having smaller least active value.
leastActive = active; // Record the current least active value
leastCount = 1; // Reset leastCount, count again based on current leastCount
- leastIndexs[0] = i; // Reset
+ leastIndexes[0] = i; // Reset
totalWeight = weight; // Reset
firstWeight = weight; // Record the weight the first invoker
sameWeight = true; // Reset, every invoker has the same weight value?
} else if (active == leastActive) { // If current invoker's active value equals with leaseActive, then accumulating.
- leastIndexs[leastCount++] = i; // Record index number of this invoker
+ leastIndexes[leastCount++] = i; // Record index number of this invoker
totalWeight += weight; // Add this invoker's weight to totalWeight.
// If every invoker has the same weight?
if (sameWeight && i > 0
@@ -66,20 +66,20 @@ public class LeastActiveLoadBalance extends AbstractLoadBalance {
// assert(leastCount > 0)
if (leastCount == 1) {
// If we got exactly one invoker having the least active value, return this invoker directly.
- return invokers.get(leastIndexs[0]);
+ return invokers.get(leastIndexes[0]);
}
if (!sameWeight && totalWeight > 0) {
// If (not every invoker has the same weight & at least one invoker's weight>0), select randomly based on totalWeight.
int offsetWeight = ThreadLocalRandom.current().nextInt(totalWeight);
// Return a invoker based on the random value.
for (int i = 0; i < leastCount; i++) {
- int leastIndex = leastIndexs[i];
+ int leastIndex = leastIndexes[i];
offsetWeight -= getWeight(invokers.get(leastIndex), invocation);
if (offsetWeight <= 0)
return invokers.get(leastIndex);
}
}
// If all invokers have the same weight value or totalWeight=0, return evenly.
- return invokers.get(leastIndexs[ThreadLocalRandom.current().nextInt(leastCount)]);
+ return invokers.get(leastIndexes[ThreadLocalRandom.current().nextInt(leastCount)]);
}
}