Search in sources :

Example 1 with CloseRegionResponse

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);
    }
}
Also used : ServiceException(org.apache.hadoop.hbase.shaded.com.google.protobuf.ServiceException) DoNotRetryIOException(org.apache.hadoop.hbase.DoNotRetryIOException) ServerName(org.apache.hadoop.hbase.ServerName) ByteString(org.apache.hadoop.hbase.shaded.com.google.protobuf.ByteString) CloseRegionResponse(org.apache.hadoop.hbase.shaded.protobuf.generated.AdminProtos.CloseRegionResponse) InterruptedIOException(java.io.InterruptedIOException) IOException(java.io.IOException) DoNotRetryIOException(org.apache.hadoop.hbase.DoNotRetryIOException) HBaseIOException(org.apache.hadoop.hbase.HBaseIOException) QosPriority(org.apache.hadoop.hbase.ipc.QosPriority)

Example 2 with CloseRegionResponse

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);
    }
}
Also used : HBaseRpcController(org.apache.hadoop.hbase.ipc.HBaseRpcController) AdminService(org.apache.hadoop.hbase.shaded.protobuf.generated.AdminProtos.AdminService) ServerName(org.apache.hadoop.hbase.ServerName) CloseRegionResponse(org.apache.hadoop.hbase.shaded.protobuf.generated.AdminProtos.CloseRegionResponse) CloseRegionRequest(org.apache.hadoop.hbase.shaded.protobuf.generated.AdminProtos.CloseRegionRequest) 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)

Aggregations

IOException (java.io.IOException)2 InterruptedIOException (java.io.InterruptedIOException)2 DoNotRetryIOException (org.apache.hadoop.hbase.DoNotRetryIOException)2 ServerName (org.apache.hadoop.hbase.ServerName)2 ServiceException (org.apache.hadoop.hbase.shaded.com.google.protobuf.ServiceException)2 CloseRegionResponse (org.apache.hadoop.hbase.shaded.protobuf.generated.AdminProtos.CloseRegionResponse)2 ExecutionException (java.util.concurrent.ExecutionException)1 TimeoutException (java.util.concurrent.TimeoutException)1 HBaseIOException (org.apache.hadoop.hbase.HBaseIOException)1 MasterNotRunningException (org.apache.hadoop.hbase.MasterNotRunningException)1 NamespaceNotFoundException (org.apache.hadoop.hbase.NamespaceNotFoundException)1 NotServingRegionException (org.apache.hadoop.hbase.NotServingRegionException)1 TableExistsException (org.apache.hadoop.hbase.TableExistsException)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 HBaseRpcController (org.apache.hadoop.hbase.ipc.HBaseRpcController)1 QosPriority (org.apache.hadoop.hbase.ipc.QosPriority)1