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";
}
});
}
Aggregations