Search in sources :

Example 1 with CoprocessorServiceRequest

use of org.apache.hadoop.hbase.shaded.protobuf.generated.ClientProtos.CoprocessorServiceRequest 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 CoprocessorServiceRequest

use of org.apache.hadoop.hbase.shaded.protobuf.generated.ClientProtos.CoprocessorServiceRequest in project hbase by apache.

the class RegionCoprocessorRpcChannel method callExecService.

@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());
    }
    if (row == null) {
        throw new NullPointerException("Can't be null!");
    }
    ClientServiceCallable<CoprocessorServiceResponse> callable = new ClientServiceCallable<CoprocessorServiceResponse>(this.conn, this.table, this.row, this.conn.getRpcControllerFactory().newController()) {

        @Override
        protected CoprocessorServiceResponse rpcCall() throws Exception {
            byte[] regionName = getLocation().getRegionInfo().getRegionName();
            CoprocessorServiceRequest csr = CoprocessorRpcUtils.getCoprocessorServiceRequest(method, request, row, regionName);
            return getStub().execService(getRpcController(), csr);
        }
    };
    CoprocessorServiceResponse result = this.rpcCallerFactory.<CoprocessorServiceResponse>newCaller().callWithRetries(callable, operationTimeout);
    this.lastRegion = result.getRegion().getValue().toByteArray();
    return CoprocessorRpcUtils.getResponse(result, responsePrototype);
}
Also used : CoprocessorServiceRequest(org.apache.hadoop.hbase.shaded.protobuf.generated.ClientProtos.CoprocessorServiceRequest) CoprocessorServiceResponse(org.apache.hadoop.hbase.shaded.protobuf.generated.ClientProtos.CoprocessorServiceResponse)

Example 3 with CoprocessorServiceRequest

use of org.apache.hadoop.hbase.shaded.protobuf.generated.ClientProtos.CoprocessorServiceRequest 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)

Example 4 with CoprocessorServiceRequest

use of org.apache.hadoop.hbase.shaded.protobuf.generated.ClientProtos.CoprocessorServiceRequest in project hbase by apache.

the class RegionCoprocessorRpcChannelImpl method rpcCall.

private CompletableFuture<Message> rpcCall(MethodDescriptor method, Message request, Message responsePrototype, HBaseRpcController controller, HRegionLocation loc, ClientService.Interface stub) {
    CompletableFuture<Message> future = new CompletableFuture<>();
    if (region != null && !Bytes.equals(loc.getRegionInfo().getRegionName(), region.getRegionName())) {
        future.completeExceptionally(new DoNotRetryIOException("Region name is changed, expected " + region.getRegionNameAsString() + ", actual " + loc.getRegionInfo().getRegionNameAsString()));
        return future;
    }
    CoprocessorServiceRequest csr = CoprocessorRpcUtils.getCoprocessorServiceRequest(method, request, row, loc.getRegionInfo().getRegionName());
    stub.execService(controller, csr, new org.apache.hadoop.hbase.shaded.com.google.protobuf.RpcCallback<CoprocessorServiceResponse>() {

        @Override
        public void run(CoprocessorServiceResponse resp) {
            if (controller.failed()) {
                future.completeExceptionally(controller.getFailed());
            } else {
                try {
                    future.complete(CoprocessorRpcUtils.getResponse(resp, responsePrototype));
                } catch (IOException e) {
                    future.completeExceptionally(e);
                }
            }
        }
    });
    return future;
}
Also used : Message(com.google.protobuf.Message) DoNotRetryIOException(org.apache.hadoop.hbase.DoNotRetryIOException) DoNotRetryIOException(org.apache.hadoop.hbase.DoNotRetryIOException) IOException(java.io.IOException) CompletableFuture(java.util.concurrent.CompletableFuture) CoprocessorServiceRequest(org.apache.hadoop.hbase.shaded.protobuf.generated.ClientProtos.CoprocessorServiceRequest) CoprocessorServiceResponse(org.apache.hadoop.hbase.shaded.protobuf.generated.ClientProtos.CoprocessorServiceResponse)

Aggregations

CoprocessorServiceRequest (org.apache.hadoop.hbase.shaded.protobuf.generated.ClientProtos.CoprocessorServiceRequest)4 CoprocessorServiceResponse (org.apache.hadoop.hbase.shaded.protobuf.generated.ClientProtos.CoprocessorServiceResponse)4 Message (com.google.protobuf.Message)3 RpcController (com.google.protobuf.RpcController)2 HBaseRpcController (org.apache.hadoop.hbase.ipc.HBaseRpcController)2 IOException (java.io.IOException)1 CompletableFuture (java.util.concurrent.CompletableFuture)1 DoNotRetryIOException (org.apache.hadoop.hbase.DoNotRetryIOException)1 ServiceException (org.apache.hadoop.hbase.shaded.com.google.protobuf.ServiceException)1