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:47:42 UTC
[hbase] branch branch-2.4 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.4
in repository https://gitbox.apache.org/repos/asf/hbase.git
The following commit(s) were added to refs/heads/branch-2.4 by this push:
new dc2bb6a HBASE-26297 Balancer run is improperly triggered by accuracy error of double comparison (#3698)
dc2bb6a is described below
commit dc2bb6a908569a3d34b8b20df10c7921528a0817
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 da51175..216b665 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
@@ -313,11 +313,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;
@@ -811,6 +811,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;