From 64b9d2f5ab4db65ec494c1f26661e7e2bd0b8664 Mon Sep 17 00:00:00 2001 From: Viraj Jasani Date: Sat, 18 Jan 2020 17:43:46 -0800 Subject: [PATCH] HBASE-23335 : Improving cost functions array copy in StochasticLoadBalancer Signed-off-by: stack --- .../hbase/master/balancer/StochasticLoadBalancer.java | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/master/balancer/StochasticLoadBalancer.java b/hbase-server/src/main/java/org/apache/hadoop/hbase/master/balancer/StochasticLoadBalancer.java index b14ab4059b9..60c8b672aad 100644 --- a/hbase-server/src/main/java/org/apache/hadoop/hbase/master/balancer/StochasticLoadBalancer.java +++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/master/balancer/StochasticLoadBalancer.java @@ -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