Search in sources :

Example 1 with MergeTableRegionsResponse

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);
}
Also used : UnknownRegionException(org.apache.hadoop.hbase.UnknownRegionException) RestoreSnapshotException(org.apache.hadoop.hbase.snapshot.RestoreSnapshotException) SnapshotCreationException(org.apache.hadoop.hbase.snapshot.SnapshotCreationException) InterruptedIOException(java.io.InterruptedIOException) ZooKeeperConnectionException(org.apache.hadoop.hbase.ZooKeeperConnectionException) IOException(java.io.IOException) ExecutionException(java.util.concurrent.ExecutionException) TableNotDisabledException(org.apache.hadoop.hbase.TableNotDisabledException) TableNotFoundException(org.apache.hadoop.hbase.TableNotFoundException) HBaseSnapshotException(org.apache.hadoop.hbase.snapshot.HBaseSnapshotException) TimeoutException(java.util.concurrent.TimeoutException) NotServingRegionException(org.apache.hadoop.hbase.NotServingRegionException) ReplicationException(org.apache.hadoop.hbase.replication.ReplicationException) DoNotRetryIOException(org.apache.hadoop.hbase.DoNotRetryIOException) UnknownRegionException(org.apache.hadoop.hbase.UnknownRegionException) FailedLogCloseException(org.apache.hadoop.hbase.regionserver.wal.FailedLogCloseException) MasterNotRunningException(org.apache.hadoop.hbase.MasterNotRunningException) TimeoutIOException(org.apache.hadoop.hbase.exceptions.TimeoutIOException) NamespaceNotFoundException(org.apache.hadoop.hbase.NamespaceNotFoundException) TableExistsException(org.apache.hadoop.hbase.TableExistsException) KeeperException(org.apache.zookeeper.KeeperException) UnknownSnapshotException(org.apache.hadoop.hbase.snapshot.UnknownSnapshotException) RemoteException(org.apache.hadoop.ipc.RemoteException) ServiceException(org.apache.hadoop.hbase.shaded.com.google.protobuf.ServiceException) HRegionInfo(org.apache.hadoop.hbase.HRegionInfo) TableName(org.apache.hadoop.hbase.TableName) MergeTableRegionsResponse(org.apache.hadoop.hbase.shaded.protobuf.generated.MasterProtos.MergeTableRegionsResponse) ServerName(org.apache.hadoop.hbase.ServerName) MergeTableRegionsRequest(org.apache.hadoop.hbase.shaded.protobuf.generated.MasterProtos.MergeTableRegionsRequest)

Aggregations

IOException (java.io.IOException)1 InterruptedIOException (java.io.InterruptedIOException)1 ExecutionException (java.util.concurrent.ExecutionException)1 TimeoutException (java.util.concurrent.TimeoutException)1 DoNotRetryIOException (org.apache.hadoop.hbase.DoNotRetryIOException)1 HRegionInfo (org.apache.hadoop.hbase.HRegionInfo)1 MasterNotRunningException (org.apache.hadoop.hbase.MasterNotRunningException)1 NamespaceNotFoundException (org.apache.hadoop.hbase.NamespaceNotFoundException)1 NotServingRegionException (org.apache.hadoop.hbase.NotServingRegionException)1 ServerName (org.apache.hadoop.hbase.ServerName)1 TableExistsException (org.apache.hadoop.hbase.TableExistsException)1 TableName (org.apache.hadoop.hbase.TableName)1 TableNotDisabledException (org.apache.hadoop.hbase.TableNotDisabledException)1 TableNotFoundException (org.apache.hadoop.hbase.TableNotFoundException)1 UnknownRegionException (org.apache.hadoop.hbase.UnknownRegionException)1 ZooKeeperConnectionException (org.apache.hadoop.hbase.ZooKeeperConnectionException)1 TimeoutIOException (org.apache.hadoop.hbase.exceptions.TimeoutIOException)1 FailedLogCloseException (org.apache.hadoop.hbase.regionserver.wal.FailedLogCloseException)1 ReplicationException (org.apache.hadoop.hbase.replication.ReplicationException)1 ServiceException (org.apache.hadoop.hbase.shaded.com.google.protobuf.ServiceException)1