HBASE-12554 TestBaseLoadBalancer may timeout due to lengthy rack lookup
This commit is contained in:
parent
aa343ebcfe
commit
d5bcf338d6
|
@ -47,6 +47,8 @@ import org.apache.hadoop.hbase.master.RackManager;
|
|||
import org.apache.hadoop.hbase.master.RegionPlan;
|
||||
import org.apache.hadoop.hbase.master.balancer.BaseLoadBalancer.Cluster;
|
||||
import org.apache.hadoop.hbase.master.balancer.BaseLoadBalancer.Cluster.MoveRegionAction;
|
||||
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;
|
||||
|
@ -71,9 +73,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);
|
||||
|
|
Loading…
Reference in New Issue