Search in sources :

Example 1 with UnassignRegionResponse

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

the class MasterRpcServices method unassignRegion.

@Override
public UnassignRegionResponse unassignRegion(RpcController controller, UnassignRegionRequest req) throws ServiceException {
    try {
        final byte[] regionName = req.getRegion().getValue().toByteArray();
        RegionSpecifierType type = req.getRegion().getType();
        UnassignRegionResponse urr = UnassignRegionResponse.newBuilder().build();
        server.checkInitialized();
        if (type != RegionSpecifierType.REGION_NAME) {
            LOG.warn("unassignRegion specifier type: expected: " + RegionSpecifierType.REGION_NAME + " actual: " + type);
        }
        RegionStateNode rsn = server.getAssignmentManager().getRegionStates().getRegionStateNodeFromName(regionName);
        if (rsn == null) {
            throw new UnknownRegionException(Bytes.toString(regionName));
        }
        RegionInfo hri = rsn.getRegionInfo();
        if (server.cpHost != null) {
            server.cpHost.preUnassign(hri);
        }
        LOG.debug(server.getClientIdAuditPrefix() + " unassign " + hri.getRegionNameAsString() + " in current location if it is online");
        server.getAssignmentManager().unassign(hri);
        if (server.cpHost != null) {
            server.cpHost.postUnassign(hri);
        }
        return urr;
    } catch (IOException ioe) {
        throw new ServiceException(ioe);
    }
}
Also used : UnassignRegionResponse(org.apache.hadoop.hbase.shaded.protobuf.generated.MasterProtos.UnassignRegionResponse) ServiceException(org.apache.hbase.thirdparty.com.google.protobuf.ServiceException) RegionSpecifierType(org.apache.hadoop.hbase.shaded.protobuf.generated.HBaseProtos.RegionSpecifier.RegionSpecifierType) UnknownRegionException(org.apache.hadoop.hbase.UnknownRegionException) RegionInfo(org.apache.hadoop.hbase.client.RegionInfo) IOException(java.io.IOException) DoNotRetryIOException(org.apache.hadoop.hbase.DoNotRetryIOException) RegionStateNode(org.apache.hadoop.hbase.master.assignment.RegionStateNode)

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 RegionStateNode (org.apache.hadoop.hbase.master.assignment.RegionStateNode)1 RegionSpecifierType (org.apache.hadoop.hbase.shaded.protobuf.generated.HBaseProtos.RegionSpecifier.RegionSpecifierType)1 UnassignRegionResponse (org.apache.hadoop.hbase.shaded.protobuf.generated.MasterProtos.UnassignRegionResponse)1 ServiceException (org.apache.hbase.thirdparty.com.google.protobuf.ServiceException)1