Search in sources :

Example 6 with ServiceDescriptor

use of org.apache.hbase.thirdparty.com.google.protobuf.Descriptors.ServiceDescriptor in project hbase by apache.

the class HRegionServer method registerService.

@Override
public boolean registerService(Service instance) {
    // No stacking of instances is allowed for a single executorService name
    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;
}
Also used : ServiceDescriptor(org.apache.hbase.thirdparty.com.google.protobuf.Descriptors.ServiceDescriptor)

Example 7 with ServiceDescriptor

use of org.apache.hbase.thirdparty.com.google.protobuf.Descriptors.ServiceDescriptor in project hbase by apache.

the class HRegionServer method execRegionServerService.

CoprocessorServiceResponse execRegionServerService(@SuppressWarnings("UnusedParameters") final RpcController controller, final CoprocessorServiceRequest serviceRequest) throws ServiceException {
    try {
        ServerRpcController serviceController = new ServerRpcController();
        CoprocessorServiceCall call = serviceRequest.getCall();
        String serviceName = call.getServiceName();
        Service service = coprocessorServiceHandlers.get(serviceName);
        if (service == null) {
            throw new UnknownProtocolException(null, "No registered coprocessor executorService found for " + serviceName);
        }
        ServiceDescriptor serviceDesc = service.getDescriptorForType();
        String methodName = call.getMethodName();
        MethodDescriptor methodDesc = serviceDesc.findMethodByName(methodName);
        if (methodDesc == null) {
            throw new UnknownProtocolException(service.getClass(), "Unknown method " + methodName + " called on executorService " + serviceName);
        }
        Message request = CoprocessorRpcUtils.getRequest(service, methodDesc, call.getRequest());
        final Message.Builder responseBuilder = service.getResponsePrototype(methodDesc).newBuilderForType();
        service.callMethod(methodDesc, serviceController, request, message -> {
            if (message != null) {
                responseBuilder.mergeFrom(message);
            }
        });
        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);
    }
}
Also used : CoprocessorServiceCall(org.apache.hadoop.hbase.shaded.protobuf.generated.ClientProtos.CoprocessorServiceCall) Message(org.apache.hbase.thirdparty.com.google.protobuf.Message) ServiceException(org.apache.hbase.thirdparty.com.google.protobuf.ServiceException) ServiceDescriptor(org.apache.hbase.thirdparty.com.google.protobuf.Descriptors.ServiceDescriptor) LockService(org.apache.hadoop.hbase.shaded.protobuf.generated.LockServiceProtos.LockService) Service(org.apache.hbase.thirdparty.com.google.protobuf.Service) RegionServerStatusService(org.apache.hadoop.hbase.shaded.protobuf.generated.RegionServerStatusProtos.RegionServerStatusService) UnknownProtocolException(org.apache.hadoop.hbase.exceptions.UnknownProtocolException) IOException(java.io.IOException) DoNotRetryIOException(org.apache.hadoop.hbase.DoNotRetryIOException) ServerRpcController(org.apache.hadoop.hbase.ipc.ServerRpcController) MethodDescriptor(org.apache.hbase.thirdparty.com.google.protobuf.Descriptors.MethodDescriptor)

Aggregations

ServiceDescriptor (org.apache.hbase.thirdparty.com.google.protobuf.Descriptors.ServiceDescriptor)7 IOException (java.io.IOException)3 DoNotRetryIOException (org.apache.hadoop.hbase.DoNotRetryIOException)3 UnknownProtocolException (org.apache.hadoop.hbase.exceptions.UnknownProtocolException)3 MethodDescriptor (org.apache.hbase.thirdparty.com.google.protobuf.Descriptors.MethodDescriptor)3 Message (org.apache.hbase.thirdparty.com.google.protobuf.Message)3 Service (org.apache.hbase.thirdparty.com.google.protobuf.Service)3 ServerRpcController (org.apache.hadoop.hbase.ipc.ServerRpcController)2 LockService (org.apache.hadoop.hbase.shaded.protobuf.generated.LockServiceProtos.LockService)2 RegionServerStatusService (org.apache.hadoop.hbase.shaded.protobuf.generated.RegionServerStatusProtos.RegionServerStatusService)2 ServiceException (org.apache.hbase.thirdparty.com.google.protobuf.ServiceException)2 InterruptedIOException (java.io.InterruptedIOException)1 CompletionService (java.util.concurrent.CompletionService)1 ExecutorCompletionService (java.util.concurrent.ExecutorCompletionService)1 TimeoutIOException (org.apache.hadoop.hbase.exceptions.TimeoutIOException)1 BlockingServiceAndInterface (org.apache.hadoop.hbase.ipc.RpcServer.BlockingServiceAndInterface)1 User (org.apache.hadoop.hbase.security.User)1 InputUser (org.apache.hadoop.hbase.security.access.AccessChecker.InputUser)1 AccessControlService (org.apache.hadoop.hbase.shaded.protobuf.generated.AccessControlProtos.AccessControlService)1 AdminService (org.apache.hadoop.hbase.shaded.protobuf.generated.AdminProtos.AdminService)1