use of org.apache.hadoop.hbase.shaded.protobuf.generated.MasterProtos.MergeTableRegionsResponse in project hbase by apache.
the class HBaseAdmin method mergeRegionsAsync.
/**
* Merge two regions. Asynchronous operation.
* @param nameofRegionsToMerge encoded or full name of daughter regions
* @param forcible true if do a compulsory merge, otherwise we will only merge
* adjacent regions
* @throws IOException
*/
@Override
public Future<Void> mergeRegionsAsync(final byte[][] nameofRegionsToMerge, final boolean forcible) throws IOException {
assert (nameofRegionsToMerge.length >= 2);
byte[][] encodedNameofRegionsToMerge = new byte[nameofRegionsToMerge.length][];
for (int i = 0; i < nameofRegionsToMerge.length; i++) {
encodedNameofRegionsToMerge[i] = isEncodedRegionName(nameofRegionsToMerge[i]) ? nameofRegionsToMerge[i] : HRegionInfo.encodeRegionName(nameofRegionsToMerge[i]).getBytes();
}
TableName tableName = null;
Pair<HRegionInfo, ServerName> pair;
for (int i = 0; i < nameofRegionsToMerge.length; i++) {
pair = getRegion(nameofRegionsToMerge[i]);
if (pair != null) {
if (pair.getFirst().getReplicaId() != HRegionInfo.DEFAULT_REPLICA_ID) {
throw new IllegalArgumentException("Can't invoke merge on non-default regions directly");
}
if (tableName == null) {
tableName = pair.getFirst().getTable();
} else if (!tableName.equals(pair.getFirst().getTable())) {
throw new IllegalArgumentException("Cannot merge regions from two different tables " + tableName + " and " + pair.getFirst().getTable());
}
} else {
throw new UnknownRegionException("Can't invoke merge on unknown region " + Bytes.toStringBinary(encodedNameofRegionsToMerge[i]));
}
}
MergeTableRegionsResponse response = executeCallable(new MasterCallable<MergeTableRegionsResponse>(getConnection(), getRpcControllerFactory()) {
@Override
protected MergeTableRegionsResponse rpcCall() throws Exception {
MergeTableRegionsRequest request = RequestConverter.buildMergeTableRegionsRequest(encodedNameofRegionsToMerge, forcible, ng.getNonceGroup(), ng.newNonce());
return master.mergeTableRegions(getRpcController(), request);
}
});
return new MergeTableRegionsFuture(this, tableName, response);
}
Aggregations