Search in sources :

Example 1 with AssignRegionResponse

use of org.apache.hadoop.hbase.shaded.protobuf.generated.MasterProtos.AssignRegionResponse in project hbase by apache.

the class MasterRpcServices method assignRegion.

@Override
public AssignRegionResponse assignRegion(RpcController controller, AssignRegionRequest req) throws ServiceException {
    try {
        server.checkInitialized();
        final RegionSpecifierType type = req.getRegion().getType();
        if (type != RegionSpecifierType.REGION_NAME) {
            LOG.warn("assignRegion specifier type: expected: " + RegionSpecifierType.REGION_NAME + " actual: " + type);
        }
        final byte[] regionName = req.getRegion().getValue().toByteArray();
        final RegionInfo regionInfo = server.getAssignmentManager().getRegionInfo(regionName);
        if (regionInfo == null) {
            throw new UnknownRegionException(Bytes.toStringBinary(regionName));
        }
        final AssignRegionResponse arr = AssignRegionResponse.newBuilder().build();
        if (server.cpHost != null) {
            server.cpHost.preAssign(regionInfo);
        }
        LOG.info(server.getClientIdAuditPrefix() + " assign " + regionInfo.getRegionNameAsString());
        server.getAssignmentManager().assign(regionInfo);
        if (server.cpHost != null) {
            server.cpHost.postAssign(regionInfo);
        }
        return arr;
    } catch (IOException ioe) {
        throw new ServiceException(ioe);
    }
}
Also used : ServiceException(org.apache.hbase.thirdparty.com.google.protobuf.ServiceException) RegionSpecifierType(org.apache.hadoop.hbase.shaded.protobuf.generated.HBaseProtos.RegionSpecifier.RegionSpecifierType) AssignRegionResponse(org.apache.hadoop.hbase.shaded.protobuf.generated.MasterProtos.AssignRegionResponse) UnknownRegionException(org.apache.hadoop.hbase.UnknownRegionException) RegionInfo(org.apache.hadoop.hbase.client.RegionInfo) IOException(java.io.IOException) DoNotRetryIOException(org.apache.hadoop.hbase.DoNotRetryIOException)

Aggregations

IOException (java.io.IOException)1 DoNotRetryIOException (org.apache.hadoop.hbase.DoNotRetryIOException)1 UnknownRegionException (org.apache.hadoop.hbase.UnknownRegionException)1 RegionInfo (org.apache.hadoop.hbase.client.RegionInfo)1 RegionSpecifierType (org.apache.hadoop.hbase.shaded.protobuf.generated.HBaseProtos.RegionSpecifier.RegionSpecifierType)1 AssignRegionResponse (org.apache.hadoop.hbase.shaded.protobuf.generated.MasterProtos.AssignRegionResponse)1 ServiceException (org.apache.hbase.thirdparty.com.google.protobuf.ServiceException)1