Search in sources :

Example 6 with GetRegionInfoResponse

use of org.apache.hadoop.hbase.shaded.protobuf.generated.AdminProtos.GetRegionInfoResponse in project hbase by apache.

the class RSRpcServices method getRegionInfo.

// Master implementation of this Admin Service differs given it is not
// able to supply detail only known to RegionServer. See note on
// MasterRpcServers#getRegionInfo.
@Override
@QosPriority(priority = HConstants.ADMIN_QOS)
public GetRegionInfoResponse getRegionInfo(final RpcController controller, final GetRegionInfoRequest request) throws ServiceException {
    try {
        checkOpen();
        requestCount.increment();
        HRegion region = getRegion(request.getRegion());
        RegionInfo info = region.getRegionInfo();
        byte[] bestSplitRow;
        if (request.hasBestSplitRow() && request.getBestSplitRow()) {
            bestSplitRow = region.checkSplit(true).orElse(null);
            // try to flush region first
            if (bestSplitRow == null) {
                region.flush(true);
                bestSplitRow = region.checkSplit(true).orElse(null);
            }
        } else {
            bestSplitRow = null;
        }
        GetRegionInfoResponse.Builder builder = GetRegionInfoResponse.newBuilder();
        builder.setRegionInfo(ProtobufUtil.toRegionInfo(info));
        if (request.hasCompactionState() && request.getCompactionState()) {
            builder.setCompactionState(ProtobufUtil.createCompactionState(region.getCompactionState()));
        }
        builder.setSplittable(region.isSplittable());
        builder.setMergeable(region.isMergeable());
        if (request.hasBestSplitRow() && request.getBestSplitRow() && bestSplitRow != null) {
            builder.setBestSplitRow(UnsafeByteOperations.unsafeWrap(bestSplitRow));
        }
        return builder.build();
    } catch (IOException ie) {
        throw new ServiceException(ie);
    }
}
Also used : ServiceException(org.apache.hbase.thirdparty.com.google.protobuf.ServiceException) GetRegionInfoResponse(org.apache.hadoop.hbase.shaded.protobuf.generated.AdminProtos.GetRegionInfoResponse) RegionInfo(org.apache.hadoop.hbase.client.RegionInfo) IOException(java.io.IOException) DoNotRetryIOException(org.apache.hadoop.hbase.DoNotRetryIOException) HBaseIOException(org.apache.hadoop.hbase.HBaseIOException) UncheckedIOException(java.io.UncheckedIOException) QosPriority(org.apache.hadoop.hbase.ipc.QosPriority)

Example 7 with GetRegionInfoResponse

use of org.apache.hadoop.hbase.shaded.protobuf.generated.AdminProtos.GetRegionInfoResponse in project hbase by apache.

the class ProtobufUtil method getRegionInfo.

// End helpers for Client
// Start helpers for Admin
/**
 * A helper to retrieve region info given a region name or an
 * encoded region name using admin protocol.
 *
 * @return the retrieved region info
 */
public static org.apache.hadoop.hbase.client.RegionInfo getRegionInfo(final RpcController controller, final AdminService.BlockingInterface admin, final byte[] regionName) throws IOException {
    try {
        GetRegionInfoRequest request = getGetRegionInfoRequest(regionName);
        GetRegionInfoResponse response = admin.getRegionInfo(controller, getGetRegionInfoRequest(regionName));
        return toRegionInfo(response.getRegionInfo());
    } catch (ServiceException se) {
        throw getRemoteException(se);
    }
}
Also used : GetRegionInfoRequest(org.apache.hadoop.hbase.shaded.protobuf.generated.AdminProtos.GetRegionInfoRequest) ServiceException(org.apache.hbase.thirdparty.com.google.protobuf.ServiceException) GetRegionInfoResponse(org.apache.hadoop.hbase.shaded.protobuf.generated.AdminProtos.GetRegionInfoResponse)

Aggregations

GetRegionInfoResponse (org.apache.hadoop.hbase.shaded.protobuf.generated.AdminProtos.GetRegionInfoResponse)6 IOException (java.io.IOException)3 ServerName (org.apache.hadoop.hbase.ServerName)3 GetRegionInfoRequest (org.apache.hadoop.hbase.shaded.protobuf.generated.AdminProtos.GetRegionInfoRequest)3 ServiceException (org.apache.hbase.thirdparty.com.google.protobuf.ServiceException)3 DoNotRetryIOException (org.apache.hadoop.hbase.DoNotRetryIOException)2 HRegionInfo (org.apache.hadoop.hbase.HRegionInfo)2 RegionInfo (org.apache.hadoop.hbase.client.RegionInfo)2 HBaseRpcController (org.apache.hadoop.hbase.ipc.HBaseRpcController)2 QosPriority (org.apache.hadoop.hbase.ipc.QosPriority)2 AdminService (org.apache.hadoop.hbase.shaded.protobuf.generated.AdminProtos.AdminService)2 Nullable (edu.umd.cs.findbugs.annotations.Nullable)1 InterruptedIOException (java.io.InterruptedIOException)1 UncheckedIOException (java.io.UncheckedIOException)1 ArrayList (java.util.ArrayList)1 Arrays (java.util.Arrays)1 Collections (java.util.Collections)1 EnumSet (java.util.EnumSet)1 HashMap (java.util.HashMap)1 List (java.util.List)1