Search in sources :

Example 11 with HBaseRpcController

use of org.apache.hadoop.hbase.ipc.HBaseRpcController in project hbase by apache.

the class HBaseAdmin method split.

@VisibleForTesting
public void split(final ServerName sn, final HRegionInfo hri, byte[] splitPoint) throws IOException {
    if (hri.getStartKey() != null && splitPoint != null && Bytes.compareTo(hri.getStartKey(), splitPoint) == 0) {
        throw new IOException("should not give a splitkey which equals to startkey!");
    }
    // TODO: There is no timeout on this controller. Set one!
    HBaseRpcController controller = rpcControllerFactory.newController();
    controller.setPriority(hri.getTable());
    // TODO: this does not do retries, it should. Set priority and timeout in controller
    AdminService.BlockingInterface admin = this.connection.getAdmin(sn);
    ProtobufUtil.split(controller, admin, hri, splitPoint);
}
Also used : HBaseRpcController(org.apache.hadoop.hbase.ipc.HBaseRpcController) AdminService(org.apache.hadoop.hbase.shaded.protobuf.generated.AdminProtos.AdminService) InterruptedIOException(java.io.InterruptedIOException) IOException(java.io.IOException) DoNotRetryIOException(org.apache.hadoop.hbase.DoNotRetryIOException) TimeoutIOException(org.apache.hadoop.hbase.exceptions.TimeoutIOException) VisibleForTesting(com.google.common.annotations.VisibleForTesting)

Example 12 with HBaseRpcController

use of org.apache.hadoop.hbase.ipc.HBaseRpcController 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 13 with HBaseRpcController

use of org.apache.hadoop.hbase.ipc.HBaseRpcController in project hbase by apache.

the class HBaseAdmin method flushRegion.

@Override
public void flushRegion(final byte[] regionName) throws IOException {
    Pair<HRegionInfo, ServerName> regionServerPair = getRegion(regionName);
    if (regionServerPair == null) {
        throw new IllegalArgumentException("Unknown regionname: " + Bytes.toStringBinary(regionName));
    }
    if (regionServerPair.getSecond() == null) {
        throw new NoServerForRegionException(Bytes.toStringBinary(regionName));
    }
    final HRegionInfo hRegionInfo = regionServerPair.getFirst();
    ServerName serverName = regionServerPair.getSecond();
    final AdminService.BlockingInterface admin = this.connection.getAdmin(serverName);
    Callable<Void> callable = new Callable<Void>() {

        @Override
        public Void call() throws Exception {
            // TODO: There is no timeout on this controller. Set one!
            HBaseRpcController controller = rpcControllerFactory.newController();
            FlushRegionRequest request = RequestConverter.buildFlushRegionRequest(hRegionInfo.getRegionName());
            admin.flushRegion(controller, request);
            return null;
        }
    };
    ProtobufUtil.call(callable);
}
Also used : HRegionInfo(org.apache.hadoop.hbase.HRegionInfo) HBaseRpcController(org.apache.hadoop.hbase.ipc.HBaseRpcController) AdminService(org.apache.hadoop.hbase.shaded.protobuf.generated.AdminProtos.AdminService) ServerName(org.apache.hadoop.hbase.ServerName) Callable(java.util.concurrent.Callable) FlushRegionRequest(org.apache.hadoop.hbase.shaded.protobuf.generated.AdminProtos.FlushRegionRequest)

Example 14 with HBaseRpcController

use of org.apache.hadoop.hbase.ipc.HBaseRpcController in project hbase by apache.

the class HBaseAdmin method rollWALWriterImpl.

private RollWALWriterResponse rollWALWriterImpl(final ServerName sn) throws IOException, FailedLogCloseException {
    final AdminService.BlockingInterface admin = this.connection.getAdmin(sn);
    RollWALWriterRequest request = RequestConverter.buildRollWALWriterRequest();
    // TODO: There is no timeout on this controller. Set one!
    HBaseRpcController controller = rpcControllerFactory.newController();
    try {
        return admin.rollWALWriter(controller, request);
    } catch (ServiceException e) {
        throw ProtobufUtil.handleRemoteException(e);
    }
}
Also used : HBaseRpcController(org.apache.hadoop.hbase.ipc.HBaseRpcController) AdminService(org.apache.hadoop.hbase.shaded.protobuf.generated.AdminProtos.AdminService) ServiceException(org.apache.hadoop.hbase.shaded.com.google.protobuf.ServiceException) RollWALWriterRequest(org.apache.hadoop.hbase.shaded.protobuf.generated.AdminProtos.RollWALWriterRequest)

