From 836f26976e1ad8b35d778c563067ed0614c026e9 Mon Sep 17 00:00:00 2001 From: Pierre Zemb Date: Fri, 12 Jul 2019 12:10:17 +0200 Subject: [PATCH] HBASE-22618 added the possibility to load custom cost functions Signed-off-by: Wellington Chevreuil --- .../balancer/StochasticLoadBalancer.java | 116 ++++++++++++------ .../master/balancer/DummyCostFunction.java | 31 +++++ .../balancer/TestStochasticLoadBalancer.java | 15 ++- 3 files changed, 125 insertions(+), 37 deletions(-) create mode 100644 hbase-server/src/test/java/org/apache/hadoop/hbase/master/balancer/DummyCostFunction.java 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 87e5821de86..ee887eeca68 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 @@ -27,7 +27,9 @@ import java.util.HashMap; import java.util.LinkedList; import java.util.List; import java.util.Map; +import java.util.Objects; import java.util.Random; +import java.util.stream.Collectors; import org.apache.hadoop.conf.Configuration; import org.apache.hadoop.hbase.ClusterMetrics; @@ -47,6 +49,7 @@ import org.apache.hadoop.hbase.master.balancer.BaseLoadBalancer.Cluster.Locality import org.apache.hadoop.hbase.master.balancer.BaseLoadBalancer.Cluster.MoveRegionAction; import org.apache.hadoop.hbase.master.balancer.BaseLoadBalancer.Cluster.SwapRegionsAction; import org.apache.hadoop.hbase.util.EnvironmentEdgeManager; +import org.apache.hadoop.hbase.util.ReflectionUtils; import org.apache.yetus.audience.InterfaceAudience; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -82,6 +85,13 @@ import org.apache.hbase.thirdparty.com.google.common.collect.Lists; *
  • hbase.master.balancer.stochastic.storefileSizeCost
  • * * + *

    You can also add custom Cost function by setting the the following configuration value:

    + * + * + *

    All custom Cost Functions needs to extends {@link StochasticLoadBalancer.CostFunction}

    + * *

    In addition to the above configurations, the balancer can be tuned by the following * configuration values:

    *