[
https://issues.apache.org/jira/browse/HBASE-26872?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]
Xiaolin Ha updated HBASE-26872:
-------------------------------
Description:
The rate calculator should avoid negative values, e.g. if a region is moved
from RS1 to RS2, the request count loads in the balancer cache maybe
[100,200,0,100,200], then the region load cost calculated by
CostFromRegionLoadAsRateFunction#getRegionLoadCost will be
(100-200+100+100)/4=25, while the real cost is (100+0+100+200)/4=100.
{code:java}
protected double getRegionLoadCost(Collection<BalancerRegionLoad>
regionLoadList) {
Iterator<BalancerRegionLoad> iter = regionLoadList.iterator();
if (!iter.hasNext()) {
return 0;
}
double previous = getCostFromRl(iter.next());
if (!iter.hasNext()) {
return 0;
}
double cost = 0;
do {
double current = getCostFromRl(iter.next());
cost += current - previous;
previous = current;
} while (iter.hasNext());
return Math.max(0, cost / (regionLoadList.size() - 1));
} {code}
We should change the cost accumulate codes to,
{code:java}
cost += current >= previous ? current - previous : current; {code}
was:
The rate calculator should avoid negative values, e.g. if a region is moved
from RS1 to RS2, the request count loads in the balancer cache maybe
[100,200,0,100,200], then the region load cost calculated by
CostFromRegionLoadAsRateFunction#getRegionLoadCost will be
(100-200+100+100)/4=25, while the real cost is (100+100+200)/4=100.
{code:java}
protected double getRegionLoadCost(Collection<BalancerRegionLoad>
regionLoadList) {
Iterator<BalancerRegionLoad> iter = regionLoadList.iterator();
if (!iter.hasNext()) {
return 0;
}
double previous = getCostFromRl(iter.next());
if (!iter.hasNext()) {
return 0;
}
double cost = 0;
do {
double current = getCostFromRl(iter.next());
cost += current - previous;
previous = current;
} while (iter.hasNext());
return Math.max(0, cost / (regionLoadList.size() - 1));
} {code}
We should change the cost accumulate codes to,
{code:java}
cost += current >= previous ? current - previous : current; {code}
> Load rate calculator for cost functions should be more precise
> --------------------------------------------------------------
>
> Key: HBASE-26872
> URL: https://issues.apache.org/jira/browse/HBASE-26872
> Project: HBase
> Issue Type: Improvement
> Components: Balancer
> Affects Versions: 2.4.11
> Reporter: Xiaolin Ha
> Assignee: Xiaolin Ha
> Priority: Major
>
> The rate calculator should avoid negative values, e.g. if a region is moved
> from RS1 to RS2, the request count loads in the balancer cache maybe
> [100,200,0,100,200], then the region load cost calculated by
> CostFromRegionLoadAsRateFunction#getRegionLoadCost will be
> (100-200+100+100)/4=25, while the real cost is (100+0+100+200)/4=100.
> {code:java}
> protected double getRegionLoadCost(Collection<BalancerRegionLoad>
> regionLoadList) {
> Iterator<BalancerRegionLoad> iter = regionLoadList.iterator();
> if (!iter.hasNext()) {
> return 0;
> }
> double previous = getCostFromRl(iter.next());
> if (!iter.hasNext()) {
> return 0;
> }
> double cost = 0;
> do {
> double current = getCostFromRl(iter.next());
> cost += current - previous;
> previous = current;
> } while (iter.hasNext());
> return Math.max(0, cost / (regionLoadList.size() - 1));
> } {code}
> We should change the cost accumulate codes to,
> {code:java}
> cost += current >= previous ? current - previous : current; {code}
--
This message was sent by Atlassian Jira
(v8.20.1#820001)