Class BalancerTestBase
java.lang.Object
org.apache.hadoop.hbase.master.balancer.BalancerTestBase
- Direct Known Subclasses:
BalancerTestBase2
,RSGroupableBalancerTestBase
,TestBalancerDecision
,TestBalancerRejection
,TestBalancerStatusTagInJMXMetrics
,TestBaseLoadBalancer
,TestCacheAwareLoadBalancer
,TestCacheAwareLoadBalancerCostFunctions
,TestFavoredStochasticBalancerPickers
,TestFavoredStochasticLoadBalancer
,TestSimpleLoadBalancer
,TestStochasticBalancerJmxMetrics
,TestStochasticLoadBalancer
,TestStochasticLoadBalancerBalanceCluster
,TestStochasticLoadBalancerHeterogeneousCost
,TestStochasticLoadBalancerHeterogeneousCostRules
,TestStochasticLoadBalancerLargeCluster
,TestStochasticLoadBalancerMidCluster
,TestStochasticLoadBalancerRegionReplica
,TestStochasticLoadBalancerRegionReplicaLargeCluster
,TestStochasticLoadBalancerRegionReplicaSameHosts
,TestStochasticLoadBalancerRegionReplicaWithRacks
,TestStochasticLoadBalancerSmallCluster
Class used to be the base of unit tests on load balancers. It gives helper methods to create maps
of
ServerName
to lists of RegionInfo
and to check list of region plans.-
Nested Class Summary
-
Field Summary
Modifier and TypeFieldDescriptionprotected int[][]
protected int[][]
protected int[][]
protected static org.apache.hadoop.conf.Configuration
protected static DummyMetricsStochasticBalancer
protected int[]
protected static org.apache.hadoop.hbase.master.balancer.StochasticLoadBalancer
private static final org.slf4j.Logger
(package private) static int
private Queue<org.apache.hadoop.hbase.client.RegionInfo>
private Queue<org.apache.hadoop.hbase.ServerName>
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionvoid
assertClusterAsBalanced
(List<org.apache.hadoop.hbase.master.balancer.ServerAndLoad> servers) Invariant is that all servers have between floor(avg) and ceiling(avg) number of regions.boolean
assertClusterOverallAsBalanced
(List<org.apache.hadoop.hbase.master.balancer.ServerAndLoad> servers, int tablenum) Invariant is that all servers have between acceptable range number of regions.void
assertRegionReplicaPlacement
(Map<org.apache.hadoop.hbase.ServerName, List<org.apache.hadoop.hbase.client.RegionInfo>> serverMap, org.apache.hadoop.hbase.master.RackManager rackManager) Checks whether region replicas are not hosted on the same host.static void
protected List<org.apache.hadoop.hbase.master.balancer.ServerAndLoad>
convertToList
(Map<org.apache.hadoop.hbase.ServerName, List<org.apache.hadoop.hbase.client.RegionInfo>> servers) protected List<org.apache.hadoop.hbase.client.RegionInfo>
createRegions
(int numRegions, org.apache.hadoop.hbase.TableName tableName) createServerMap
(int numNodes, int numRegions, int numRegionsPerServer, int replication, int numTables) protected org.apache.hadoop.hbase.master.balancer.BalancerClusterState
mockCluster
(int[] mockCluster) protected TreeMap<org.apache.hadoop.hbase.ServerName,
List<org.apache.hadoop.hbase.client.RegionInfo>> mockClusterServers
(int[] mockCluster) protected TreeMap<org.apache.hadoop.hbase.ServerName,
List<org.apache.hadoop.hbase.client.RegionInfo>> mockClusterServers
(int[][] mockCluster) protected TreeMap<org.apache.hadoop.hbase.ServerName,
List<org.apache.hadoop.hbase.client.RegionInfo>> mockClusterServers
(int[] mockCluster, int numTables) mockClusterServersUnsorted
(int[] mockCluster, int numTables) protected HashMap<org.apache.hadoop.hbase.TableName,
TreeMap<org.apache.hadoop.hbase.ServerName, List<org.apache.hadoop.hbase.client.RegionInfo>>> mockClusterServersWithTables
(Map<org.apache.hadoop.hbase.ServerName, List<org.apache.hadoop.hbase.client.RegionInfo>> clusterServers) protected TreeMap<org.apache.hadoop.hbase.ServerName,
List<org.apache.hadoop.hbase.client.RegionInfo>> mockUniformClusterServers
(int[] mockCluster) protected String
protected String
printStats
(List<org.apache.hadoop.hbase.master.balancer.ServerAndLoad> servers) protected List<org.apache.hadoop.hbase.client.RegionInfo>
randomRegions
(int numRegions) protected List<org.apache.hadoop.hbase.client.RegionInfo>
randomRegions
(int numRegions, int numTables) protected org.apache.hadoop.hbase.master.balancer.ServerAndLoad
randomServer
(int numRegionsPerServer) protected List<org.apache.hadoop.hbase.master.balancer.ServerAndLoad>
randomServers
(int numServers, int numRegionsPerServer) protected List<org.apache.hadoop.hbase.master.balancer.ServerAndLoad>
reconcile
(List<org.apache.hadoop.hbase.master.balancer.ServerAndLoad> list, List<org.apache.hadoop.hbase.master.RegionPlan> plans, Map<org.apache.hadoop.hbase.ServerName, List<org.apache.hadoop.hbase.client.RegionInfo>> servers) This assumes the RegionPlan HSI instances are the same ones in the map, so actually no need to even pass in the map, but I think it's clearer.protected void
returnRegions
(List<org.apache.hadoop.hbase.client.RegionInfo> regions) protected void
returnServer
(org.apache.hadoop.hbase.ServerName server) protected void
returnServers
(List<org.apache.hadoop.hbase.ServerName> servers) protected void
testWithCluster
(int numNodes, int numRegions, int numRegionsPerServer, int replication, int numTables, boolean assertFullyBalanced, boolean assertFullyBalancedForReplicas) protected void
testWithCluster
(Map<org.apache.hadoop.hbase.ServerName, List<org.apache.hadoop.hbase.client.RegionInfo>> serverMap, org.apache.hadoop.hbase.master.RackManager rackManager, boolean assertFullyBalanced, boolean assertFullyBalancedForReplicas) protected void
testWithClusterWithIteration
(int numNodes, int numRegions, int numRegionsPerServer, int replication, int numTables, boolean assertFullyBalanced, boolean assertFullyBalancedForReplicas) protected void
testWithClusterWithIteration
(Map<org.apache.hadoop.hbase.ServerName, List<org.apache.hadoop.hbase.client.RegionInfo>> serverMap, org.apache.hadoop.hbase.master.RackManager rackManager, boolean assertFullyBalanced, boolean assertFullyBalancedForReplicas) protected List<org.apache.hadoop.hbase.client.RegionInfo>
uniformRegions
(int numRegions) protected void
updateLoad
(Map<org.apache.hadoop.hbase.ServerName, org.apache.hadoop.hbase.master.balancer.ServerAndLoad> map, org.apache.hadoop.hbase.ServerName sn, int diff)
-
Field Details
-
LOG
-
regionId
-
conf
-
loadBalancer
-
dummyMetricsStochasticBalancer
-
largeCluster
-
clusterStateMocks
-
clusterStateMocksWithNoSlop
-
clusterStateMocksWithSlop
-
regionQueue
-
serverQueue
-
-
Constructor Details
-
BalancerTestBase
public BalancerTestBase()
-
-
Method Details
-
beforeAllTests
- Throws:
Exception
-
assertClusterAsBalanced
public void assertClusterAsBalanced(List<org.apache.hadoop.hbase.master.balancer.ServerAndLoad> servers) Invariant is that all servers have between floor(avg) and ceiling(avg) number of regions. -
assertClusterOverallAsBalanced
public boolean assertClusterOverallAsBalanced(List<org.apache.hadoop.hbase.master.balancer.ServerAndLoad> servers, int tablenum) Invariant is that all servers have between acceptable range number of regions. -
assertRegionReplicaPlacement
public void assertRegionReplicaPlacement(Map<org.apache.hadoop.hbase.ServerName, List<org.apache.hadoop.hbase.client.RegionInfo>> serverMap, org.apache.hadoop.hbase.master.RackManager rackManager) Checks whether region replicas are not hosted on the same host. -
printStats
-
convertToList
protected List<org.apache.hadoop.hbase.master.balancer.ServerAndLoad> convertToList(Map<org.apache.hadoop.hbase.ServerName, List<org.apache.hadoop.hbase.client.RegionInfo>> servers) -
printMock
-
reconcile
protected List<org.apache.hadoop.hbase.master.balancer.ServerAndLoad> reconcile(List<org.apache.hadoop.hbase.master.balancer.ServerAndLoad> list, List<org.apache.hadoop.hbase.master.RegionPlan> plans, Map<org.apache.hadoop.hbase.ServerName, List<org.apache.hadoop.hbase.client.RegionInfo>> servers) This assumes the RegionPlan HSI instances are the same ones in the map, so actually no need to even pass in the map, but I think it's clearer.- Returns:
- a list of all added
ServerAndLoad
values.
-
updateLoad
protected void updateLoad(Map<org.apache.hadoop.hbase.ServerName, org.apache.hadoop.hbase.master.balancer.ServerAndLoad> map, org.apache.hadoop.hbase.ServerName sn, int diff) -
mockClusterServers
protected TreeMap<org.apache.hadoop.hbase.ServerName,List<org.apache.hadoop.hbase.client.RegionInfo>> mockClusterServers(int[][] mockCluster) -
mockClusterServers
protected TreeMap<org.apache.hadoop.hbase.ServerName,List<org.apache.hadoop.hbase.client.RegionInfo>> mockClusterServers(int[] mockCluster) -
mockCluster
protected org.apache.hadoop.hbase.master.balancer.BalancerClusterState mockCluster(int[] mockCluster) -
mockClusterServers
protected TreeMap<org.apache.hadoop.hbase.ServerName,List<org.apache.hadoop.hbase.client.RegionInfo>> mockClusterServers(int[] mockCluster, int numTables) -
mockClusterServersUnsorted
protected Map<org.apache.hadoop.hbase.ServerName,List<org.apache.hadoop.hbase.client.RegionInfo>> mockClusterServersUnsorted(int[] mockCluster, int numTables) -
mockUniformClusterServers
protected TreeMap<org.apache.hadoop.hbase.ServerName,List<org.apache.hadoop.hbase.client.RegionInfo>> mockUniformClusterServers(int[] mockCluster) -
mockClusterServersWithTables
-
randomRegions
-
createRegions
protected List<org.apache.hadoop.hbase.client.RegionInfo> createRegions(int numRegions, org.apache.hadoop.hbase.TableName tableName) -
randomRegions
protected List<org.apache.hadoop.hbase.client.RegionInfo> randomRegions(int numRegions, int numTables) -
uniformRegions
-
returnRegions
-
randomServer
protected org.apache.hadoop.hbase.master.balancer.ServerAndLoad randomServer(int numRegionsPerServer) -
randomServers
protected List<org.apache.hadoop.hbase.master.balancer.ServerAndLoad> randomServers(int numServers, int numRegionsPerServer) -
returnServer
-
returnServers
-
testWithCluster
protected void testWithCluster(int numNodes, int numRegions, int numRegionsPerServer, int replication, int numTables, boolean assertFullyBalanced, boolean assertFullyBalancedForReplicas) -
testWithClusterWithIteration
protected void testWithClusterWithIteration(int numNodes, int numRegions, int numRegionsPerServer, int replication, int numTables, boolean assertFullyBalanced, boolean assertFullyBalancedForReplicas) -
testWithCluster
protected void testWithCluster(Map<org.apache.hadoop.hbase.ServerName, List<org.apache.hadoop.hbase.client.RegionInfo>> serverMap, org.apache.hadoop.hbase.master.RackManager rackManager, boolean assertFullyBalanced, boolean assertFullyBalancedForReplicas) -
testWithClusterWithIteration
protected void testWithClusterWithIteration(Map<org.apache.hadoop.hbase.ServerName, List<org.apache.hadoop.hbase.client.RegionInfo>> serverMap, org.apache.hadoop.hbase.master.RackManager rackManager, boolean assertFullyBalanced, boolean assertFullyBalancedForReplicas) -
createServerMap
protected Map<org.apache.hadoop.hbase.ServerName,List<org.apache.hadoop.hbase.client.RegionInfo>> createServerMap(int numNodes, int numRegions, int numRegionsPerServer, int replication, int numTables)
-