Search in sources :

Example 11 with AssignmentManager

use of org.apache.hadoop.hbase.master.AssignmentManager in project hbase by apache.

the class TestHBaseFsckMOB method setUpBeforeClass.

@BeforeClass
public static void setUpBeforeClass() throws Exception {
    TEST_UTIL.getConfiguration().set(CoprocessorHost.MASTER_COPROCESSOR_CONF_KEY, MasterSyncObserver.class.getName());
    conf.setInt("hbase.regionserver.handler.count", 2);
    conf.setInt("hbase.regionserver.metahandler.count", 30);
    conf.setInt("hbase.htable.threads.max", POOL_SIZE);
    conf.setInt("hbase.hconnection.threads.max", 2 * POOL_SIZE);
    conf.setInt("hbase.hbck.close.timeout", 2 * REGION_ONLINE_TIMEOUT);
    conf.setInt(HConstants.HBASE_RPC_TIMEOUT_KEY, 8 * REGION_ONLINE_TIMEOUT);
    TEST_UTIL.startMiniCluster(1);
    tableExecutorService = new ThreadPoolExecutor(1, POOL_SIZE, 60, TimeUnit.SECONDS, new SynchronousQueue<>(), Threads.newDaemonThreadFactory("testhbck"));
    hbfsckExecutorService = new ScheduledThreadPoolExecutor(POOL_SIZE);
    AssignmentManager assignmentManager = TEST_UTIL.getHBaseCluster().getMaster().getAssignmentManager();
    regionStates = assignmentManager.getRegionStates();
    connection = (ClusterConnection) TEST_UTIL.getConnection();
    admin = connection.getAdmin();
    admin.setBalancerRunning(false, true);
    TEST_UTIL.waitUntilAllRegionsAssigned(TableName.META_TABLE_NAME);
    TEST_UTIL.waitUntilAllRegionsAssigned(TableName.NAMESPACE_TABLE_NAME);
}
Also used : ScheduledThreadPoolExecutor(java.util.concurrent.ScheduledThreadPoolExecutor) SynchronousQueue(java.util.concurrent.SynchronousQueue) AssignmentManager(org.apache.hadoop.hbase.master.AssignmentManager) ThreadPoolExecutor(java.util.concurrent.ThreadPoolExecutor) ScheduledThreadPoolExecutor(java.util.concurrent.ScheduledThreadPoolExecutor) BeforeClass(org.junit.BeforeClass)

Example 12 with AssignmentManager

use of org.apache.hadoop.hbase.master.AssignmentManager in project hbase by apache.

the class TestHBaseFsckReplicas method setUpBeforeClass.

@BeforeClass
public static void setUpBeforeClass() throws Exception {
    TEST_UTIL.getConfiguration().set(CoprocessorHost.MASTER_COPROCESSOR_CONF_KEY, MasterSyncObserver.class.getName());
    conf.setInt("hbase.regionserver.handler.count", 2);
    conf.setInt("hbase.regionserver.metahandler.count", 30);
    conf.setInt("hbase.htable.threads.max", POOL_SIZE);
    conf.setInt("hbase.hconnection.threads.max", 2 * POOL_SIZE);
    conf.setInt("hbase.hbck.close.timeout", 2 * REGION_ONLINE_TIMEOUT);
    conf.setInt(HConstants.HBASE_RPC_TIMEOUT_KEY, 8 * REGION_ONLINE_TIMEOUT);
    TEST_UTIL.startMiniCluster(3);
    tableExecutorService = new ThreadPoolExecutor(1, POOL_SIZE, 60, TimeUnit.SECONDS, new SynchronousQueue<>(), Threads.newDaemonThreadFactory("testhbck"));
    hbfsckExecutorService = new ScheduledThreadPoolExecutor(POOL_SIZE);
    AssignmentManager assignmentManager = TEST_UTIL.getHBaseCluster().getMaster().getAssignmentManager();
    regionStates = assignmentManager.getRegionStates();
    connection = (ClusterConnection) TEST_UTIL.getConnection();
    admin = connection.getAdmin();
    admin.setBalancerRunning(false, true);
    TEST_UTIL.waitUntilAllRegionsAssigned(TableName.META_TABLE_NAME);
    TEST_UTIL.waitUntilAllRegionsAssigned(TableName.NAMESPACE_TABLE_NAME);
}
Also used : ScheduledThreadPoolExecutor(java.util.concurrent.ScheduledThreadPoolExecutor) SynchronousQueue(java.util.concurrent.SynchronousQueue) AssignmentManager(org.apache.hadoop.hbase.master.AssignmentManager) ThreadPoolExecutor(java.util.concurrent.ThreadPoolExecutor) ScheduledThreadPoolExecutor(java.util.concurrent.ScheduledThreadPoolExecutor) BeforeClass(org.junit.BeforeClass)

Example 13 with AssignmentManager

use of org.apache.hadoop.hbase.master.AssignmentManager in project hbase by apache.

the class TestRegionMergeTransactionOnCluster method testWholesomeMerge.

@Test
public void testWholesomeMerge() throws Exception {
    LOG.info("Starting " + name.getMethodName());
    final TableName tableName = TableName.valueOf(name.getMethodName());
    // Create table and load data.
    Table table = createTableAndLoadData(MASTER, tableName);
    // Merge 1st and 2nd region
    mergeRegionsAndVerifyRegionNum(MASTER, tableName, 0, 1, INITIAL_REGION_NUM - 1);
    // Merge 2nd and 3th region
    PairOfSameType<HRegionInfo> mergedRegions = mergeRegionsAndVerifyRegionNum(MASTER, tableName, 1, 2, INITIAL_REGION_NUM - 2);
    verifyRowCount(table, ROWSIZE);
    // Randomly choose one of the two merged regions
    HRegionInfo hri = RandomUtils.nextBoolean() ? mergedRegions.getFirst() : mergedRegions.getSecond();
    MiniHBaseCluster cluster = TEST_UTIL.getHBaseCluster();
    AssignmentManager am = cluster.getMaster().getAssignmentManager();
    RegionStates regionStates = am.getRegionStates();
    long start = EnvironmentEdgeManager.currentTime();
    while (!regionStates.isRegionInState(hri, State.MERGED)) {
        assertFalse("Timed out in waiting one merged region to be in state MERGED", EnvironmentEdgeManager.currentTime() - start > 60000);
        Thread.sleep(500);
    }
    // We should not be able to assign it again
    am.assign(hri, true);
    assertFalse("Merged region can't be assigned", regionStates.isRegionInTransition(hri));
    assertTrue(regionStates.isRegionInState(hri, State.MERGED));
    // We should not be able to unassign it either
    am.unassign(hri, null);
    assertFalse("Merged region can't be unassigned", regionStates.isRegionInTransition(hri));
    assertTrue(regionStates.isRegionInState(hri, State.MERGED));
    table.close();
}
Also used : HRegionInfo(org.apache.hadoop.hbase.HRegionInfo) TableName(org.apache.hadoop.hbase.TableName) Table(org.apache.hadoop.hbase.client.Table) RegionStates(org.apache.hadoop.hbase.master.RegionStates) AssignmentManager(org.apache.hadoop.hbase.master.AssignmentManager) MiniHBaseCluster(org.apache.hadoop.hbase.MiniHBaseCluster) Test(org.junit.Test)

Example 14 with AssignmentManager

use of org.apache.hadoop.hbase.master.AssignmentManager in project hbase by apache.

the class TestSplitTransactionOnCluster method testSplitRegionWithNoStoreFiles.

/**
   * If a table has regions that have no store files in a region, they should split successfully
   * into two regions with no store files.
   */
@Test(timeout = 60000)
public void testSplitRegionWithNoStoreFiles() throws Exception {
    final TableName tableName = TableName.valueOf(name.getMethodName());
    // Create table then get the single region for our new table.
    createTableAndWait(tableName, HConstants.CATALOG_FAMILY);
    List<HRegion> regions = cluster.getRegions(tableName);
    HRegionInfo hri = getAndCheckSingleTableRegion(regions);
    ensureTableRegionNotOnSameServerAsMeta(admin, hri);
    int regionServerIndex = cluster.getServerWith(regions.get(0).getRegionInfo().getRegionName());
    HRegionServer regionServer = cluster.getRegionServer(regionServerIndex);
    // Turn off balancer so it doesn't cut in and mess up our placements.
    this.admin.setBalancerRunning(false, true);
    // Turn off the meta scanner so it don't remove parent on us.
    cluster.getMaster().setCatalogJanitorEnabled(false);
    try {
        // Precondition: we created a table with no data, no store files.
        printOutRegions(regionServer, "Initial regions: ");
        Configuration conf = cluster.getConfiguration();
        HBaseFsck.debugLsr(conf, new Path("/"));
        Path rootDir = FSUtils.getRootDir(conf);
        FileSystem fs = TESTING_UTIL.getDFSCluster().getFileSystem();
        Map<String, Path> storefiles = FSUtils.getTableStoreFilePathMap(null, fs, rootDir, tableName);
        assertEquals("Expected nothing but found " + storefiles.toString(), storefiles.size(), 0);
        // find a splittable region.  Refresh the regions list
        regions = cluster.getRegions(tableName);
        final HRegion region = findSplittableRegion(regions);
        assertTrue("not able to find a splittable region", region != null);
        // Now split.
        try {
            requestSplitRegion(regionServer, region, Bytes.toBytes("row2"));
        } catch (IOException e) {
            fail("Split execution should have succeeded with no exceptions thrown");
        }
        // Postcondition: split the table with no store files into two regions, but still have not
        // store files
        List<HRegion> daughters = cluster.getRegions(tableName);
        assertTrue(daughters.size() == 2);
        // check dirs
        HBaseFsck.debugLsr(conf, new Path("/"));
        Map<String, Path> storefilesAfter = FSUtils.getTableStoreFilePathMap(null, fs, rootDir, tableName);
        assertEquals("Expected nothing but found " + storefilesAfter.toString(), storefilesAfter.size(), 0);
        // split parent
        hri = region.getRegionInfo();
        AssignmentManager am = cluster.getMaster().getAssignmentManager();
        RegionStates regionStates = am.getRegionStates();
        long start = EnvironmentEdgeManager.currentTime();
        while (!regionStates.isRegionInState(hri, State.SPLIT)) {
            assertFalse("Timed out in waiting split parent to be in state SPLIT", EnvironmentEdgeManager.currentTime() - start > 60000);
            Thread.sleep(500);
        }
        // We should not be able to assign it again
        am.assign(hri, true);
        assertFalse("Split region can't be assigned", regionStates.isRegionInTransition(hri));
        assertTrue(regionStates.isRegionInState(hri, State.SPLIT));
        // We should not be able to unassign it either
        am.unassign(hri, null);
        assertFalse("Split region can't be unassigned", regionStates.isRegionInTransition(hri));
        assertTrue(regionStates.isRegionInState(hri, State.SPLIT));
    } finally {
        admin.setBalancerRunning(true, false);
        cluster.getMaster().setCatalogJanitorEnabled(true);
    }
}
Also used : Path(org.apache.hadoop.fs.Path) Configuration(org.apache.hadoop.conf.Configuration) AssignmentManager(org.apache.hadoop.hbase.master.AssignmentManager) InterruptedIOException(java.io.InterruptedIOException) IOException(java.io.IOException) HRegionInfo(org.apache.hadoop.hbase.HRegionInfo) TableName(org.apache.hadoop.hbase.TableName) RegionStates(org.apache.hadoop.hbase.master.RegionStates) FileSystem(org.apache.hadoop.fs.FileSystem) Test(org.junit.Test)

Example 15 with AssignmentManager

use of org.apache.hadoop.hbase.master.AssignmentManager in project hbase by apache.

the class TestHBaseFsckTwoRS method setUpBeforeClass.

@BeforeClass
public static void setUpBeforeClass() throws Exception {
    TEST_UTIL.getConfiguration().set(CoprocessorHost.MASTER_COPROCESSOR_CONF_KEY, MasterSyncObserver.class.getName());
    conf.setInt("hbase.regionserver.handler.count", 2);
    conf.setInt("hbase.regionserver.metahandler.count", 30);
    conf.setInt("hbase.htable.threads.max", POOL_SIZE);
    conf.setInt("hbase.hconnection.threads.max", 2 * POOL_SIZE);
    conf.setInt("hbase.hbck.close.timeout", 2 * REGION_ONLINE_TIMEOUT);
    conf.setInt(HConstants.HBASE_RPC_TIMEOUT_KEY, 8 * REGION_ONLINE_TIMEOUT);
    TEST_UTIL.startMiniCluster(2);
    tableExecutorService = new ThreadPoolExecutor(1, POOL_SIZE, 60, TimeUnit.SECONDS, new SynchronousQueue<>(), Threads.newDaemonThreadFactory("testhbck"));
    hbfsckExecutorService = new ScheduledThreadPoolExecutor(POOL_SIZE);
    AssignmentManager assignmentManager = TEST_UTIL.getHBaseCluster().getMaster().getAssignmentManager();
    regionStates = assignmentManager.getRegionStates();
    connection = (ClusterConnection) TEST_UTIL.getConnection();
    admin = connection.getAdmin();
    admin.setBalancerRunning(false, true);
    TEST_UTIL.waitUntilAllRegionsAssigned(TableName.META_TABLE_NAME);
    TEST_UTIL.waitUntilAllRegionsAssigned(TableName.NAMESPACE_TABLE_NAME);
}
Also used : ScheduledThreadPoolExecutor(java.util.concurrent.ScheduledThreadPoolExecutor) SynchronousQueue(java.util.concurrent.SynchronousQueue) AssignmentManager(org.apache.hadoop.hbase.master.AssignmentManager) ThreadPoolExecutor(java.util.concurrent.ThreadPoolExecutor) ScheduledThreadPoolExecutor(java.util.concurrent.ScheduledThreadPoolExecutor) BeforeClass(org.junit.BeforeClass)

Aggregations

AssignmentManager (org.apache.hadoop.hbase.master.AssignmentManager)24 HRegionInfo (org.apache.hadoop.hbase.HRegionInfo)13 ServerName (org.apache.hadoop.hbase.ServerName)6 TableName (org.apache.hadoop.hbase.TableName)6 RegionStates (org.apache.hadoop.hbase.master.RegionStates)6 ScheduledThreadPoolExecutor (java.util.concurrent.ScheduledThreadPoolExecutor)4 SynchronousQueue (java.util.concurrent.SynchronousQueue)4 ThreadPoolExecutor (java.util.concurrent.ThreadPoolExecutor)4 MiniHBaseCluster (org.apache.hadoop.hbase.MiniHBaseCluster)4 RegionState (org.apache.hadoop.hbase.master.RegionState)4 BeforeClass (org.junit.BeforeClass)4 Test (org.junit.Test)4 ArrayList (java.util.ArrayList)3 HashMap (java.util.HashMap)3 HMaster (org.apache.hadoop.hbase.master.HMaster)3 MasterWalManager (org.apache.hadoop.hbase.master.MasterWalManager)3 IOException (java.io.IOException)2 InterruptedIOException (java.io.InterruptedIOException)2 List (java.util.List)2 Map (java.util.Map)2