You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@hbase.apache.org by zh...@apache.org on 2021/09/26 15:46:49 UTC
[hbase] branch branch-2.3 updated: HBASE-26297 Balancer run is
improperly triggered by accuracy error of double comparison (#3698)
This is an automated email from the ASF dual-hosted git repository.
zhangduo pushed a commit to branch branch-2.3
in repository https://gitbox.apache.org/repos/asf/hbase.git
The following commit(s) were added to refs/heads/branch-2.3 by this push:
new 3a5b7c2 HBASE-26297 Balancer run is improperly triggered by accuracy error of double comparison (#3698)
3a5b7c2 is described below
commit 3a5b7c2ad9a5e67e1478436c95e144ff812d0627
Author: clarax <cl...@gmail.com>
AuthorDate: Sun Sep 26 00:10:44 2021 -0700
HBASE-26297 Balancer run is improperly triggered by accuracy error of double comparison (#3698)
Signed-off-by: Duo Zhang <zh...@apache.org>
---
.../hadoop/hbase/master/balancer/StochasticLoadBalancer.java | 7 +++++--
1 file changed, 5 insertions(+), 2 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 6b86374..5b83e95 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
@@ -297,11 +297,11 @@ public class StochasticLoadBalancer extends BaseLoadBalancer {
@Override
protected synchronized boolean areSomeRegionReplicasColocated(Cluster c) {
regionReplicaHostCostFunction.init(c);
- if (regionReplicaHostCostFunction.cost() > 0) {
+ if (Math.abs(regionReplicaHostCostFunction.cost()) > CostFunction.COST_EPSILON) {
return true;
}
regionReplicaRackCostFunction.init(c);
- if (regionReplicaRackCostFunction.cost() > 0) {
+ if (Math.abs(regionReplicaRackCostFunction.cost()) > CostFunction.COST_EPSILON) {
return true;
}
return false;
@@ -752,6 +752,9 @@ public class StochasticLoadBalancer extends BaseLoadBalancer {
* Base class of StochasticLoadBalancer's Cost Functions.
*/
public abstract static class CostFunction {
+
+ public static final double COST_EPSILON = 0.0001;
+
private float multiplier = 0;
protected Cluster cluster;