HBASE-26237 Improve computation complexity for primaryRegionCountSkewCostFunction (#3657)

Signed-off-by: Duo Zhang <zhangduo@apache.org>
Signed-off-by: Huaxiang Sun <huaxiangsun@apache.org>
This commit is contained in:
clarax 2021-09-03 18:36:55 -07:00 committed by GitHub
parent dd293c8ba9
commit afbdd4115b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 7 additions and 3 deletions

View File

@ -66,8 +66,12 @@ class PrimaryRegionCountSkewCostFunction extends CostFunction {
@Override
protected void regionMoved(int region, int oldServer, int newServer) {
cost.applyCostsChange(costs -> {
costs[oldServer] = computeCostForRegionServer(oldServer);
costs[newServer] = computeCostForRegionServer(newServer);
if (region == cluster.regionIndexToPrimaryIndex[region]) {
if (oldServer >= 0) {
costs[oldServer]--;
}
costs[newServer]++;
}
});
}
@ -80,4 +84,4 @@ class PrimaryRegionCountSkewCostFunction extends CostFunction {
protected double cost() {
return cost.cost();
}
}
}