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