Search in sources :

Example 1 with RpcController

use of com.google.protobuf.RpcController 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 2 with RpcController

use of com.google.protobuf.RpcController in project hbase by apache.

the class HBaseAdmin method coprocessorService.

@Override
public // Coprocessor Endpoint against the Master.
CoprocessorRpcChannel coprocessorService() {
    return new SyncCoprocessorRpcChannel() {

        @Override
        protected Message callExecService(final RpcController controller, final Descriptors.MethodDescriptor method, final Message request, final Message responsePrototype) throws IOException {
            if (LOG.isTraceEnabled()) {
                LOG.trace("Call: " + method.getName() + ", " + request.toString());
            }
            // Try-with-resources so close gets called when we are done.
            try (MasterCallable<CoprocessorServiceResponse> callable = new MasterCallable<CoprocessorServiceResponse>(connection, connection.getRpcControllerFactory()) {

                @Override
                protected CoprocessorServiceResponse rpcCall() throws Exception {
                    CoprocessorServiceRequest csr = CoprocessorRpcUtils.getCoprocessorServiceRequest(method, request);
                    return this.master.execMasterService(getRpcController(), csr);
                }
            }) {
                // TODO: Are we retrying here? Does not seem so. We should use RetryingRpcCaller
                callable.prepare(false);
                int operationTimeout = connection.getConnectionConfiguration().getOperationTimeout();
                CoprocessorServiceResponse result = callable.call(operationTimeout);
                return CoprocessorRpcUtils.getResponse(result, responsePrototype);
            }
        }
    };
}
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) CoprocessorServiceResponse(org.apache.hadoop.hbase.shaded.protobuf.generated.ClientProtos.CoprocessorServiceResponse)

Aggregations

Message (com.google.protobuf.Message)2 RpcController (com.google.protobuf.RpcController)2 HBaseRpcController (org.apache.hadoop.hbase.ipc.HBaseRpcController)2 CoprocessorServiceRequest (org.apache.hadoop.hbase.shaded.protobuf.generated.ClientProtos.CoprocessorServiceRequest)2 CoprocessorServiceResponse (org.apache.hadoop.hbase.shaded.protobuf.generated.ClientProtos.CoprocessorServiceResponse)2 ServiceException (org.apache.hadoop.hbase.shaded.com.google.protobuf.ServiceException)1