Skip to content

Commit afbdd41

Browse files
authored
HBASE-26237 Improve computation complexity for primaryRegionCountSkewCostFunction (#3657)
Signed-off-by: Duo Zhang <zhangduo@apache.org> Signed-off-by: Huaxiang Sun <huaxiangsun@apache.org>
1 parent dd293c8 commit afbdd41

1 file changed

Lines changed: 7 additions & 3 deletions

File tree

hbase-balancer/src/main/java/org/apache/hadoop/hbase/master/balancer/PrimaryRegionCountSkewCostFunction.java

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -66,8 +66,12 @@ void prepare(BalancerClusterState cluster) {
6666
@Override
6767
protected void regionMoved(int region, int oldServer, int newServer) {
6868
cost.applyCostsChange(costs -> {
69-
costs[oldServer] = computeCostForRegionServer(oldServer);
70-
costs[newServer] = computeCostForRegionServer(newServer);
69+
if (region == cluster.regionIndexToPrimaryIndex[region]) {
70+
if (oldServer >= 0) {
71+
costs[oldServer]--;
72+
}
73+
costs[newServer]++;
74+
}
7175
});
7276
}
7377

@@ -80,4 +84,4 @@ boolean isNeeded() {
8084
protected double cost() {
8185
return cost.cost();
8286
}
83-
}
87+
}

0 commit comments

Comments
 (0)