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();
}
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();
}
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);
}
}
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);
}
}
Aggregations