Class TestRegionPlacement

java.lang.Object
org.apache.hadoop.hbase.master.TestRegionPlacement

public class TestRegionPlacement extends Object
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    private 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

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    private 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 plan
    private void
    verifyRegionAssignment(org.apache.hadoop.hbase.favored.FavoredNodesPlan plan, int regionMovementNum, int numRegionsOnPrimaryRS)
    To verify the region assignment status.
    private void
    Verify the number of region movement is expected
    private void
    verifyRegionOnPrimaryRS(int expectedNum)
    Verify the number of user regions is assigned to the primary region server based on the plan is expected
    private void
    verifyRegionServerUpdated(org.apache.hadoop.hbase.favored.FavoredNodesPlan plan)
    Verify all the online region servers has been updated to the latest assignment plan

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

  • Constructor Details

  • Method Details

    • setupBeforeClass

      public static void setupBeforeClass() throws Exception
      Throws:
      Exception
    • tearDownAfterClass

      public static void tearDownAfterClass() throws Exception
      Throws:
      Exception
    • testRegionPlacement

      public void testRegionPlacement() throws Exception
      Throws:
      Exception
    • killRandomServerAndVerifyAssignment

      private void killRandomServerAndVerifyAssignment() throws IOException, InterruptedException, org.apache.zookeeper.KeeperException
      Throws:
      IOException
      InterruptedException
      org.apache.zookeeper.KeeperException
    • testRandomizedMatrix

      public void 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 plan
      p1 - The first switch position
      p2 - 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

      private void verifyRegionMovementNum(int expected) throws InterruptedException, IOException
      Verify the number of region movement is expected
      Throws:
      InterruptedException
      IOException
    • verifyRegionOnPrimaryRS

      private void verifyRegionOnPrimaryRS(int expectedNum) throws IOException
      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

      private int getNumRegionisOnPrimaryRS() throws IOException
      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 created
      regionNum - number of regions to create
      Throws:
      IOException