Search in sources :

Example 46 with ServiceException

use of org.apache.hadoop.hbase.shaded.com.google.protobuf.ServiceException in project hbase by apache.

the class TestMetaTableLocator method testVerifyMetaRegionLocationFails.

/**
   * Test get of meta region fails properly if nothing to connect to.
   * @throws IOException
   * @throws InterruptedException
   * @throws KeeperException
   * @throws ServiceException
   */
@Test
public void testVerifyMetaRegionLocationFails() throws IOException, InterruptedException, KeeperException, ServiceException {
    ClusterConnection connection = Mockito.mock(ClusterConnection.class);
    ServiceException connectException = new ServiceException(new ConnectException("Connection refused"));
    final AdminProtos.AdminService.BlockingInterface implementation = Mockito.mock(AdminProtos.AdminService.BlockingInterface.class);
    Mockito.when(implementation.getRegionInfo((RpcController) Mockito.any(), (GetRegionInfoRequest) Mockito.any())).thenThrow(connectException);
    Mockito.when(connection.getAdmin(Mockito.any(ServerName.class))).thenReturn(implementation);
    RpcControllerFactory controllerFactory = Mockito.mock(RpcControllerFactory.class);
    Mockito.when(controllerFactory.newController()).thenReturn(Mockito.mock(HBaseRpcController.class));
    Mockito.when(connection.getRpcControllerFactory()).thenReturn(controllerFactory);
    ServerName sn = ServerName.valueOf("example.com", 1234, System.currentTimeMillis());
    MetaTableLocator.setMetaLocation(this.watcher, sn, RegionState.State.OPENING);
    assertFalse(new MetaTableLocator().verifyMetaRegionLocation(connection, watcher, 100));
    MetaTableLocator.setMetaLocation(this.watcher, sn, RegionState.State.OPEN);
    assertFalse(new MetaTableLocator().verifyMetaRegionLocation(connection, watcher, 100));
}
Also used : ClusterConnection(org.apache.hadoop.hbase.client.ClusterConnection) HBaseRpcController(org.apache.hadoop.hbase.ipc.HBaseRpcController) MetaTableLocator(org.apache.hadoop.hbase.zookeeper.MetaTableLocator) ServiceException(org.apache.hadoop.hbase.shaded.com.google.protobuf.ServiceException) RpcControllerFactory(org.apache.hadoop.hbase.ipc.RpcControllerFactory) ConnectException(java.net.ConnectException) Test(org.junit.Test)

Example 47 with ServiceException

use of org.apache.hadoop.hbase.shaded.com.google.protobuf.ServiceException in project hbase by apache.

the class HBaseAdmin method drainRegionServers.

@Override
public void drainRegionServers(List<ServerName> servers) throws IOException {
    final List<HBaseProtos.ServerName> pbServers = new ArrayList<>(servers.size());
    for (ServerName server : servers) {
        // Parse to ServerName to do simple validation.
        ServerName.parseServerName(server.toString());
        pbServers.add(ProtobufUtil.toServerName(server));
    }
    executeCallable(new MasterCallable<Void>(getConnection(), getRpcControllerFactory()) {

        @Override
        public Void rpcCall() throws ServiceException {
            DrainRegionServersRequest req = DrainRegionServersRequest.newBuilder().addAllServerName(pbServers).build();
            master.drainRegionServers(getRpcController(), req);
            return null;
        }
    });
}
Also used : DrainRegionServersRequest(org.apache.hadoop.hbase.shaded.protobuf.generated.MasterProtos.DrainRegionServersRequest) ServiceException(org.apache.hadoop.hbase.shaded.com.google.protobuf.ServiceException) ServerName(org.apache.hadoop.hbase.ServerName) ArrayList(java.util.ArrayList)

Example 48 with ServiceException

use of org.apache.hadoop.hbase.shaded.com.google.protobuf.ServiceException in project hbase by apache.

the class HBaseAdmin method coprocessorService.

