Search in sources :

Example 6 with RSGroupInfo

use of org.apache.hadoop.hbase.rsgroup.RSGroupInfo in project hbase by apache.

the class TestRSGroupBasedLoadBalancer method constructGroupInfo.

/**
   * Construct group info, with each group having at least one server.
   *
   * @param servers the servers
   * @param groups the groups
   * @return the map
   */
private static Map<String, RSGroupInfo> constructGroupInfo(List<ServerName> servers, String[] groups) {
    assertTrue(servers != null);
    assertTrue(servers.size() >= groups.length);
    int index = 0;
    Map<String, RSGroupInfo> groupMap = new HashMap<>();
    for (String grpName : groups) {
        RSGroupInfo RSGroupInfo = new RSGroupInfo(grpName);
        RSGroupInfo.addServer(servers.get(index).getAddress());
        groupMap.put(grpName, RSGroupInfo);
        index++;
    }
    while (index < servers.size()) {
        int grpIndex = rand.nextInt(groups.length);
        groupMap.get(groups[grpIndex]).addServer(servers.get(index).getAddress());
        index++;
    }
    return groupMap;
}
Also used : HashMap(java.util.HashMap) RSGroupInfo(org.apache.hadoop.hbase.rsgroup.RSGroupInfo)

Aggregations

RSGroupInfo (org.apache.hadoop.hbase.rsgroup.RSGroupInfo)6 HRegionInfo (org.apache.hadoop.hbase.HRegionInfo)4 ServerName (org.apache.hadoop.hbase.ServerName)4 TableName (org.apache.hadoop.hbase.TableName)4 ArrayList (java.util.ArrayList)2 HashMap (java.util.HashMap)2 List (java.util.List)2 Map (java.util.Map)1 TreeMap (java.util.TreeMap)1 TreeSet (java.util.TreeSet)1 HTableDescriptor (org.apache.hadoop.hbase.HTableDescriptor)1 Address (org.apache.hadoop.hbase.net.Address)1 RSGroupInfoManager (org.apache.hadoop.hbase.rsgroup.RSGroupInfoManager)1 Test (org.junit.Test)1