Class RSGroupableBalancerTestBase
java.lang.Object
org.apache.hadoop.hbase.master.balancer.BalancerTestBase
org.apache.hadoop.hbase.master.balancer.RSGroupableBalancerTestBase
- Direct Known Subclasses:
TestRSGroupBasedLoadBalancer
,TestRSGroupBasedLoadBalancerWithStochasticLoadBalancerAsInternal
Base UT of RSGroupableBalancer.
-
Nested Class Summary
Nested classes/interfaces inherited from class org.apache.hadoop.hbase.master.balancer.BalancerTestBase
BalancerTestBase.MockMapping
-
Field Summary
Modifier and TypeFieldDescription(package private) static org.apache.hadoop.conf.Configuration
(package private) static String[]
(package private) int[]
(package private) static int
(package private) static List<org.apache.hadoop.hbase.ServerName>
(package private) static org.apache.hadoop.hbase.TableName
(package private) static Map<org.apache.hadoop.hbase.TableName,
org.apache.hadoop.hbase.client.TableDescriptor> (package private) static org.apache.hadoop.hbase.TableName[]
Fields inherited from class org.apache.hadoop.hbase.master.balancer.BalancerTestBase
clusterStateMocks, clusterStateMocksWithNoSlop, clusterStateMocksWithSlop, largeCluster
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionprotected void
assertClusterAsBalanced
(org.apache.hbase.thirdparty.com.google.common.collect.ArrayListMultimap<String, org.apache.hadoop.hbase.master.balancer.ServerAndLoad> groupLoadMap) Invariant is that all servers of a group have load between floor(avg) and ceiling(avg) number of regions.protected void
assertImmediateAssignment
(List<org.apache.hadoop.hbase.client.RegionInfo> regions, List<org.apache.hadoop.hbase.ServerName> servers, Map<org.apache.hadoop.hbase.client.RegionInfo, org.apache.hadoop.hbase.ServerName> assignments) All regions have an assignment.protected void
assertRetainedAssignment
(Map<org.apache.hadoop.hbase.client.RegionInfo, org.apache.hadoop.hbase.ServerName> existing, List<org.apache.hadoop.hbase.ServerName> servers, Map<org.apache.hadoop.hbase.ServerName, List<org.apache.hadoop.hbase.client.RegionInfo>> assignment) Asserts a valid retained assignment plan.protected List<org.apache.hadoop.hbase.client.RegionInfo>
assignedRegions
(int numRegions, org.apache.hadoop.hbase.ServerName sn) Generate assigned regions to a given server using group information.constructGroupInfo
(List<org.apache.hadoop.hbase.ServerName> servers, String[] groups) Construct group info, with each group having at least one server.protected static Map<org.apache.hadoop.hbase.TableName,
org.apache.hadoop.hbase.client.TableDescriptor> constructTableDesc
(boolean hasBogusTable) Construct table descriptors evenly distributed between the groups.protected org.apache.hbase.thirdparty.com.google.common.collect.ArrayListMultimap<String,
org.apache.hadoop.hbase.master.balancer.ServerAndLoad> convertToGroupBasedMap
(Map<org.apache.hadoop.hbase.ServerName, List<org.apache.hadoop.hbase.client.RegionInfo>> serversMap) protected static List<org.apache.hadoop.hbase.ServerName>
generateServers
(int numServers) protected static org.apache.hadoop.hbase.rsgroup.RSGroupInfoManager
protected static org.apache.hadoop.hbase.master.MasterServices
protected org.apache.hadoop.hbase.TableName
getTableName
(org.apache.hadoop.hbase.ServerName sn) protected String
printStats
(org.apache.hbase.thirdparty.com.google.common.collect.ArrayListMultimap<String, org.apache.hadoop.hbase.master.balancer.ServerAndLoad> groupBasedLoad) protected List<org.apache.hadoop.hbase.client.RegionInfo>
randomRegions
(int numRegions) Generate a list of regions evenly distributed between the tables.protected org.apache.hbase.thirdparty.com.google.common.collect.ArrayListMultimap<String,
org.apache.hadoop.hbase.master.balancer.ServerAndLoad> reconcile
(org.apache.hbase.thirdparty.com.google.common.collect.ArrayListMultimap<String, org.apache.hadoop.hbase.master.balancer.ServerAndLoad> previousLoad, List<org.apache.hadoop.hbase.master.RegionPlan> plans) protected void
updateLoad
(org.apache.hbase.thirdparty.com.google.common.collect.ArrayListMultimap<String, org.apache.hadoop.hbase.master.balancer.ServerAndLoad> previousLoad, org.apache.hadoop.hbase.ServerName sn, int diff) Methods inherited from class org.apache.hadoop.hbase.master.balancer.BalancerTestBase
assertClusterAsBalanced, assertClusterOverallAsBalanced, assertRegionReplicaPlacement, convertToList, createRegions, createServerMap, mockCluster, mockClusterServers, mockClusterServers, mockClusterServers, mockClusterServersUnsorted, mockClusterServersWithTables, mockUniformClusterServers, printMock, printStats, randomRegions, randomServer, randomServers, reconcile, returnRegions, returnServer, returnServers, uniformRegions, updateLoad
-
Field Details
-
groups
-
table0
-
tables
-
servers
-
groupMap
-
tableDescs
static Map<org.apache.hadoop.hbase.TableName,org.apache.hadoop.hbase.client.TableDescriptor> tableDescs -
regionAssignment
int[] regionAssignment -
regionId
-
conf
-
-
Constructor Details
-
RSGroupableBalancerTestBase
public RSGroupableBalancerTestBase()
-
-
Method Details
-
assertClusterAsBalanced
protected void assertClusterAsBalanced(org.apache.hbase.thirdparty.com.google.common.collect.ArrayListMultimap<String, org.apache.hadoop.hbase.master.balancer.ServerAndLoad> groupLoadMap) Invariant is that all servers of a group have load between floor(avg) and ceiling(avg) number of regions. -
assertImmediateAssignment
protected void assertImmediateAssignment(List<org.apache.hadoop.hbase.client.RegionInfo> regions, List<org.apache.hadoop.hbase.ServerName> servers, Map<org.apache.hadoop.hbase.client.RegionInfo, org.apache.hadoop.hbase.ServerName> assignments) throws IOExceptionAll regions have an assignment.- Throws:
IOException
-
assertRetainedAssignment
protected void assertRetainedAssignment(Map<org.apache.hadoop.hbase.client.RegionInfo, org.apache.hadoop.hbase.ServerName> existing, List<org.apache.hadoop.hbase.ServerName> servers, Map<org.apache.hadoop.hbase.ServerName, throws FileNotFoundException, IOExceptionList<org.apache.hadoop.hbase.client.RegionInfo>> assignment) Asserts a valid retained assignment plan.Must meet the following conditions:
- Every input region has an assignment, and to an online server
- If a region had an existing assignment to a server with the same address a a currently online server, it will be assigned to it
- Throws:
FileNotFoundException
IOException
-
printStats
protected String printStats(org.apache.hbase.thirdparty.com.google.common.collect.ArrayListMultimap<String, org.apache.hadoop.hbase.master.balancer.ServerAndLoad> groupBasedLoad) -
convertToGroupBasedMap
protected org.apache.hbase.thirdparty.com.google.common.collect.ArrayListMultimap<String,org.apache.hadoop.hbase.master.balancer.ServerAndLoad> convertToGroupBasedMap(Map<org.apache.hadoop.hbase.ServerName, List<org.apache.hadoop.hbase.client.RegionInfo>> serversMap) throws IOException- Throws:
IOException
-
reconcile
protected org.apache.hbase.thirdparty.com.google.common.collect.ArrayListMultimap<String,org.apache.hadoop.hbase.master.balancer.ServerAndLoad> reconcile(org.apache.hbase.thirdparty.com.google.common.collect.ArrayListMultimap<String, org.apache.hadoop.hbase.master.balancer.ServerAndLoad> previousLoad, List<org.apache.hadoop.hbase.master.RegionPlan> plans) -
updateLoad
protected void updateLoad(org.apache.hbase.thirdparty.com.google.common.collect.ArrayListMultimap<String, org.apache.hadoop.hbase.master.balancer.ServerAndLoad> previousLoad, org.apache.hadoop.hbase.ServerName sn, int diff) -
mockClusterServers
protected Map<org.apache.hadoop.hbase.ServerName,List<org.apache.hadoop.hbase.client.RegionInfo>> mockClusterServers() throws IOException- Throws:
IOException
-
randomRegions
Generate a list of regions evenly distributed between the tables.- Overrides:
randomRegions
in classBalancerTestBase
- Parameters:
numRegions
- The number of regions to be generated.- Returns:
- List of RegionInfo.
-
assignedRegions
protected List<org.apache.hadoop.hbase.client.RegionInfo> assignedRegions(int numRegions, org.apache.hadoop.hbase.ServerName sn) throws IOException Generate assigned regions to a given server using group information.- Parameters:
numRegions
- the num regions to generatesn
- the servername- Returns:
- the list of regions
- Throws:
IOException
- Signals that an I/O exception has occurred.
-
generateServers
-
constructGroupInfo
protected static Map<String,org.apache.hadoop.hbase.rsgroup.RSGroupInfo> constructGroupInfo(List<org.apache.hadoop.hbase.ServerName> servers, String[] groups) Construct group info, with each group having at least one server.- Parameters:
servers
- the serversgroups
- the groups- Returns:
- the map
-
constructTableDesc
protected static Map<org.apache.hadoop.hbase.TableName,org.apache.hadoop.hbase.client.TableDescriptor> constructTableDesc(boolean hasBogusTable) Construct table descriptors evenly distributed between the groups.- Parameters:
hasBogusTable
- there is a table that does not determine the group- Returns:
- the list of table descriptors
-
getMockedMaster
- Throws:
IOException
-
getMockedGroupInfoManager
protected static org.apache.hadoop.hbase.rsgroup.RSGroupInfoManager getMockedGroupInfoManager() throws IOException- Throws:
IOException
-
getTableName
protected org.apache.hadoop.hbase.TableName getTableName(org.apache.hadoop.hbase.ServerName sn) throws IOException - Throws:
IOException
-