HBASE-23335 : Improving cost functions array copy in StochasticLoadBalancer

Signed-off-by: stack <stack@apache.org>
This commit is contained in:
Viraj Jasani 2020-01-18 17:43:46 -08:00
parent dc602d7d5d
commit 64b9d2f5ab
No known key found for this signature in database
GPG Key ID: E906DFF511D3E5DB
1 changed files with 2 additions and 6 deletions

View File

@ -414,9 +414,7 @@ public class StochasticLoadBalancer extends BaseLoadBalancer {
double currentCost = computeCost(cluster, Double.MAX_VALUE);
curOverallCost = currentCost;
for (int i = 0; i < this.curFunctionCosts.length; i++) {
curFunctionCosts[i] = tempFunctionCosts[i];
}
System.arraycopy(tempFunctionCosts, 0, curFunctionCosts, 0, this.curFunctionCosts.length);
double initCost = currentCost;
double newCost = currentCost;
@ -462,9 +460,7 @@ public class StochasticLoadBalancer extends BaseLoadBalancer {
// save for JMX
curOverallCost = currentCost;
for (int i = 0; i < this.curFunctionCosts.length; i++) {
curFunctionCosts[i] = tempFunctionCosts[i];
}
System.arraycopy(tempFunctionCosts, 0, curFunctionCosts, 0, this.curFunctionCosts.length);
} else {
// Put things back the way they were before.
// TODO: undo by remembering old values