use of org.apache.hadoop.hbase.master.RackManager in project hbase by apache.
the class TestBaseLoadBalancer method beforeAllTests.
@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);
Mockito.when(st.getServerName()).thenReturn(master);
loadBalancer.setMasterServices(st);
// Set up the rack topologies (5 machines per rack)
rackManager = Mockito.mock(RackManager.class);
for (int i = 0; i < NUM_SERVERS; i++) {
servers[i] = ServerName.valueOf("foo" + i + ":1234", -1);
if (i < 5) {
Mockito.when(rackManager.getRack(servers[i])).thenReturn("rack1");
}
if (i >= 5 && i < 10) {
Mockito.when(rackManager.getRack(servers[i])).thenReturn("rack2");
}
if (i >= 10) {
Mockito.when(rackManager.getRack(servers[i])).thenReturn("rack3");
}
}
}
use of org.apache.hadoop.hbase.master.RackManager in project hbase by apache.
the class TestStochasticLoadBalancer method testRegionReplicationOnMidClusterWithRacks.
@Test(timeout = 800000)
public void testRegionReplicationOnMidClusterWithRacks() {
conf.setLong(StochasticLoadBalancer.MAX_STEPS_KEY, 10000000L);
conf.setFloat("hbase.master.balancer.stochastic.maxMovePercent", 1.0f);
// 120 sec
conf.setLong("hbase.master.balancer.stochastic.maxRunningTime", 120 * 1000);
loadBalancer.setConf(conf);
int numNodes = 30;
int numRegions = numNodes * 30;
// 3 replicas per region
int replication = 3;
int numRegionsPerServer = 28;
int numTables = 10;
// all replicas should be on a different rack
int numRacks = 4;
Map<ServerName, List<HRegionInfo>> serverMap = createServerMap(numNodes, numRegions, numRegionsPerServer, replication, numTables);
RackManager rm = new ForTestRackManager(numRacks);
testWithCluster(serverMap, rm, false, true);
}
use of org.apache.hadoop.hbase.master.RackManager in project hbase by apache.
the class BaseLoadBalancer method setConf.
@Override
public void setConf(Configuration conf) {
setSlop(conf);
if (slop < 0)
slop = 0;
else if (slop > 1)
slop = 1;
if (overallSlop < 0)
overallSlop = 0;
else if (overallSlop > 1)
overallSlop = 1;
this.config = conf;
String[] tables = getTablesOnMaster(conf);
if (tables != null && tables.length > 0) {
Collections.addAll(tablesOnMaster, tables);
}
this.rackManager = new RackManager(getConf());
regionFinder.setConf(conf);
}
Aggregations