1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18 package org.apache.hadoop.hbase.master.balancer;
19
20 import org.apache.commons.logging.Log;
21 import org.apache.commons.logging.LogFactory;
22 import org.apache.hadoop.hbase.testclassification.MediumTests;
23 import org.junit.After;
24 import org.junit.Before;
25 import org.junit.Test;
26 import org.junit.experimental.categories.Category;
27
28 @Category({MediumTests.class})
29 public class TestStochasticLoadBalancer2 extends BalancerTestBase {
30 private static final Log LOG = LogFactory.getLog(TestStochasticLoadBalancer2.class);
31
32 @Before
33 public void before() {
34 conf.setFloat("hbase.master.balancer.stochastic.maxMovePercent", 1.0f);
35 conf.setLong(StochasticLoadBalancer.MAX_STEPS_KEY, 2000000L);
36 conf.setFloat("hbase.master.balancer.stochastic.localityCost", 0);
37 conf.setLong("hbase.master.balancer.stochastic.maxRunningTime", 90 * 1000);
38 conf.setFloat("hbase.master.balancer.stochastic.minCostNeedBalance", 0.05f);
39 loadBalancer.setConf(conf);
40 }
41
42 @After
43 public void after() {
44
45 conf.setFloat("hbase.master.balancer.stochastic.minCostNeedBalance", 0.0f);
46 loadBalancer.setConf(conf);
47 }
48
49 @Test (timeout = 800000)
50 public void testRegionReplicasOnMidCluster() {
51 int numNodes = 200;
52 int numRegions = 40 * 200;
53 int replication = 3;
54 int numRegionsPerServer = 30;
55 int numTables = 10;
56 testWithCluster(numNodes, numRegions, numRegionsPerServer, replication, numTables, true, true);
57 }
58
59 @Test (timeout = 800000)
60 public void testRegionReplicasOnLargeCluster() {
61 int numNodes = 1000;
62 int numRegions = 20 * numNodes;
63 int numRegionsPerServer = 19;
64 int numTables = 100;
65 int replication = 3;
66 testWithCluster(numNodes, numRegions, numRegionsPerServer, replication, numTables, true, true);
67 }
68
69 @Test (timeout = 800000)
70 public void testRegionReplicasOnMidClusterHighReplication() {
71 conf.setLong(StochasticLoadBalancer.MAX_STEPS_KEY, 4000000L);
72 conf.setLong("hbase.master.balancer.stochastic.maxRunningTime", 120 * 1000);
73 loadBalancer.setConf(conf);
74 int numNodes = 80;
75 int numRegions = 6 * numNodes;
76 int replication = 80;
77 int numRegionsPerServer = 5;
78 int numTables = 10;
79 testWithCluster(numNodes, numRegions, numRegionsPerServer, replication, numTables, false, true);
80 }
81
82 @Test (timeout = 800000)
83 public void testRegionReplicationOnMidClusterReplicationGreaterThanNumNodes() {
84 conf.setLong("hbase.master.balancer.stochastic.maxRunningTime", 120 * 1000);
85 loadBalancer.setConf(conf);
86 int numNodes = 40;
87 int numRegions = 6 * 50;
88 int replication = 50;
89 int numRegionsPerServer = 6;
90 int numTables = 10;
91 testWithCluster(numNodes, numRegions, numRegionsPerServer, replication, numTables, true, false);
92 }
93 }