From 160f48435281c5479c4ea5ea8cbabc6815846607 Mon Sep 17 00:00:00 2001 From: Rahul Agarkar Date: Fri, 31 Mar 2023 11:05:04 +0530 Subject: [PATCH] HBASE-27389 Add cost function in balancer to consider the cost of building bucket cache before moving regions --- .../hbase/master/balancer/PrefetchCacheCostFunction.java | 2 +- .../hbase/master/balancer/TestPrefetchCacheCostBalancer.java | 5 ++--- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/hbase-balancer/src/main/java/org/apache/hadoop/hbase/master/balancer/PrefetchCacheCostFunction.java b/hbase-balancer/src/main/java/org/apache/hadoop/hbase/master/balancer/PrefetchCacheCostFunction.java index f19fc88618e..7e777859784 100644 --- a/hbase-balancer/src/main/java/org/apache/hadoop/hbase/master/balancer/PrefetchCacheCostFunction.java +++ b/hbase-balancer/src/main/java/org/apache/hadoop/hbase/master/balancer/PrefetchCacheCostFunction.java @@ -70,7 +70,7 @@ public class PrefetchCacheCostFunction extends CostFunction { @Override protected double cost() { - return 1 - prefetchRatio; + return scale(0, 1, (1 - prefetchRatio)); } @Override diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/master/balancer/TestPrefetchCacheCostBalancer.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/master/balancer/TestPrefetchCacheCostBalancer.java index 5da02744084..dafb5b96582 100644 --- a/hbase-server/src/test/java/org/apache/hadoop/hbase/master/balancer/TestPrefetchCacheCostBalancer.java +++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/master/balancer/TestPrefetchCacheCostBalancer.java @@ -185,7 +185,7 @@ public class TestPrefetchCacheCostBalancer extends StochasticBalancerTestBase { admin.balance(); TEST_UTIL.waitUntilNoRegionsInTransition(120000); - Map ssmap = admin.getClusterMetrics().getLiveServerMetrics(); + Map ssmap = cluster.getClusterMetrics().getLiveServerMetrics(); assertEquals(REGION_SERVERS, ssmap.size()); // Get the name of the region server to shutdown and restart @@ -273,8 +273,7 @@ public class TestPrefetchCacheCostBalancer extends StochasticBalancerTestBase { admin.balance(); TEST_UTIL.waitUntilNoRegionsInTransition(120000); - Map ssmap = admin.getClusterMetrics().getLiveServerMetrics(); - + Map ssmap = cluster.getClusterMetrics().getLiveServerMetrics(); assertEquals(REGION_SERVERS, ssmap.size()); // Shutdown the last server. This is because the server id for an inactive server is reassigned