Search in sources :

Example 1 with MergeTableRegionsProcedure

use of org.apache.hadoop.hbase.master.procedure.MergeTableRegionsProcedure in project hbase by apache.

the class HMaster method mergeRegions.

@Override
public long mergeRegions(final HRegionInfo[] regionsToMerge, final boolean forcible, final long nonceGroup, final long nonce) throws IOException {
    checkInitialized();
    assert (regionsToMerge.length == 2);
    TableName tableName = regionsToMerge[0].getTable();
    if (tableName == null || regionsToMerge[1].getTable() == null) {
        throw new UnknownRegionException("Can't merge regions without table associated");
    }
    if (!tableName.equals(regionsToMerge[1].getTable())) {
        throw new IOException("Cannot merge regions from two different tables " + regionsToMerge[0].getTable() + " and " + regionsToMerge[1].getTable());
    }
    if (regionsToMerge[0].compareTo(regionsToMerge[1]) == 0) {
        throw new MergeRegionException("Cannot merge a region to itself " + regionsToMerge[0] + ", " + regionsToMerge[1]);
    }
    return MasterProcedureUtil.submitProcedure(new MasterProcedureUtil.NonceProcedureRunnable(this, nonceGroup, nonce) {

        @Override
        protected void run() throws IOException {
            getMaster().getMasterCoprocessorHost().preMergeRegions(regionsToMerge);
            LOG.info(getClientIdAuditPrefix() + " Merge regions " + regionsToMerge[0].getEncodedName() + " and " + regionsToMerge[1].getEncodedName());
            submitProcedure(new MergeTableRegionsProcedure(procedureExecutor.getEnvironment(), regionsToMerge, forcible));
            getMaster().getMasterCoprocessorHost().postMergeRegions(regionsToMerge);
        }

        @Override
        protected String getDescription() {
            return "DisableTableProcedure";
        }
    });
}
Also used : TableName(org.apache.hadoop.hbase.TableName) MergeTableRegionsProcedure(org.apache.hadoop.hbase.master.procedure.MergeTableRegionsProcedure) UnknownRegionException(org.apache.hadoop.hbase.UnknownRegionException) InterruptedIOException(java.io.InterruptedIOException) IOException(java.io.IOException) DoNotRetryIOException(org.apache.hadoop.hbase.DoNotRetryIOException) HBaseIOException(org.apache.hadoop.hbase.HBaseIOException) MergeRegionException(org.apache.hadoop.hbase.exceptions.MergeRegionException) MasterProcedureUtil(org.apache.hadoop.hbase.master.procedure.MasterProcedureUtil)

Aggregations

IOException (java.io.IOException)1 InterruptedIOException (java.io.InterruptedIOException)1 DoNotRetryIOException (org.apache.hadoop.hbase.DoNotRetryIOException)1 HBaseIOException (org.apache.hadoop.hbase.HBaseIOException)1 TableName (org.apache.hadoop.hbase.TableName)1 UnknownRegionException (org.apache.hadoop.hbase.UnknownRegionException)1 MergeRegionException (org.apache.hadoop.hbase.exceptions.MergeRegionException)1 MasterProcedureUtil (org.apache.hadoop.hbase.master.procedure.MasterProcedureUtil)1 MergeTableRegionsProcedure (org.apache.hadoop.hbase.master.procedure.MergeTableRegionsProcedure)1