Search in sources :

Example 1 with CloseRegionRequest

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

the class ProtobufUtil method buildCloseRegionRequest.

/**
    * Create a CloseRegionRequest for a given encoded region name
    *
    * @param encodedRegionName the name of the region to close
    * @return a CloseRegionRequest
    */
public static CloseRegionRequest buildCloseRegionRequest(ServerName server, final String encodedRegionName) {
    CloseRegionRequest.Builder builder = CloseRegionRequest.newBuilder();
    RegionSpecifier region = RequestConverter.buildRegionSpecifier(RegionSpecifierType.ENCODED_REGION_NAME, Bytes.toBytes(encodedRegionName));
    builder.setRegion(region);
    if (server != null) {
        builder.setServerStartCode(server.getStartcode());
    }
    return builder.build();
}
Also used : CloseRegionRequest(org.apache.hadoop.hbase.shaded.protobuf.generated.AdminProtos.CloseRegionRequest) RegionSpecifier(org.apache.hadoop.hbase.shaded.protobuf.generated.HBaseProtos.RegionSpecifier)

Example 2 with CloseRegionRequest

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

the class ProtobufUtil method buildCloseRegionRequest.

public static CloseRegionRequest buildCloseRegionRequest(ServerName server, final byte[] regionName, ServerName destinationServer) {
    CloseRegionRequest.Builder builder = CloseRegionRequest.newBuilder();
    RegionSpecifier region = RequestConverter.buildRegionSpecifier(RegionSpecifierType.REGION_NAME, regionName);
    builder.setRegion(region);
    if (destinationServer != null) {
        builder.setDestinationServer(toServerName(destinationServer));
    }
    if (server != null) {
        builder.setServerStartCode(server.getStartcode());
    }
    return builder.build();
}
Also used : CloseRegionRequest(org.apache.hadoop.hbase.shaded.protobuf.generated.AdminProtos.CloseRegionRequest) RegionSpecifier(org.apache.hadoop.hbase.shaded.protobuf.generated.HBaseProtos.RegionSpecifier)

Example 3 with CloseRegionRequest

use of org.apache.hadoop.hbase.shaded.protobuf.generated.AdminProtos.CloseRegionRequest 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)

Example 4 with CloseRegionRequest

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

the class TestRegionServerNoMaster method testOpenCloseRegionRPCIntendedForPreviousServer.

/**
   * Tests an on-the-fly RPC that was scheduled for the earlier RS on the same port
   * for openRegion. The region server should reject this RPC. (HBASE-9721)
   */
@Test
public void testOpenCloseRegionRPCIntendedForPreviousServer() throws Exception {
    Assert.assertTrue(getRS().getRegion(regionName).isAvailable());
    ServerName sn = getRS().getServerName();
    ServerName earlierServerName = ServerName.valueOf(sn.getHostname(), sn.getPort(), 1);
    try {
        CloseRegionRequest request = ProtobufUtil.buildCloseRegionRequest(earlierServerName, regionName);
        getRS().getRSRpcServices().closeRegion(null, request);
        Assert.fail("The closeRegion should have been rejected");
    } catch (org.apache.hadoop.hbase.shaded.com.google.protobuf.ServiceException se) {
        Assert.assertTrue(se.getCause() instanceof IOException);
        Assert.assertTrue(se.getCause().getMessage().contains("This RPC was intended for a different server"));
    }
    //actual close
    closeRegionNoZK();
    try {
        AdminProtos.OpenRegionRequest orr = RequestConverter.buildOpenRegionRequest(earlierServerName, hri, null, null);
        getRS().getRSRpcServices().openRegion(null, orr);
        Assert.fail("The openRegion should have been rejected");
    } catch (org.apache.hadoop.hbase.shaded.com.google.protobuf.ServiceException se) {
        Assert.assertTrue(se.getCause() instanceof IOException);
        Assert.assertTrue(se.getCause().getMessage().contains("This RPC was intended for a different server"));
    } finally {
        openRegion(HTU, getRS(), hri);
    }
}
Also used : AdminProtos(org.apache.hadoop.hbase.shaded.protobuf.generated.AdminProtos) ServerName(org.apache.hadoop.hbase.ServerName) IOException(java.io.IOException) CloseRegionRequest(org.apache.hadoop.hbase.shaded.protobuf.generated.AdminProtos.CloseRegionRequest) Test(org.junit.Test)

Aggregations

CloseRegionRequest (org.apache.hadoop.hbase.shaded.protobuf.generated.AdminProtos.CloseRegionRequest)4 IOException (java.io.IOException)2 ServerName (org.apache.hadoop.hbase.ServerName)2 RegionSpecifier (org.apache.hadoop.hbase.shaded.protobuf.generated.HBaseProtos.RegionSpecifier)2 InterruptedIOException (java.io.InterruptedIOException)1 ExecutionException (java.util.concurrent.ExecutionException)1 TimeoutException (java.util.concurrent.TimeoutException)1 DoNotRetryIOException (org.apache.hadoop.hbase.DoNotRetryIOException)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 FailedLogCloseException (org.apache.hadoop.hbase.regionserver.wal.FailedLogCloseException)1 ReplicationException (org.apache.hadoop.hbase.replication.ReplicationException)1