@Override public void dummyThrow(RpcController controller, DummyRequest request, RpcCallback<DummyResponse> done) { CoprocessorRpcUtils.setControllerException(controller, WHAT_TO_THROW); } }
@Override public boolean registerService(com.google.protobuf.Service instance) { /* * No stacking of instances is allowed for a single executorService name */ com.google.protobuf.Descriptors.ServiceDescriptor serviceDesc = instance.getDescriptorForType(); String serviceName = CoprocessorRpcUtils.getServiceName(serviceDesc); if (coprocessorServiceHandlers.containsKey(serviceName)) { LOG.error("Coprocessor executorService " + serviceName + " already registered, rejecting request from " + instance); return false; } coprocessorServiceHandlers.put(serviceName, instance); if (LOG.isDebugEnabled()) { LOG.debug("Registered regionserver coprocessor executorService: executorService=" + serviceName); } return true; }
@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); } } };
CoprocessorRpcUtils.getRequest(service, methodDesc, call.getRequest()); final com.google.protobuf.Message.Builder responseBuilder = service.getResponsePrototype(methodDesc).newBuilderForType(); IOException exception = CoprocessorRpcUtils.getControllerException(serviceController); if (exception != null) { throw exception; return CoprocessorRpcUtils.getResponse(responseBuilder.build(), HConstants.EMPTY_BYTE_ARRAY); } catch (IOException ie) { throw new ServiceException(ie);
com.google.protobuf.Descriptors.ServiceDescriptor serviceDesc = service.getDescriptorForType(); com.google.protobuf.Descriptors.MethodDescriptor methodDesc = CoprocessorRpcUtils.getMethodDescriptor(methodName, serviceDesc); CoprocessorRpcUtils.getRequest(service, methodDesc, call.getRequest()); final com.google.protobuf.Message.Builder responseBuilder = service.getResponsePrototype(methodDesc).newBuilderForType(); throw execController.getFailedOn(); return CoprocessorRpcUtils.getResponse(execResult, HConstants.EMPTY_BYTE_ARRAY); } catch (IOException ie) { throw new ServiceException(ie);
public static CoprocessorServiceRequest getCoprocessorServiceRequest( final Descriptors.MethodDescriptor method, final Message request) { return getCoprocessorServiceRequest(method, request, HConstants.EMPTY_BYTE_ARRAY, HConstants.EMPTY_BYTE_ARRAY); }
@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); } } };
public static CoprocessorServiceRequest getCoprocessorServiceRequest( final Descriptors.MethodDescriptor method, final Message request, final byte [] row, final byte [] regionName) { return CoprocessorServiceRequest.newBuilder().setCall( getCoprocessorServiceCall(method, request, row)). setRegion(RequestConverter.buildRegionSpecifier(REGION_NAME, regionName)).build(); }
private CompletableFuture<Message> rpcCall(MethodDescriptor method, Message request, Message responsePrototype, HBaseRpcController controller, ClientService.Interface stub) { CompletableFuture<Message> future = new CompletableFuture<>(); CoprocessorServiceRequest csr = CoprocessorRpcUtils.getCoprocessorServiceRequest(method, request); stub.execRegionServerService( controller, csr, new org.apache.hbase.thirdparty.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; }
@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(), HConstants.PRIORITY_UNSET) { @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); }
public static CoprocessorServiceRequest getCoprocessorServiceRequest( final Descriptors.MethodDescriptor method, final Message request, final byte [] row, final byte [] regionName) { return CoprocessorServiceRequest.newBuilder().setCall( getCoprocessorServiceCall(method, request, row)). setRegion(RequestConverter.buildRegionSpecifier(REGION_NAME, regionName)).build(); }
@Override public void dummyThrow(RpcController controller, DummyRequest request, RpcCallback<DummyResponse> done) { CoprocessorRpcUtils.setControllerException(controller, WHAT_TO_THROW); } }
@Override public boolean registerService(Service instance) { /* * No stacking of instances is allowed for a single service name */ Descriptors.ServiceDescriptor serviceDesc = instance.getDescriptorForType(); String serviceName = CoprocessorRpcUtils.getServiceName(serviceDesc); if (coprocessorServiceHandlers.containsKey(serviceName)) { LOG.error("Coprocessor service "+serviceName+ " already registered, rejecting request from "+instance ); return false; } coprocessorServiceHandlers.put(serviceName, instance); if (LOG.isDebugEnabled()) { LOG.debug("Registered master coprocessor service: service="+serviceName); } return true; }
@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); } } };
private CompletableFuture<Message> rpcCall(MethodDescriptor method, Message request, Message responsePrototype, HBaseRpcController controller, MasterService.Interface stub) { CompletableFuture<Message> future = new CompletableFuture<>(); CoprocessorServiceRequest csr = CoprocessorRpcUtils.getCoprocessorServiceRequest(method, request); stub.execMasterService( controller, csr, new org.apache.hbase.thirdparty.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; }
@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); } } };
public static CoprocessorServiceRequest getCoprocessorServiceRequest( final Descriptors.MethodDescriptor method, final Message request, final byte [] row, final byte [] regionName) { return CoprocessorServiceRequest.newBuilder().setCall( getCoprocessorServiceCall(method, request, row)). setRegion(RequestConverter.buildRegionSpecifier(REGION_NAME, regionName)).build(); }
@Override @InterfaceAudience.Private public void callMethod(Descriptors.MethodDescriptor method, RpcController controller, Message request, Message responsePrototype, RpcCallback<Message> callback) { Message response = null; try { response = callExecService(controller, method, request, responsePrototype); } catch (IOException ioe) { LOG.warn("Call failed on IOException", ioe); CoprocessorRpcUtils.setControllerException(controller, ioe); } if (callback != null) { callback.run(response); } }
String serviceName = CoprocessorRpcUtils.getServiceName(serviceDesc); if (coprocessorServiceHandlers.containsKey(serviceName)) { LOG.error("Coprocessor service " + serviceName +
@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); } } };