Example 15 with HBaseRpcController

use of org.apache.hadoop.hbase.ipc.HBaseRpcController in project hbase by apache.

the class TestHCM method testCallableSleep.

@Test
public void testCallableSleep() throws Exception {
    long pauseTime;
    long baseTime = 100;
    final TableName tableName = TableName.valueOf(name.getMethodName());
    TEST_UTIL.createTable(tableName, FAM_NAM);
    ClientServiceCallable<Object> regionServerCallable = new ClientServiceCallable<Object>(TEST_UTIL.getConnection(), tableName, ROW, new RpcControllerFactory(TEST_UTIL.getConfiguration()).newController()) {

        @Override
        protected Object rpcCall() throws Exception {
            return null;
        }
    };
    regionServerCallable.prepare(false);
    for (int i = 0; i < HConstants.RETRY_BACKOFF.length; i++) {
        pauseTime = regionServerCallable.sleep(baseTime, i);
        assertTrue(pauseTime >= (baseTime * HConstants.RETRY_BACKOFF[i]));
        assertTrue(pauseTime <= (baseTime * HConstants.RETRY_BACKOFF[i] * 1.01f));
    }
    RegionAdminServiceCallable<Object> regionAdminServiceCallable = new RegionAdminServiceCallable<Object>((ClusterConnection) TEST_UTIL.getConnection(), new RpcControllerFactory(TEST_UTIL.getConfiguration()), tableName, ROW) {

        @Override
        public Object call(HBaseRpcController controller) throws Exception {
            return null;
        }
    };
    regionAdminServiceCallable.prepare(false);
    for (int i = 0; i < HConstants.RETRY_BACKOFF.length; i++) {
        pauseTime = regionAdminServiceCallable.sleep(baseTime, i);
        assertTrue(pauseTime >= (baseTime * HConstants.RETRY_BACKOFF[i]));
        assertTrue(pauseTime <= (baseTime * HConstants.RETRY_BACKOFF[i] * 1.01f));
    }
    MasterCallable<Object> masterCallable = new MasterCallable<Object>(TEST_UTIL.getConnection(), new RpcControllerFactory(TEST_UTIL.getConfiguration())) {

        @Override
        protected Object rpcCall() throws Exception {
            return null;
        }
    };
    try {
        for (int i = 0; i < HConstants.RETRY_BACKOFF.length; i++) {
            pauseTime = masterCallable.sleep(baseTime, i);
            assertTrue(pauseTime >= (baseTime * HConstants.RETRY_BACKOFF[i]));
            assertTrue(pauseTime <= (baseTime * HConstants.RETRY_BACKOFF[i] * 1.01f));
        }
    } finally {
        masterCallable.close();
    }
}
Also used : TableName(org.apache.hadoop.hbase.TableName) HBaseRpcController(org.apache.hadoop.hbase.ipc.HBaseRpcController) RpcControllerFactory(org.apache.hadoop.hbase.ipc.RpcControllerFactory) Test(org.junit.Test)

Aggregations

HBaseRpcController (org.apache.hadoop.hbase.ipc.HBaseRpcController)32 IOException (java.io.IOException)19 AdminService (org.apache.hadoop.hbase.shaded.protobuf.generated.AdminProtos.AdminService)16 ServiceException (org.apache.hadoop.hbase.shaded.com.google.protobuf.ServiceException)12 DoNotRetryIOException (org.apache.hadoop.hbase.DoNotRetryIOException)10 InterruptedIOException (java.io.InterruptedIOException)9 HBaseIOException (org.apache.hadoop.hbase.HBaseIOException)6 NotServingRegionException (org.apache.hadoop.hbase.NotServingRegionException)6 ArrayList (java.util.ArrayList)5 CellScanner (org.apache.hadoop.hbase.CellScanner)5 ServerName (org.apache.hadoop.hbase.ServerName)5 Result (org.apache.hadoop.hbase.client.Result)4 RpcCallContext (org.apache.hadoop.hbase.ipc.RpcCallContext)4 OperationQuota (org.apache.hadoop.hbase.quotas.OperationQuota)4 RegionActionResult (org.apache.hadoop.hbase.shaded.protobuf.generated.ClientProtos.RegionActionResult)4 RemoteException (org.apache.hadoop.ipc.RemoteException)4 Callable (java.util.concurrent.Callable)3 CellScannable (org.apache.hadoop.hbase.CellScannable)3 HRegionInfo (org.apache.hadoop.hbase.HRegionInfo)3 ConcurrentHashMap (java.util.concurrent.ConcurrentHashMap)2