@Override
public CoprocessorRpcChannel coprocessorService(final ServerName serverName) {
    return new SyncCoprocessorRpcChannel() {

        @Override
        protected Message callExecService(RpcController controller, Descriptors.MethodDescriptor method, Message request, Message responsePrototype) throws IOException {
            if (LOG.isTraceEnabled()) {
                LOG.trace("Call: " + method.getName() + ", " + request.toString());
            }
            CoprocessorServiceRequest csr = CoprocessorRpcUtils.getCoprocessorServiceRequest(method, request);
            // TODO: Are we retrying here? Does not seem so. We should use RetryingRpcCaller
            // TODO: Make this same as RegionCoprocessorRpcChannel and MasterCoprocessorRpcChannel. They
            // are all different though should do same thing; e.g. RpcChannel setup.
            ClientProtos.ClientService.BlockingInterface stub = connection.getClient(serverName);
            CoprocessorServiceResponse result;
            try {
                result = stub.execRegionServerService(connection.getRpcControllerFactory().newController(), csr);
                return CoprocessorRpcUtils.getResponse(result, responsePrototype);
            } catch (ServiceException e) {
                throw ProtobufUtil.handleRemoteException(e);
            }
        }
    };
}
Also used : RpcController(com.google.protobuf.RpcController) HBaseRpcController(org.apache.hadoop.hbase.ipc.HBaseRpcController) CoprocessorServiceRequest(org.apache.hadoop.hbase.shaded.protobuf.generated.ClientProtos.CoprocessorServiceRequest) Message(com.google.protobuf.Message) ServiceException(org.apache.hadoop.hbase.shaded.com.google.protobuf.ServiceException) CoprocessorServiceResponse(org.apache.hadoop.hbase.shaded.protobuf.generated.ClientProtos.CoprocessorServiceResponse)

Example 49 with ServiceException

use of org.apache.hadoop.hbase.shaded.com.google.protobuf.ServiceException 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 50 with ServiceException

use of org.apache.hadoop.hbase.shaded.com.google.protobuf.ServiceException in project hbase by apache.

the class HBaseAdmin method removeDrainFromRegionServers.

@Override
public void removeDrainFromRegionServers(List<ServerName> servers) throws IOException {
    final List<HBaseProtos.ServerName> pbServers = new ArrayList<>(servers.size());
    for (ServerName server : servers) {
        pbServers.add(ProtobufUtil.toServerName(server));
    }
    executeCallable(new MasterCallable<Void>(getConnection(), getRpcControllerFactory()) {

        @Override
        public Void rpcCall() throws ServiceException {
            RemoveDrainFromRegionServersRequest req = RemoveDrainFromRegionServersRequest.newBuilder().addAllServerName(pbServers).build();
            master.removeDrainFromRegionServers(getRpcController(), req);
            return null;
        }
    });
}
Also used : ServiceException(org.apache.hadoop.hbase.shaded.com.google.protobuf.ServiceException) RemoveDrainFromRegionServersRequest(org.apache.hadoop.hbase.shaded.protobuf.generated.MasterProtos.RemoveDrainFromRegionServersRequest) ServerName(org.apache.hadoop.hbase.ServerName) ArrayList(java.util.ArrayList)

Aggregations

ServiceException (org.apache.hadoop.hbase.shaded.com.google.protobuf.ServiceException)95 IOException (java.io.IOException)76 DoNotRetryIOException (org.apache.hadoop.hbase.DoNotRetryIOException)65 InterruptedIOException (java.io.InterruptedIOException)28 HBaseIOException (org.apache.hadoop.hbase.HBaseIOException)24 ServerName (org.apache.hadoop.hbase.ServerName)16 QosPriority (org.apache.hadoop.hbase.ipc.QosPriority)15 HRegionInfo (org.apache.hadoop.hbase.HRegionInfo)14 ArrayList (java.util.ArrayList)12 HBaseRpcController (org.apache.hadoop.hbase.ipc.HBaseRpcController)12 TableName (org.apache.hadoop.hbase.TableName)10 ByteString (org.apache.hadoop.hbase.shaded.com.google.protobuf.ByteString)10 Test (org.junit.Test)9 CellScanner (org.apache.hadoop.hbase.CellScanner)5 UnknownRegionException (org.apache.hadoop.hbase.UnknownRegionException)4 ClusterConnection (org.apache.hadoop.hbase.client.ClusterConnection)4 Result (org.apache.hadoop.hbase.client.Result)4 ForeignException (org.apache.hadoop.hbase.errorhandling.ForeignException)4 RpcCallContext (org.apache.hadoop.hbase.ipc.RpcCallContext)4 OperationQuota (org.apache.hadoop.hbase.quotas.OperationQuota)4