Package org.apache.hadoop.hbase.master
Class TestRegionPlacement
java.lang.Object
org.apache.hadoop.hbase.master.TestRegionPlacement
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate static org.apache.hadoop.hbase.client.Adminstatic final HBaseClassTestRuleprivate static org.apache.hadoop.hbase.client.Connectionprivate Map<org.apache.hadoop.hbase.client.RegionInfo,org.apache.hadoop.hbase.ServerName[]> private intprivate static final org.slf4j.Loggerprivate static org.apache.hadoop.hbase.favored.FavoredNodesPlan.Position[]private intprivate static org.apache.hadoop.hbase.master.RegionPlacementMaintainerprivate static final intprivate static final HBaseTestingUtil -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprivate static voidcreateTable(org.apache.hadoop.hbase.TableName tableName, int regionNum) Create a table with specified table name and region number.private intCheck whether regions are assigned to servers consistent with the explicit hints that are persisted in the hbase:meta table.private voidstatic voidprivate org.apache.hadoop.hbase.favored.FavoredNodesPlanshuffleAssignmentPlan(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 voidvoidUsed to test the correctness of this class.voidprivate voidverifyMETAUpdated(org.apache.hadoop.hbase.favored.FavoredNodesPlan expectedPlan) Verify the meta has updated to the latest assignment planprivate voidverifyRegionAssignment(org.apache.hadoop.hbase.favored.FavoredNodesPlan plan, int regionMovementNum, int numRegionsOnPrimaryRS) To verify the region assignment status.private voidverifyRegionMovementNum(int expected) Verify the number of region movement is expectedprivate voidverifyRegionOnPrimaryRS(int expectedNum) Verify the number of user regions is assigned to the primary region server based on the plan is expectedprivate voidverifyRegionServerUpdated(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:
IOExceptionInterruptedExceptionorg.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:
InterruptedExceptionIOException
-
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:
InterruptedExceptionIOException
-
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
-