Search in sources :

Example 1 with CatalogJanitor

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

the class MergeTableRegionsProcedure method prepareMergeRegion.

/**
   * Prepare merge and do some check
   * @param env MasterProcedureEnv
   * @throws IOException
   */
private void prepareMergeRegion(final MasterProcedureEnv env) throws IOException {
    // Note: the following logic assumes that we only have 2 regions to merge.  In the future,
    // if we want to extend to more than 2 regions, the code needs to modify a little bit.
    //
    CatalogJanitor catalogJanitor = env.getMasterServices().getCatalogJanitor();
    boolean regionAHasMergeQualifier = !catalogJanitor.cleanMergeQualifier(regionsToMerge[0]);
    if (regionAHasMergeQualifier || !catalogJanitor.cleanMergeQualifier(regionsToMerge[1])) {
        String msg = "Skip merging regions " + getRegionsToMergeListFullNameString() + ", because region " + (regionAHasMergeQualifier ? regionsToMerge[0].getEncodedName() : regionsToMerge[1].getEncodedName()) + " has merge qualifier";
        LOG.warn(msg);
        throw new MergeRegionException(msg);
    }
    RegionStates regionStates = getAssignmentManager(env).getRegionStates();
    RegionState regionStateA = regionStates.getRegionState(regionsToMerge[0].getEncodedName());
    RegionState regionStateB = regionStates.getRegionState(regionsToMerge[1].getEncodedName());
    if (regionStateA == null || regionStateB == null) {
        throw new UnknownRegionException(regionStateA == null ? regionsToMerge[0].getEncodedName() : regionsToMerge[1].getEncodedName());
    }
    if (!regionStateA.isOpened() || !regionStateB.isOpened()) {
        throw new MergeRegionException("Unable to merge regions not online " + regionStateA + ", " + regionStateB);
    }
}
Also used : RegionState(org.apache.hadoop.hbase.master.RegionState) RegionStates(org.apache.hadoop.hbase.master.RegionStates) CatalogJanitor(org.apache.hadoop.hbase.master.CatalogJanitor) UnknownRegionException(org.apache.hadoop.hbase.UnknownRegionException) MergeRegionException(org.apache.hadoop.hbase.exceptions.MergeRegionException)

Aggregations

UnknownRegionException (org.apache.hadoop.hbase.UnknownRegionException)1 MergeRegionException (org.apache.hadoop.hbase.exceptions.MergeRegionException)1 CatalogJanitor (org.apache.hadoop.hbase.master.CatalogJanitor)1 RegionState (org.apache.hadoop.hbase.master.RegionState)1 RegionStates (org.apache.hadoop.hbase.master.RegionStates)1