Search in sources :

Example 1 with CoprocessorServiceResponse

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

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

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

Example 4 with CoprocessorServiceResponse

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

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

the class RSRpcServices method execService.

@Override
public CoprocessorServiceResponse execService(final RpcController controller, final CoprocessorServiceRequest request) throws ServiceException {
    try {
        checkOpen();
        requestCount.increment();
        Region region = getRegion(request.getRegion());
        com.google.protobuf.Message result = execServiceOnRegion(region, request.getCall());
        CoprocessorServiceResponse.Builder builder = CoprocessorServiceResponse.newBuilder();
        builder.setRegion(RequestConverter.buildRegionSpecifier(RegionSpecifierType.REGION_NAME, region.getRegionInfo().getRegionName()));
        // TODO: COPIES!!!!!!
        builder.setValue(builder.getValueBuilder().setName(result.getClass().getName()).setValue(org.apache.hadoop.hbase.shaded.com.google.protobuf.ByteString.copyFrom(result.toByteArray())));
        return builder.build();
    } catch (IOException ie) {
        throw new ServiceException(ie);
    }
}
Also used : ServiceException(org.apache.hadoop.hbase.shaded.com.google.protobuf.ServiceException) CoprocessorServiceResponse(org.apache.hadoop.hbase.shaded.protobuf.generated.ClientProtos.CoprocessorServiceResponse) Message(org.apache.hadoop.hbase.shaded.com.google.protobuf.Message) InterruptedIOException(java.io.InterruptedIOException) IOException(java.io.IOException) DoNotRetryIOException(org.apache.hadoop.hbase.DoNotRetryIOException) HBaseIOException(org.apache.hadoop.hbase.HBaseIOException)

Aggregations

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