Search in sources :

Example 1 with RackManager

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");
        }
    }
}
Also used : Configuration(org.apache.hadoop.conf.Configuration) HBaseConfiguration(org.apache.hadoop.hbase.HBaseConfiguration) MasterServices(org.apache.hadoop.hbase.master.MasterServices) RackManager(org.apache.hadoop.hbase.master.RackManager) BeforeClass(org.junit.BeforeClass)

Example 2 with RackManager

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);
}
Also used : ServerName(org.apache.hadoop.hbase.ServerName) ArrayList(java.util.ArrayList) List(java.util.List) RackManager(org.apache.hadoop.hbase.master.RackManager) Test(org.junit.Test)

Example 3 with RackManager

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);
}
Also used : RackManager(org.apache.hadoop.hbase.master.RackManager)

Aggregations

RackManager (org.apache.hadoop.hbase.master.RackManager)3 ArrayList (java.util.ArrayList)1 List (java.util.List)1 Configuration (org.apache.hadoop.conf.Configuration)1 HBaseConfiguration (org.apache.hadoop.hbase.HBaseConfiguration)1 ServerName (org.apache.hadoop.hbase.ServerName)1 MasterServices (org.apache.hadoop.hbase.master.MasterServices)1 BeforeClass (org.junit.BeforeClass)1 Test (org.junit.Test)1