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 loadBalancer.setConf(conf);
46 }
47
48 @Test (timeout = 800000)
49 public void testRegionReplicasOnMidCluster() {
50 int numNodes = 200;
51 int numRegions = 40 * 200;
52 int replication = 3;
53 int numRegionsPerServer = 30;
54 int numTables = 10;
55 testWithCluster(numNodes, numRegions, numRegionsPerServer, replication, numTables, true, true);
56 }
57
58 @Test (timeout = 800000)
59 public void testRegionReplicasOnLargeCluster() {
60 int numNodes = 1000;
61 int numRegions = 20 * numNodes;
62 int numRegionsPerServer = 19;
63 int numTables = 100;
64 int replication = 3;
65 testWithCluster(numNodes, numRegions, numRegionsPerServer, replication, numTables, true, true);
66 }
67
68 @Test (timeout = 800000)
69 public void testRegionReplicasOnMidClusterHighReplication() {
70 conf.setLong(StochasticLoadBalancer.MAX_STEPS_KEY, 4000000L);
71 conf.setLong("hbase.master.balancer.stochastic.maxRunningTime", 120 * 1000);
72 loadBalancer.setConf(conf);
73 int numNodes = 80;
74 int numRegions = 6 * numNodes;
75 int replication = 80;
76 int numRegionsPerServer = 5;
77 int numTables = 10;
78 testWithCluster(numNodes, numRegions, numRegionsPerServer, replication, numTables, false, true);
79 }
80
81 @Test (timeout = 800000)
82 public void testRegionReplicationOnMidClusterReplicationGreaterThanNumNodes() {
83 conf.setLong("hbase.master.balancer.stochastic.maxRunningTime", 120 * 1000);
84 loadBalancer.setConf(conf);
85 int numNodes = 40;
86 int numRegions = 6 * 50;
87 int replication = 50;
88 int numRegionsPerServer = 6;
89 int numTables = 10;
90 testWithCluster(numNodes, numRegions, numRegionsPerServer, replication, numTables, true, false);
91 }
92 }