use of org.apache.hadoop.hbase.shaded.protobuf.generated.AdminProtos.CloseRegionResponse in project hbase by apache.
the class RSRpcServices method closeRegion.
/**
* Close a region on the region server.
*
* @param controller the RPC controller
* @param request the request
* @throws ServiceException
*/
@Override
@QosPriority(priority = HConstants.ADMIN_QOS)
public CloseRegionResponse closeRegion(final RpcController controller, final CloseRegionRequest request) throws ServiceException {
final ServerName sn = (request.hasDestinationServer() ? ProtobufUtil.toServerName(request.getDestinationServer()) : null);
try {
checkOpen();
if (request.hasServerStartCode()) {
// check that we are the same server that this RPC is intended for.
long serverStartCode = request.getServerStartCode();
if (regionServer.serverName.getStartcode() != serverStartCode) {
throw new ServiceException(new DoNotRetryIOException("This RPC was intended for a " + "different server with startCode: " + serverStartCode + ", this server is: " + regionServer.serverName));
}
}
final String encodedRegionName = ProtobufUtil.getRegionEncodedName(request.getRegion());
requestCount.increment();
if (sn == null) {
LOG.info("Close " + encodedRegionName + " without moving");
} else {
LOG.info("Close " + encodedRegionName + ", moving to " + sn);
}
boolean closed = regionServer.closeRegion(encodedRegionName, false, sn);
CloseRegionResponse.Builder builder = CloseRegionResponse.newBuilder().setClosed(closed);
return builder.build();
} catch (IOException ie) {
throw new ServiceException(ie);
}
}
use of org.apache.hadoop.hbase.shaded.protobuf.generated.AdminProtos.CloseRegionResponse in project hbase by apache.
the class HBaseAdmin method closeRegionWithEncodedRegionName.
@Override
public boolean closeRegionWithEncodedRegionName(final String encodedRegionName, final String serverName) throws IOException {
if (null == serverName || ("").equals(serverName.trim())) {
throw new IllegalArgumentException("The servername cannot be null or empty.");
}
ServerName sn = ServerName.valueOf(serverName);
AdminService.BlockingInterface admin = this.connection.getAdmin(sn);
// Close the region without updating zk state.
CloseRegionRequest request = ProtobufUtil.buildCloseRegionRequest(sn, encodedRegionName);
// TODO: There is no timeout on this controller. Set one!
HBaseRpcController controller = this.rpcControllerFactory.newController();
try {
CloseRegionResponse response = admin.closeRegion(controller, request);
boolean closed = response.getClosed();
if (false == closed) {
LOG.error("Not able to close the region " + encodedRegionName + ".");
}
return closed;
} catch (Exception e) {
throw ProtobufUtil.handleRemoteException(e);
}
}
Aggregations