HBASE-12554 TestBaseLoadBalancer may timeout due to lengthy rack lookup

This commit is contained in:
tedyu 2014-11-21 16:52:11 -08:00
parent 882324dbcc
commit 7ee4df600b
1 changed files with 19 additions and 0 deletions

View File

@ -50,6 +50,8 @@ import org.apache.hadoop.hbase.master.balancer.BaseLoadBalancer.Cluster;
import org.apache.hadoop.hbase.master.balancer.BaseLoadBalancer.Cluster.MoveRegionAction;
import org.apache.hadoop.hbase.testclassification.MasterTests;
import org.apache.hadoop.hbase.testclassification.MediumTests;
import org.apache.hadoop.net.DNSToSwitchMapping;
import org.apache.hadoop.net.ScriptBasedMapping;
import org.junit.BeforeClass;
import org.junit.Test;
import org.junit.experimental.categories.Category;
@ -74,9 +76,26 @@ public class TestBaseLoadBalancer extends BalancerTestBase {
new int[] { 1, 3 }, new int[] { 2, 3 }, new int[] { 3, 3 }, new int[] { 25, 3 },
new int[] { 2, 10 }, new int[] { 2, 100 }, new int[] { 12, 10 }, new int[] { 12, 100 }, };
// This class is introduced because IP to rack resolution can be lengthy.
public static class MockMapping extends ScriptBasedMapping {
public MockMapping(Configuration conf) {
}
private static String RACK = "rack";
@Override
public List<String> resolve(List<String> names) {
List<String> ret = new ArrayList<String>(names.size());
for (String name : names) {
ret.add(RACK);
}
return ret;
}
}
@BeforeClass
public static void beforeAllTests() throws Exception {
Configuration conf = HBaseConfiguration.create();
conf.setClass("hbase.util.ip.to.rack.determiner", MockMapping.class, DNSToSwitchMapping.class);
loadBalancer = new MockBalancer();
loadBalancer.setConf(conf);
MasterServices st = Mockito.mock(MasterServices.class);