Package org.apache.hadoop.hbase.master
Class TestRegionPlacement
java.lang.Object
org.apache.hadoop.hbase.master.TestRegionPlacement
-
Field Summary
Modifier and TypeFieldDescriptionprivate static org.apache.hadoop.hbase.client.Admin
static final HBaseClassTestRule
private static org.apache.hadoop.hbase.client.Connection
private Map<org.apache.hadoop.hbase.client.RegionInfo,
org.apache.hadoop.hbase.ServerName[]> private int
private static final org.slf4j.Logger
private static org.apache.hadoop.hbase.favored.FavoredNodesPlan.Position[]
private int
private static org.apache.hadoop.hbase.master.RegionPlacementMaintainer
private static final int
private static final HBaseTestingUtility
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionprivate static void
createTable
(org.apache.hadoop.hbase.TableName tableName, int regionNum) Create a table with specified table name and region number.private int
Check whether regions are assigned to servers consistent with the explicit hints that are persisted in the hbase:meta table.private void
static void
private org.apache.hadoop.hbase.favored.FavoredNodesPlan
shuffleAssignmentPlan
(org.apache.hadoop.hbase.favored.FavoredNodesPlan plan, org.apache.hadoop.hbase.favored.FavoredNodesPlan.Position p1, org.apache.hadoop.hbase.favored.FavoredNodesPlan.Position p2) Shuffle the assignment plan by switching two favored node positions.static void
void
Used to test the correctness of this class.void
private void
verifyMETAUpdated
(org.apache.hadoop.hbase.favored.FavoredNodesPlan expectedPlan) Verify the meta has updated to the latest assignment planprivate void
verifyRegionAssignment
(org.apache.hadoop.hbase.favored.FavoredNodesPlan plan, int regionMovementNum, int numRegionsOnPrimaryRS) To verify the region assignment status.private void
verifyRegionMovementNum
(int expected) Verify the number of region movement is expectedprivate void
verifyRegionOnPrimaryRS
(int expectedNum) Verify the number of user regions is assigned to the primary region server based on the plan is expectedprivate void
verifyRegionServerUpdated
(org.apache.hadoop.hbase.favored.FavoredNodesPlan plan) Verify all the online region servers has been updated to the latest assignment plan
-
Field Details
-
CLASS_RULE
-
LOG
-
TEST_UTIL
-
SLAVES
- See Also:
-
CONNECTION
-
admin
-
rp
-
positions
-
lastRegionOnPrimaryRSCount
-
REGION_NUM
-
favoredNodesAssignmentPlan
private Map<org.apache.hadoop.hbase.client.RegionInfo,org.apache.hadoop.hbase.ServerName[]> favoredNodesAssignmentPlan
-
-
Constructor Details
-
TestRegionPlacement
public TestRegionPlacement()
-
-
Method Details
-
setupBeforeClass
- Throws:
Exception
-
tearDownAfterClass
- Throws:
Exception
-
testRegionPlacement
- Throws:
Exception
-
killRandomServerAndVerifyAssignment
private void killRandomServerAndVerifyAssignment() throws IOException, InterruptedException, org.apache.zookeeper.KeeperException- Throws:
IOException
InterruptedException
org.apache.zookeeper.KeeperException
-
testRandomizedMatrix
Used to test the correctness of this class. -
shuffleAssignmentPlan
private org.apache.hadoop.hbase.favored.FavoredNodesPlan shuffleAssignmentPlan(org.apache.hadoop.hbase.favored.FavoredNodesPlan plan, org.apache.hadoop.hbase.favored.FavoredNodesPlan.Position p1, org.apache.hadoop.hbase.favored.FavoredNodesPlan.Position p2) throws IOException Shuffle the assignment plan by switching two favored node positions.- Parameters:
plan
- The assignment planp1
- The first switch positionp2
- The second switch position- Returns:
- the shuffled assignment plan
- Throws:
IOException
-
verifyRegionAssignment
private void verifyRegionAssignment(org.apache.hadoop.hbase.favored.FavoredNodesPlan plan, int regionMovementNum, int numRegionsOnPrimaryRS) throws InterruptedException, IOException To verify the region assignment status. It will check the assignment plan consistency between hbase:meta and region servers. Also it will verify weather the number of region movement and the number regions on the primary region server are expected- Throws:
InterruptedException
IOException
-
verifyMETAUpdated
private void verifyMETAUpdated(org.apache.hadoop.hbase.favored.FavoredNodesPlan expectedPlan) throws IOException Verify the meta has updated to the latest assignment plan- Parameters:
expectedPlan
- the region assignment plan- Throws:
IOException
- if an IO problem is encountered
-
verifyRegionMovementNum
Verify the number of region movement is expected- Throws:
InterruptedException
IOException
-
verifyRegionOnPrimaryRS
Verify the number of user regions is assigned to the primary region server based on the plan is expected- Parameters:
expectedNum
- the expected number of assigned regions- Throws:
IOException
-
verifyRegionServerUpdated
private void verifyRegionServerUpdated(org.apache.hadoop.hbase.favored.FavoredNodesPlan plan) throws IOException Verify all the online region servers has been updated to the latest assignment plan- Throws:
IOException
-
getNumRegionisOnPrimaryRS
Check whether regions are assigned to servers consistent with the explicit hints that are persisted in the hbase:meta table. Also keep track of the number of the regions are assigned to the primary region server.- Returns:
- the number of regions are assigned to the primary region server
- Throws:
IOException
-
createTable
private static void createTable(org.apache.hadoop.hbase.TableName tableName, int regionNum) throws IOException Create a table with specified table name and region number.- Parameters:
tableName
- the name of the table to be createdregionNum
- number of regions to create- Throws:
IOException
-