Search in sources :

Example 1 with GCRegionProcedure

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

the class CatalogJanitor method cleanParent.

static boolean cleanParent(MasterServices services, RegionInfo parent, Result rowContent) throws IOException {
    if (LOG.isDebugEnabled()) {
        LOG.debug("Cleaning parent region {}", parent);
    }
    // Check whether it is a merged region and if it is clean of references.
    if (CatalogFamilyFormat.hasMergeRegions(rowContent.rawCells())) {
        // Wait until clean of merge parent regions first
        if (LOG.isDebugEnabled()) {
            LOG.debug("Region {} has merge parents, cleaning them first", parent);
        }
        return false;
    }
    // Run checks on each daughter split.
    PairOfSameType<RegionInfo> daughters = MetaTableAccessor.getDaughterRegions(rowContent);
    Pair<Boolean, Boolean> a = checkDaughterInFs(services, parent, daughters.getFirst());
    Pair<Boolean, Boolean> b = checkDaughterInFs(services, parent, daughters.getSecond());
    if (hasNoReferences(a) && hasNoReferences(b)) {
        String daughterA = daughters.getFirst() != null ? daughters.getFirst().getShortNameToLog() : "null";
        String daughterB = daughters.getSecond() != null ? daughters.getSecond().getShortNameToLog() : "null";
        if (LOG.isDebugEnabled()) {
            LOG.debug("Deleting region " + parent.getShortNameToLog() + " because daughters -- " + daughterA + ", " + daughterB + " -- no longer hold references");
        }
        ProcedureExecutor<MasterProcedureEnv> pe = services.getMasterProcedureExecutor();
        GCRegionProcedure gcRegionProcedure = new GCRegionProcedure(pe.getEnvironment(), parent);
        pe.submitProcedure(gcRegionProcedure);
        if (LOG.isDebugEnabled()) {
            LOG.debug("Submitted procedure {} for split parent {}", gcRegionProcedure, parent);
        }
        return true;
    } else {
        if (LOG.isDebugEnabled()) {
            if (!hasNoReferences(a)) {
                LOG.debug("Deferring removal of region {} because daughter {} still has references", parent, daughters.getFirst());
            }
            if (!hasNoReferences(b)) {
                LOG.debug("Deferring removal of region {} because daughter {} still has references", parent, daughters.getSecond());
            }
        }
    }
    return false;
}
Also used : RegionInfo(org.apache.hadoop.hbase.client.RegionInfo) MasterProcedureEnv(org.apache.hadoop.hbase.master.procedure.MasterProcedureEnv) GCRegionProcedure(org.apache.hadoop.hbase.master.assignment.GCRegionProcedure) AtomicBoolean(java.util.concurrent.atomic.AtomicBoolean)

Example 2 with GCRegionProcedure

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

the class TestMetaFixer method testOverlapWithMergeOfNonContiguous.

/**
 * Make it so a big overlap spans many Regions, some of which are non-contiguous. Make it so
 * we can fix this condition. HBASE-24247
 */
@Test
public void testOverlapWithMergeOfNonContiguous() throws Exception {
    TableName tn = TableName.valueOf(this.name.getMethodName());
    TEST_UTIL.createMultiRegionTable(tn, HConstants.CATALOG_FAMILY);
    List<RegionInfo> ris = MetaTableAccessor.getTableRegions(TEST_UTIL.getConnection(), tn);
    assertTrue(ris.size() > 5);
    MasterServices services = TEST_UTIL.getHBaseCluster().getMaster();
    services.getCatalogJanitor().scan();
    Report report = services.getCatalogJanitor().getLastReport();
    assertTrue(report.isEmpty());
    // Make a simple overlap spanning second and third region.
    makeOverlap(services, ris.get(1), ris.get(5));
    // Now Delete a region under the overlap to manufacture non-contiguous sub regions.
    RegionInfo deletedRegion = ris.get(3);
    long pid = services.getAssignmentManager().unassign(deletedRegion);
    while (!services.getMasterProcedureExecutor().isFinished(pid)) {
        Threads.sleep(100);
    }
    GCRegionProcedure procedure = new GCRegionProcedure(services.getMasterProcedureExecutor().getEnvironment(), ris.get(3));
    pid = services.getMasterProcedureExecutor().submitProcedure(procedure);
    while (!services.getMasterProcedureExecutor().isFinished(pid)) {
        Threads.sleep(100);
    }
    services.getCatalogJanitor().scan();
    report = services.getCatalogJanitor().getLastReport();
    assertEquals(1, MetaFixer.calculateMerges(10, report.getOverlaps()).size());
    MetaFixer fixer = new MetaFixer(services);
    fixer.fixOverlaps(report);
    HBaseTestingUtil.await(10, () -> {
        try {
            services.getCatalogJanitor().scan();
            final Report postReport = services.getCatalogJanitor().getLastReport();
            return postReport.isEmpty();
        } catch (Exception e) {
            throw new RuntimeException(e);
        }
    });
}
Also used : TableName(org.apache.hadoop.hbase.TableName) RegionInfo(org.apache.hadoop.hbase.client.RegionInfo) GCRegionProcedure(org.apache.hadoop.hbase.master.assignment.GCRegionProcedure) MasterServices(org.apache.hadoop.hbase.master.MasterServices) IOException(java.io.IOException) Test(org.junit.Test)

Aggregations

RegionInfo (org.apache.hadoop.hbase.client.RegionInfo)2 GCRegionProcedure (org.apache.hadoop.hbase.master.assignment.GCRegionProcedure)2 IOException (java.io.IOException)1 AtomicBoolean (java.util.concurrent.atomic.AtomicBoolean)1 TableName (org.apache.hadoop.hbase.TableName)1 MasterServices (org.apache.hadoop.hbase.master.MasterServices)1 MasterProcedureEnv (org.apache.hadoop.hbase.master.procedure.MasterProcedureEnv)1 Test (org.junit.Test)1