public Message execService(RpcController controller, CoprocessorServiceCall call)
    throws IOException {
    String serviceName = call.getServiceName();
    Service service = coprocessorServiceHandlers.get(serviceName);
    if (service == null) {
      throw new UnknownProtocolException(null, "No registered coprocessor service found for "
        + serviceName + " in region " + Bytes.toStringBinary(getRegionInfo().getRegionName()));
    }
    ServiceDescriptor serviceDesc = service.getDescriptorForType();

    cpRequestsCount.increment();
    String methodName = call.getMethodName();
    MethodDescriptor methodDesc = CoprocessorRpcUtils.getMethodDescriptor(methodName, serviceDesc);

    Message.Builder builder = service.getRequestPrototype(methodDesc).newBuilderForType();

    ProtobufUtil.mergeFrom(builder, call.getRequest().toByteArray());
    Message request = CoprocessorRpcUtils.getRequest(service, methodDesc, call.getRequest());

    if (coprocessorHost != null) {
      request = coprocessorHost.preEndpointInvocation(service, methodName, request);
    }

    final Message.Builder responseBuilder =
      service.getResponsePrototype(methodDesc).newBuilderForType();
    service.callMethod(methodDesc, controller, request, new RpcCallback<Message>() {
      @Override
      public void run(Message message) {
        if (message != null) {
          responseBuilder.mergeFrom(message);
        }
      }
    });

    if (coprocessorHost != null) {
      coprocessorHost.postEndpointInvocation(service, methodName, request, responseBuilder);
    }
    IOException exception =
      org.apache.hadoop.hbase.ipc.CoprocessorRpcUtils.getControllerException(controller);
    if (exception != null) {
      throw exception;
    }

    return responseBuilder.build();
  }
Executes a single protocol buffer coprocessor endpoint {@link Service} method using the
registered protocol handlers. {@link Service} implementations must be registered via the
{@link #registerService(Service)} method before they are available.
@param controller an {@code RpcContoller} implementation to pass to the invoked service
@param call       a {@code CoprocessorServiceCall} instance identifying the service, method,
                  and parameters for the method invocation
@return a protocol buffer {@code Message} instance containing the method's result
@throws IOException if no registered service handler is found or an error occurs during the
                    invocation
@see #registerService(Service)
hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/HRegion.java