use of org.apache.hadoop.hbase.master.assignment.MergeTableRegionsProcedure in project hbase by apache.
the class TestMergeTableRegionsWhileRSCrash method test.
@Test
public void test() throws Exception {
// write some rows to the table
for (int i = 0; i < 10; i++) {
byte[] row = Bytes.toBytes("row" + i);
Put put = new Put(row);
put.addColumn(CF, CF, CF);
TABLE.put(put);
}
MasterProcedureEnv env = UTIL.getMiniHBaseCluster().getMaster().getMasterProcedureExecutor().getEnvironment();
final ProcedureExecutor<MasterProcedureEnv> executor = UTIL.getMiniHBaseCluster().getMaster().getMasterProcedureExecutor();
List<RegionInfo> regionInfos = admin.getRegions(TABLE_NAME);
MergeTableRegionsProcedure mergeTableRegionsProcedure = new MergeTableRegionsProcedure(env, new RegionInfo[] { regionInfos.get(0), regionInfos.get(1) }, false);
executor.submitProcedure(mergeTableRegionsProcedure);
UTIL.waitFor(30000, () -> executor.getProcedures().stream().filter(p -> p instanceof TransitRegionStateProcedure).map(p -> (TransitRegionStateProcedure) p).anyMatch(p -> TABLE_NAME.equals(p.getTableName())));
UTIL.getMiniHBaseCluster().killRegionServer(UTIL.getMiniHBaseCluster().getRegionServer(0).getServerName());
UTIL.getMiniHBaseCluster().startRegionServer();
UTIL.waitUntilNoRegionsInTransition();
Scan scan = new Scan();
ResultScanner results = TABLE.getScanner(scan);
int count = 0;
Result result = null;
while ((result = results.next()) != null) {
count++;
}
Assert.assertEquals("There should be 10 rows!", 10, count);
}
use of org.apache.hadoop.hbase.master.assignment.MergeTableRegionsProcedure in project hbase by apache.
the class HMaster method mergeRegions.
@Override
public long mergeRegions(final RegionInfo[] regionsToMerge, final boolean forcible, final long ng, final long nonce) throws IOException {
checkInitialized();
if (!isSplitOrMergeEnabled(MasterSwitchType.MERGE)) {
String regionsStr = Arrays.deepToString(regionsToMerge);
LOG.warn("Merge switch is off! skip merge of " + regionsStr);
throw new DoNotRetryIOException("Merge of " + regionsStr + " failed because merge switch is off");
}
final String mergeRegionsStr = Arrays.stream(regionsToMerge).map(RegionInfo::getEncodedName).collect(Collectors.joining(", "));
return MasterProcedureUtil.submitProcedure(new NonceProcedureRunnable(this, ng, nonce) {
@Override
protected void run() throws IOException {
getMaster().getMasterCoprocessorHost().preMergeRegions(regionsToMerge);
String aid = getClientIdAuditPrefix();
LOG.info("{} merge regions {}", aid, mergeRegionsStr);
submitProcedure(new MergeTableRegionsProcedure(procedureExecutor.getEnvironment(), regionsToMerge, forcible));
getMaster().getMasterCoprocessorHost().postMergeRegions(regionsToMerge);
}
@Override
protected String getDescription() {
return "MergeTableProcedure";
}
});
}
Aggregations