Package com.google.protobuf.Descriptors

Examples of com.google.protobuf.Descriptors.MethodDescriptor


        setupResponse(responseBuffer, callTooBig, new CallQueueTooBigException(),
          "Call queue is full, is ipc.server.max.callqueue.size too small?");
        responder.doRespond(callTooBig);
        return;
      }
      MethodDescriptor md = null;
      Message param = null;
      CellScanner cellScanner = null;
      try {
        if (header.hasRequestParam() && header.getRequestParam()) {
          md = this.service.getDescriptorForType().findMethodByName(header.getMethodName());
View Full Code Here


    assertEquals("TestService", service.getName());
    assertEquals("protobuf_unittest.TestService", service.getFullName());
    assertEquals(UnittestProto.getDescriptor(), service.getFile());


    MethodDescriptor fooMethod = service.getMethods().get(0);
    assertEquals("Foo", fooMethod.getName());
    assertEquals(UnittestProto.FooRequest.getDescriptor(),
                 fooMethod.getInputType());
    assertEquals(UnittestProto.FooResponse.getDescriptor(),
                 fooMethod.getOutputType());
    assertEquals(fooMethod, service.findMethodByName("Foo"));

    MethodDescriptor barMethod = service.getMethods().get(1);
    assertEquals("Bar", barMethod.getName());
    assertEquals(UnittestProto.BarRequest.getDescriptor(),
                 barMethod.getInputType());
    assertEquals(UnittestProto.BarResponse.getDescriptor(),
                 barMethod.getOutputType());
    assertEquals(barMethod, service.findMethodByName("Bar"));

    assertNull(service.findMethodByName("NoSuchMethod"));

    for (int i = 0; i < service.getMethods().size(); i++) {
View Full Code Here

    assertTrue(
      service.getOptions().hasExtension(UnittestCustomOptions.serviceOpt1));
    assertEquals(Long.valueOf(-9876543210L),
      service.getOptions().getExtension(UnittestCustomOptions.serviceOpt1));

    MethodDescriptor method = service.findMethodByName("Foo");
    assertNotNull(method);

    assertTrue(
      method.getOptions().hasExtension(UnittestCustomOptions.methodOpt1));
    assertEquals(UnittestCustomOptions.MethodOpt1.METHODOPT1_VAL2,
      method.getOptions().getExtension(UnittestCustomOptions.methodOpt1));
  }
View Full Code Here

    public void messageReceived(ChannelHandlerContext ctx, MessageEvent e)
        throws Exception {
      final RpcRequest request = (RpcRequest) e.getMessage();

      String methodName = request.getMethodName();
      MethodDescriptor methodDescriptor =
          service.getDescriptorForType().findMethodByName(methodName);

      if (methodDescriptor == null) {
        throw new RemoteCallException(request.getId(),
            new NoSuchMethodException(methodName));
View Full Code Here

        throws Exception {

      final RpcRequest request = (RpcRequest) e.getMessage();

      String methodName = request.getMethodName();
      MethodDescriptor methodDescriptor = service.getDescriptorForType().
          findMethodByName(methodName);

      if (methodDescriptor == null) {
        throw new RemoteCallException(request.getId(),
            new NoSuchMethodException(methodName));
View Full Code Here

    private void doRequest(RpcMessage message) {
        Service service = services.get(message.getService());
        Builder errorBuilder = RpcMessage.newBuilder().setType(MessageType.ERROR);
        boolean succeed = false;
        if (service != null) {
            MethodDescriptor method = service.getDescriptorForType()
                    .findMethodByName(message.getMethod());
            if (method != null) {
                Message request = fromByteString(service.getRequestPrototype(method),
                        message.getRequest());
                if (request != null) {
View Full Code Here

      String methodName = rpcRequest.getMethodName();
      if (verbose) {
        log("Call: protocol=" + protocol.getCanonicalName() + ", method="
            + methodName);
      }
      MethodDescriptor methodDescriptor = service.getDescriptorForType()
          .findMethodByName(methodName);
      if (methodDescriptor == null) {
        String msg = "Unknown method " + methodName + " called on "
            + protocol + " protocol.";
        LOG.warn(msg);
View Full Code Here

  }

  private Response forwardToBlockingService(Request rpcRequest,
      BlockingService blockingService) throws RpcException {
    // Get matching method
    MethodDescriptor method = getMethod(rpcRequest,
        blockingService.getDescriptorForType());

    // Create request for method
    Message request = getRequestProto(rpcRequest,
        blockingService.getRequestPrototype(method));

    // Call method
    SocketRpcController socketController = new SocketRpcController();
    try {
      Message response = blockingService.callBlockingMethod(method,
          socketController, request);
      return createRpcResponse(response, true, socketController);
    } catch (ServiceException e) {
      throw new RpcException(ErrorReason.RPC_FAILED, e.getMessage(), e);
    } catch (RuntimeException e) {
      throw new RpcException(ErrorReason.RPC_ERROR,
          "Error running method " + method.getFullName(), e);
    }
  }
View Full Code Here

  private void forwardToService(SocketRpcProtos.Request rpcRequest,
      RpcCallback<Message> callback, Service service,
      RpcController socketController) throws RpcException {
    // Get matching method
    MethodDescriptor method = getMethod(rpcRequest,
        service.getDescriptorForType());

    // Create request for method
    Message request = getRequestProto(rpcRequest,
        service.getRequestPrototype(method));

    // Call method
    try {
      service.callMethod(method, socketController, request, callback);
    } catch (RuntimeException e) {
      throw new RpcException(ErrorReason.RPC_ERROR,
          "Error running method " + method.getFullName(), e);
    }
  }
View Full Code Here

  /**
   * Get matching method.
   */
  private MethodDescriptor getMethod(SocketRpcProtos.Request rpcRequest,
      ServiceDescriptor descriptor) throws RpcException {
    MethodDescriptor method = descriptor.findMethodByName(
        rpcRequest.getMethodName());
    if (method == null) {
      throw new RpcException(
          ErrorReason.METHOD_NOT_FOUND,
          String.format("Could not find method %s in service %s",
View Full Code Here

TOP

Related Classes of com.google.protobuf.Descriptors.MethodDescriptor

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.