Search in sources :

Example 56 with ServiceException

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

the class ProtobufUtil method getOnlineRegions.

/**
 * A helper to get the all the online regions on a region
 * server using admin protocol.
 * @return a list of online region info
 */
public static List<org.apache.hadoop.hbase.client.RegionInfo> getOnlineRegions(final RpcController controller, final AdminService.BlockingInterface admin) throws IOException {
    GetOnlineRegionRequest request = RequestConverter.buildGetOnlineRegionRequest();
    GetOnlineRegionResponse response = null;
    try {
        response = admin.getOnlineRegion(controller, request);
    } catch (ServiceException se) {
        throw getRemoteException(se);
    }
    return getRegionInfos(response);
}
Also used : ServiceException(org.apache.hbase.thirdparty.com.google.protobuf.ServiceException) GetOnlineRegionRequest(org.apache.hadoop.hbase.shaded.protobuf.generated.AdminProtos.GetOnlineRegionRequest) GetOnlineRegionResponse(org.apache.hadoop.hbase.shaded.protobuf.generated.AdminProtos.GetOnlineRegionResponse)

Example 57 with ServiceException

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

the class HBaseHbck method setRegionStateInMeta.

@Override
public Map<String, RegionState.State> setRegionStateInMeta(Map<String, RegionState.State> nameOrEncodedName2State) throws IOException {
    try {
        if (LOG.isDebugEnabled()) {
            nameOrEncodedName2State.forEach((k, v) -> LOG.debug("region={}, state={}", k, v));
        }
        MasterProtos.SetRegionStateInMetaResponse response = hbck.setRegionStateInMeta(rpcControllerFactory.newController(), RequestConverter.buildSetRegionStateInMetaRequest(nameOrEncodedName2State));
        Map<String, RegionState.State> result = new HashMap<>();
        for (RegionSpecifierAndState nameAndState : response.getStatesList()) {
            result.put(nameAndState.getRegionSpecifier().getValue().toStringUtf8(), RegionState.State.convert(nameAndState.getState()));
        }
        return result;
    } catch (ServiceException se) {
        throw new IOException(se);
    }
}
Also used : RegionSpecifierAndState(org.apache.hadoop.hbase.shaded.protobuf.generated.MasterProtos.RegionSpecifierAndState) ServiceException(org.apache.hbase.thirdparty.com.google.protobuf.ServiceException) HashMap(java.util.HashMap) RegionState(org.apache.hadoop.hbase.master.RegionState) RegionSpecifierAndState(org.apache.hadoop.hbase.shaded.protobuf.generated.MasterProtos.RegionSpecifierAndState) IOException(java.io.IOException) MasterProtos(org.apache.hadoop.hbase.shaded.protobuf.generated.MasterProtos)

Example 58 with ServiceException

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

the class HBaseRpcServicesBase method updateConfiguration.

@Override
public UpdateConfigurationResponse updateConfiguration(RpcController controller, UpdateConfigurationRequest request) throws ServiceException {
    try {
        requirePermission("updateConfiguration", Permission.Action.ADMIN);
        this.server.updateConfiguration();
    } catch (Exception e) {
        throw new ServiceException(e);
    }
    return UpdateConfigurationResponse.getDefaultInstance();
}
Also used : ServiceException(org.apache.hbase.thirdparty.com.google.protobuf.ServiceException) ServiceException(org.apache.hbase.thirdparty.com.google.protobuf.ServiceException) InvocationTargetException(java.lang.reflect.InvocationTargetException) BindException(java.net.BindException) KeeperException(org.apache.zookeeper.KeeperException) IOException(java.io.IOException)

Example 59 with ServiceException

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

the class HBaseRpcServicesBase method getLogEntries.

@Override
@QosPriority(priority = HConstants.ADMIN_QOS)
public HBaseProtos.LogEntry getLogEntries(RpcController controller, HBaseProtos.LogRequest request) throws ServiceException {
    try {
        final String logClassName = request.getLogClassName();
        Class<?> logClass = Class.forName(logClassName).asSubclass(Message.class);
        Method method = logClass.getMethod("parseFrom", ByteString.class);
        if (logClassName.contains("SlowLogResponseRequest")) {
            SlowLogResponseRequest slowLogResponseRequest = (SlowLogResponseRequest) method.invoke(null, request.getLogMessage());
            final NamedQueueRecorder namedQueueRecorder = this.server.getNamedQueueRecorder();
            final List<SlowLogPayload> slowLogPayloads = getSlowLogPayloads(slowLogResponseRequest, namedQueueRecorder);
            SlowLogResponses slowLogResponses = SlowLogResponses.newBuilder().addAllSlowLogPayloads(slowLogPayloads).build();
            return HBaseProtos.LogEntry.newBuilder().setLogClassName(slowLogResponses.getClass().getName()).setLogMessage(slowLogResponses.toByteString()).build();
        }
    } catch (ClassNotFoundException | NoSuchMethodException | IllegalAccessException | InvocationTargetException e) {
        LOG.error("Error while retrieving log entries.", e);
        throw new ServiceException(e);
    }
    throw new ServiceException("Invalid request params");
}
Also used : SlowLogPayload(org.apache.hadoop.hbase.shaded.protobuf.generated.TooSlowLog.SlowLogPayload) ByteString(org.apache.hbase.thirdparty.com.google.protobuf.ByteString) Method(java.lang.reflect.Method) InvocationTargetException(java.lang.reflect.InvocationTargetException) NamedQueueRecorder(org.apache.hadoop.hbase.namequeues.NamedQueueRecorder) SlowLogResponseRequest(org.apache.hadoop.hbase.shaded.protobuf.generated.AdminProtos.SlowLogResponseRequest) ClearSlowLogResponseRequest(org.apache.hadoop.hbase.shaded.protobuf.generated.AdminProtos.ClearSlowLogResponseRequest) ClearSlowLogResponses(org.apache.hadoop.hbase.shaded.protobuf.generated.AdminProtos.ClearSlowLogResponses) SlowLogResponses(org.apache.hadoop.hbase.shaded.protobuf.generated.AdminProtos.SlowLogResponses) ServiceException(org.apache.hbase.thirdparty.com.google.protobuf.ServiceException) QosPriority(org.apache.hadoop.hbase.ipc.QosPriority)

