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:
parent
dd293c8ba9
commit
afbdd4115b
|
@ -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();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue