Search in sources :

Example 21 with AssignmentManager

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

the class ServerCrashProcedure method zkCoordinatedSplitMetaLogs.

/**
 * Split hbase:meta logs using 'classic' zk-based coordination.
 * Superceded by procedure-based WAL splitting.
 * @see #createSplittingWalProcedures(MasterProcedureEnv, boolean)
 */
private void zkCoordinatedSplitMetaLogs(MasterProcedureEnv env) throws IOException {
    LOG.debug("Splitting meta WALs {}", this);
    MasterWalManager mwm = env.getMasterServices().getMasterWalManager();
    AssignmentManager am = env.getMasterServices().getAssignmentManager();
    am.getRegionStates().metaLogSplitting(serverName);
    mwm.splitMetaLog(serverName);
    am.getRegionStates().metaLogSplit(serverName);
    LOG.debug("Done splitting meta WALs {}", this);
}
Also used : MasterWalManager(org.apache.hadoop.hbase.master.MasterWalManager) AssignmentManager(org.apache.hadoop.hbase.master.assignment.AssignmentManager)

Example 22 with AssignmentManager

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

the class HBaseTestingUtil method assignRegion.

/**
 * Uses directly the assignment manager to assign the region. and waits until the specified region
 * has completed assignment.
 * @return true if the region is assigned false otherwise.
 */
public boolean assignRegion(final RegionInfo regionInfo) throws IOException, InterruptedException {
    final AssignmentManager am = getHBaseCluster().getMaster().getAssignmentManager();
    am.assign(regionInfo);
    return AssignmentTestingUtil.waitForAssignment(am, regionInfo);
}
Also used : AssignmentManager(org.apache.hadoop.hbase.master.assignment.AssignmentManager)

Example 23 with AssignmentManager

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

the class TestAsyncRegionAdminApi method testAssignRegionAndUnassignRegion.

@Test
public void testAssignRegionAndUnassignRegion() throws Exception {
    createTableWithDefaultConf(tableName);
    // assign region.
    HMaster master = TEST_UTIL.getHBaseCluster().getMaster();
    AssignmentManager am = master.getAssignmentManager();
    RegionInfo hri = am.getRegionStates().getRegionsOfTable(tableName).get(0);
    // assert region on server
    RegionStates regionStates = am.getRegionStates();
    ServerName serverName = regionStates.getRegionServerOfRegion(hri);
    TEST_UTIL.assertRegionOnServer(hri, serverName, 200);
    assertTrue(regionStates.getRegionState(hri).isOpened());
    // Master should not abort, and region should stay assigned.
    try {
        admin.assign(hri.getRegionName()).get();
        fail("Should fail when assigning an already onlined region");
    } catch (ExecutionException e) {
        // Expected
        assertThat(e.getCause(), instanceOf(DoNotRetryRegionException.class));
    }
    assertFalse(am.getRegionStates().getRegionStateNode(hri).isInTransition());
    assertTrue(regionStates.getRegionState(hri).isOpened());
    // unassign region
    admin.unassign(hri.getRegionName(), true).get();
    assertFalse(am.getRegionStates().getRegionStateNode(hri).isInTransition());
    assertTrue(regionStates.getRegionState(hri).isClosed());
}
Also used : RegionStates(org.apache.hadoop.hbase.master.assignment.RegionStates) ServerName(org.apache.hadoop.hbase.ServerName) HMaster(org.apache.hadoop.hbase.master.HMaster) AssignmentManager(org.apache.hadoop.hbase.master.assignment.AssignmentManager) ExecutionException(java.util.concurrent.ExecutionException) Test(org.junit.Test)

Example 24 with AssignmentManager

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

the class TestFailedMetaReplicaAssigment method testFailedReplicaAssignment.

@Test
public void testFailedReplicaAssignment() throws InterruptedException {
    HMaster master = TEST_UTIL.getMiniHBaseCluster().getMaster();
    // waiting for master to come up
    TEST_UTIL.waitFor(30000, () -> master.isInitialized());
    AssignmentManager am = master.getAssignmentManager();
    // showing one of the replicas got assigned
    RegionInfo metaReplicaHri = RegionReplicaUtil.getRegionInfoForReplica(RegionInfoBuilder.FIRST_META_REGIONINFO, 1);
    // we use assignAsync so we need to wait a bit
    TEST_UTIL.waitFor(30000, () -> {
        RegionStateNode metaReplicaRegionNode = am.getRegionStates().getOrCreateRegionStateNode(metaReplicaHri);
        return metaReplicaRegionNode.getRegionLocation() != null;
    });
    // showing one of the replicas failed to be assigned
    RegionInfo metaReplicaHri2 = RegionReplicaUtil.getRegionInfoForReplica(RegionInfoBuilder.FIRST_META_REGIONINFO, 2);
    RegionStateNode metaReplicaRegionNode2 = am.getRegionStates().getOrCreateRegionStateNode(metaReplicaHri2);
    // wait for several seconds to make sure that it is not assigned
    for (int i = 0; i < 3; i++) {
        Thread.sleep(2000);
        assertNull(metaReplicaRegionNode2.getRegionLocation());
    }
    // showing master is active and running
    assertFalse(master.isStopping());
    assertFalse(master.isStopped());
    assertTrue(master.isActiveMaster());
}
Also used : HMaster(org.apache.hadoop.hbase.master.HMaster) AssignmentManager(org.apache.hadoop.hbase.master.assignment.AssignmentManager) RegionStateNode(org.apache.hadoop.hbase.master.assignment.RegionStateNode) Test(org.junit.Test)

Example 25 with AssignmentManager

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

the class MasterProcedureTestingUtility method restartMasterProcedureExecutor.

public static void restartMasterProcedureExecutor(ProcedureExecutor<MasterProcedureEnv> procExec) throws Exception {
    final MasterProcedureEnv env = procExec.getEnvironment();
    final HMaster master = (HMaster) env.getMasterServices();
    ProcedureTestingUtility.restart(procExec, true, true, // stop services
    new Callable<Void>() {

        @Override
        public Void call() throws Exception {
            AssignmentManager am = env.getAssignmentManager();
            // try to simulate a master restart by removing the ServerManager states about seqIDs
            for (RegionState regionState : am.getRegionStates().getRegionStates()) {
                env.getMasterServices().getServerManager().removeRegion(regionState.getRegion());
            }
            am.stop();
            master.setInitialized(false);
            return null;
        }
    }, // setup RIT before starting workers
    new Callable<Void>() {

        @Override
        public Void call() throws Exception {
            AssignmentManager am = env.getAssignmentManager();
            am.start();
            // just follow the same way with HMaster.finishActiveMasterInitialization. See the
            // comments there
            am.setupRIT(procExec.getActiveProceduresNoCopy().stream().filter(p -> !p.isSuccess()).filter(p -> p instanceof TransitRegionStateProcedure).map(p -> (TransitRegionStateProcedure) p).collect(Collectors.toList()));
            return null;
        }
    }, // restart services
    new Callable<Void>() {

        @Override
        public Void call() throws Exception {
            AssignmentManager am = env.getAssignmentManager();
            try {
                am.joinCluster();
                am.wakeMetaLoadedEvent();
                master.setInitialized(true);
            } catch (Exception e) {
                LOG.warn("Failed to load meta", e);
            }
            return null;
        }
    });
}
Also used : CatalogFamilyFormat(org.apache.hadoop.hbase.CatalogFamilyFormat) Result(org.apache.hadoop.hbase.client.Result) FileSystem(org.apache.hadoop.fs.FileSystem) RegionLocations(org.apache.hadoop.hbase.RegionLocations) LoggerFactory(org.slf4j.LoggerFactory) RegionState(org.apache.hadoop.hbase.master.RegionState) MD5Hash(org.apache.hadoop.hbase.util.MD5Hash) ProcedureExecutor(org.apache.hadoop.hbase.procedure2.ProcedureExecutor) AtomicInteger(java.util.concurrent.atomic.AtomicInteger) Path(org.apache.hadoop.fs.Path) ColumnFamilyDescriptor(org.apache.hadoop.hbase.client.ColumnFamilyDescriptor) BufferedMutator(org.apache.hadoop.hbase.client.BufferedMutator) Durability(org.apache.hadoop.hbase.client.Durability) TableStateManager(org.apache.hadoop.hbase.master.TableStateManager) CommonFSUtils(org.apache.hadoop.hbase.util.CommonFSUtils) HBaseTestingUtil(org.apache.hadoop.hbase.HBaseTestingUtil) Collectors(java.util.stream.Collectors) List(java.util.List) Assert.assertFalse(org.junit.Assert.assertFalse) StoreFileTrackerFactory(org.apache.hadoop.hbase.regionserver.storefiletracker.StoreFileTrackerFactory) EnvironmentEdgeManager(org.apache.hadoop.hbase.util.EnvironmentEdgeManager) TRACKER_IMPL(org.apache.hadoop.hbase.regionserver.storefiletracker.StoreFileTrackerFactory.TRACKER_IMPL) MetaTableAccessor(org.apache.hadoop.hbase.MetaTableAccessor) TableDescriptor(org.apache.hadoop.hbase.client.TableDescriptor) HMaster(org.apache.hadoop.hbase.master.HMaster) FSUtils(org.apache.hadoop.hbase.util.FSUtils) StateMachineProcedure(org.apache.hadoop.hbase.procedure2.StateMachineProcedure) AssignmentManager(org.apache.hadoop.hbase.master.assignment.AssignmentManager) ModifyRegionUtils(org.apache.hadoop.hbase.util.ModifyRegionUtils) Callable(java.util.concurrent.Callable) SingleProcessHBaseCluster(org.apache.hadoop.hbase.SingleProcessHBaseCluster) TableState(org.apache.hadoop.hbase.client.TableState) TreeSet(java.util.TreeSet) TableDescriptorBuilder(org.apache.hadoop.hbase.client.TableDescriptorBuilder) ColumnFamilyDescriptorBuilder(org.apache.hadoop.hbase.client.ColumnFamilyDescriptorBuilder) ServerName(org.apache.hadoop.hbase.ServerName) Bytes(org.apache.hadoop.hbase.util.Bytes) TableName(org.apache.hadoop.hbase.TableName) Logger(org.slf4j.Logger) Put(org.apache.hadoop.hbase.client.Put) Assert.assertTrue(org.junit.Assert.assertTrue) ProcedureTestingUtility(org.apache.hadoop.hbase.procedure2.ProcedureTestingUtility) IOException(java.io.IOException) Procedure(org.apache.hadoop.hbase.procedure2.Procedure) ClientMetaTableAccessor(org.apache.hadoop.hbase.ClientMetaTableAccessor) InterfaceAudience(org.apache.yetus.audience.InterfaceAudience) Admin(org.apache.hadoop.hbase.client.Admin) HRegionLocation(org.apache.hadoop.hbase.HRegionLocation) TransitRegionStateProcedure(org.apache.hadoop.hbase.master.assignment.TransitRegionStateProcedure) Connection(org.apache.hadoop.hbase.client.Connection) RegionInfo(org.apache.hadoop.hbase.client.RegionInfo) Assert.assertEquals(org.junit.Assert.assertEquals) RegionState(org.apache.hadoop.hbase.master.RegionState) TransitRegionStateProcedure(org.apache.hadoop.hbase.master.assignment.TransitRegionStateProcedure) HMaster(org.apache.hadoop.hbase.master.HMaster) AssignmentManager(org.apache.hadoop.hbase.master.assignment.AssignmentManager) IOException(java.io.IOException)

Aggregations

AssignmentManager (org.apache.hadoop.hbase.master.assignment.AssignmentManager)30 RegionInfo (org.apache.hadoop.hbase.client.RegionInfo)13 Test (org.junit.Test)13 TableName (org.apache.hadoop.hbase.TableName)10 HMaster (org.apache.hadoop.hbase.master.HMaster)10 IOException (java.io.IOException)9 RegionStates (org.apache.hadoop.hbase.master.assignment.RegionStates)9 ServerName (org.apache.hadoop.hbase.ServerName)7 RegionStateNode (org.apache.hadoop.hbase.master.assignment.RegionStateNode)6 TransitRegionStateProcedure (org.apache.hadoop.hbase.master.assignment.TransitRegionStateProcedure)5 ArrayList (java.util.ArrayList)4 DoNotRetryIOException (org.apache.hadoop.hbase.DoNotRetryIOException)4 List (java.util.List)3 Map (java.util.Map)3 Path (org.apache.hadoop.fs.Path)3 SingleProcessHBaseCluster (org.apache.hadoop.hbase.SingleProcessHBaseCluster)3 Admin (org.apache.hadoop.hbase.client.Admin)3 HashMap (java.util.HashMap)2 HashSet (java.util.HashSet)2 ExecutionException (java.util.concurrent.ExecutionException)2