You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@hbase.apache.org by ha...@apache.org on 2022/03/28 10:19:41 UTC
[hbase] branch branch-2.5 updated: Revert "HBASE-26872 Load rate calculator for cost functions should be more precise (#4253)"
This is an automated email from the ASF dual-hosted git repository.
haxiaolin pushed a commit to branch branch-2.5
in repository https://gitbox.apache.org/repos/asf/hbase.git
The following commit(s) were added to refs/heads/branch-2.5 by this push:
new 2452290 Revert "HBASE-26872 Load rate calculator for cost functions should be more precise (#4253)"
2452290 is described below
commit 245229055edd7727fc287c9683365cbac02b64ee
Author: haxiaolin <ha...@apache.org>
AuthorDate: Mon Mar 28 18:19:01 2022 +0800
Revert "HBASE-26872 Load rate calculator for cost functions should be more precise (#4253)"
This reverts commit 568b335b443acc33975927d96297b332ae4b4287.
---
.../balancer/CostFromRegionLoadAsRateFunction.java | 4 ++--
.../balancer/TestStochasticLoadBalancer.java | 28 ++--------------------
2 files changed, 4 insertions(+), 28 deletions(-)
diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/master/balancer/CostFromRegionLoadAsRateFunction.java b/hbase-server/src/main/java/org/apache/hadoop/hbase/master/balancer/CostFromRegionLoadAsRateFunction.java
index e6d0cf8..88af49e 100644
--- a/hbase-server/src/main/java/org/apache/hadoop/hbase/master/balancer/CostFromRegionLoadAsRateFunction.java
+++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/master/balancer/CostFromRegionLoadAsRateFunction.java
@@ -42,9 +42,9 @@ abstract class CostFromRegionLoadAsRateFunction extends CostFromRegionLoadFuncti
double cost = 0;
do {
double current = getCostFromRl(iter.next());
- cost += current >= previous ? current - previous : current;
+ cost += current - previous;
previous = current;
} while (iter.hasNext());
return Math.max(0, cost / (regionLoadList.size() - 1));
}
-}
+}
\ No newline at end of file
diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/master/balancer/TestStochasticLoadBalancer.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/master/balancer/TestStochasticLoadBalancer.java
index bd80e15..9f9ac84 100644
--- a/hbase-server/src/test/java/org/apache/hadoop/hbase/master/balancer/TestStochasticLoadBalancer.java
+++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/master/balancer/TestStochasticLoadBalancer.java
@@ -23,6 +23,7 @@ import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertTrue;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
+
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
@@ -49,6 +50,7 @@ import org.apache.hadoop.hbase.util.EnvironmentEdgeManager;
import org.junit.ClassRule;
import org.junit.Test;
import org.junit.experimental.categories.Category;
+
import org.apache.hbase.thirdparty.org.apache.commons.collections4.CollectionUtils;
@Category({ MasterTests.class, MediumTests.class })
@@ -448,32 +450,6 @@ public class TestStochasticLoadBalancer extends BalancerTestBase {
}
@Test
- public void testRegionLoadCostWhenDecrease() {
- List<BalancerRegionLoad> regionLoads = new ArrayList<>();
- // test region loads of [1,2,1,4]
- for (int i = 1; i < 5; i++) {
- int load = i == 3 ? 1 : i;
- BalancerRegionLoad regionLoad = mock(BalancerRegionLoad.class);
- when(regionLoad.getReadRequestsCount()).thenReturn((long)load);
- when(regionLoad.getCpRequestsCount()).thenReturn((long)load);
- regionLoads.add(regionLoad);
- }
-
- Configuration conf = HBaseConfiguration.create();
- ReadRequestCostFunction readCostFunction =
- new ReadRequestCostFunction(conf);
- double rateResult = readCostFunction.getRegionLoadCost(regionLoads);
- // read requests are treated as a rate so the average rate here is simply 1
- assertEquals(1.67, rateResult, 0.01);
-
- CPRequestCostFunction cpCostFunction =
- new CPRequestCostFunction(conf);
- rateResult = cpCostFunction.getRegionLoadCost(regionLoads);
- // coprocessor requests are treated as a rate so the average rate here is simply 1
- assertEquals(1.67, rateResult, 0.01);
- }
-
- @Test
public void testLosingRs() throws Exception {
int numNodes = 3;
int numRegions = 20;