Example 60 with ServiceException

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

the class AbstractTestIPC method testRpcMaxRequestSize.

/**
 * Tests that the rpc scheduler is called when requests arrive.
 */
@Test
public void testRpcMaxRequestSize() throws IOException, ServiceException {
    Configuration conf = new Configuration(CONF);
    conf.setInt(RpcServer.MAX_REQUEST_SIZE, 1000);
    RpcServer rpcServer = createRpcServer(null, "testRpcServer", Lists.newArrayList(new RpcServer.BlockingServiceAndInterface(SERVICE, null)), new InetSocketAddress("localhost", 0), conf, new FifoRpcScheduler(conf, 1));
    try (AbstractRpcClient<?> client = createRpcClient(conf)) {
        rpcServer.start();
        BlockingInterface stub = newBlockingStub(client, rpcServer.getListenerAddress());
        StringBuilder message = new StringBuilder(1200);
        for (int i = 0; i < 200; i++) {
            message.append("hello.");
        }
        // set total RPC size bigger than 100 bytes
        EchoRequestProto param = EchoRequestProto.newBuilder().setMessage(message.toString()).build();
        stub.echo(new HBaseRpcControllerImpl(CellUtil.createCellScanner(ImmutableList.<Cell>of(CELL))), param);
        fail("RPC should have failed because it exceeds max request size");
    } catch (ServiceException e) {
        LOG.info("Caught expected exception: " + e);
        assertTrue(e.toString(), StringUtils.stringifyException(e).contains("RequestTooBigException"));
    } finally {
        rpcServer.stop();
    }
}
Also used : BlockingInterface(org.apache.hadoop.hbase.shaded.ipc.protobuf.generated.TestRpcServiceProtos.TestProtobufRpcProto.BlockingInterface) Configuration(org.apache.hadoop.conf.Configuration) HBaseConfiguration(org.apache.hadoop.hbase.HBaseConfiguration) BlockingServiceAndInterface(org.apache.hadoop.hbase.ipc.RpcServer.BlockingServiceAndInterface) EchoRequestProto(org.apache.hadoop.hbase.shaded.ipc.protobuf.generated.TestProtos.EchoRequestProto) ServiceException(org.apache.hbase.thirdparty.com.google.protobuf.ServiceException) InetSocketAddress(java.net.InetSocketAddress) Test(org.junit.Test)

Aggregations

ServiceException (org.apache.hbase.thirdparty.com.google.protobuf.ServiceException)130 IOException (java.io.IOException)112 DoNotRetryIOException (org.apache.hadoop.hbase.DoNotRetryIOException)100 ByteString (org.apache.hbase.thirdparty.com.google.protobuf.ByteString)39 HBaseIOException (org.apache.hadoop.hbase.HBaseIOException)28 UncheckedIOException (java.io.UncheckedIOException)27 TableName (org.apache.hadoop.hbase.TableName)22 QosPriority (org.apache.hadoop.hbase.ipc.QosPriority)22 RegionInfo (org.apache.hadoop.hbase.client.RegionInfo)19 UnknownRegionException (org.apache.hadoop.hbase.UnknownRegionException)16 UnknownProtocolException (org.apache.hadoop.hbase.exceptions.UnknownProtocolException)16 Test (org.junit.Test)16 InvocationTargetException (java.lang.reflect.InvocationTargetException)15 ArrayList (java.util.ArrayList)15 TableDescriptor (org.apache.hadoop.hbase.client.TableDescriptor)15 ForeignException (org.apache.hadoop.hbase.errorhandling.ForeignException)15 ServerNotRunningYetException (org.apache.hadoop.hbase.ipc.ServerNotRunningYetException)15 KeeperException (org.apache.zookeeper.KeeperException)14 Table (org.apache.hadoop.hbase.client.Table)13 User (org.apache.hadoop.hbase.security.User)13