Package com.google.protobuf

Examples of com.google.protobuf.Message$Builder


      if (methodDescriptor == null) {
        throw new RemoteCallException(request.getId(),
            new NoSuchMethodException(methodName));
      }
      Message paramProto = null;
      if (request.hasRequestMessage()) {
        try {
          paramProto = service.getRequestPrototype(methodDescriptor)
              .newBuilderForType().mergeFrom(request.getRequestMessage()).
                  build();

        } catch (Throwable t) {
          throw new RemoteCallException(request.getId(), methodDescriptor, t);
        }
      }
      Message returnValue;
      RpcController controller = new NettyRpcController();

      try {
        returnValue = service.callBlockingMethod(methodDescriptor,
            controller, paramProto);
      } catch (Throwable t) {
        throw new RemoteCallException(request.getId(), methodDescriptor, t);
      }

      RpcResponse.Builder builder =
          RpcResponse.newBuilder().setId(request.getId());

      if (returnValue != null) {
        builder.setResponseMessage(returnValue.toByteString());
      }

      if (controller.failed()) {
        builder.setErrorMessage(controller.errorText());
      }
View Full Code Here


      if (methodDescriptor == null) {
        throw new RemoteCallException(request.getId(),
            new NoSuchMethodException(methodName));
      }

      Message paramProto = null;
      if (request.hasRequestMessage()) {
        try {
          paramProto = service.getRequestPrototype(methodDescriptor)
                  .newBuilderForType().mergeFrom(request.getRequestMessage()).
                  build();
View Full Code Here

    }
  }

  @Override
  protected Object getField(Object record, String name, int pos, Object state) {
    Message m = (Message)record;
    FieldDescriptor f = ((FieldDescriptor[])state)[pos];
    switch (f.getType()) {
    case MESSAGE:
      if (!f.isRepeated() && !m.hasField(f))
        return null;
    default:
      return m.getField(f);
    }
  }   
View Full Code Here

  public final void testWriteLoadProtoFromFile() throws IOException {   
    File file = new File(TEST_PATH+"/file.bin");
    file.createNewFile();
    FileUtil.writeProto(file, proto);
   
    Message defaultInstance = TestMessageProto.getDefaultInstance();
    TestMessageProto message = (TestMessageProto)
      FileUtil.loadProto(new File(TEST_PATH+"/file.bin"), defaultInstance);
   
    assertEquals(proto, message);
  }
View Full Code Here

    FileOutputStream out = new FileOutputStream(new File(TEST_PATH+"/file.bin"));   
    FileUtil.writeProto(out, proto);
   
   
    FileInputStream in = new FileInputStream(new File(TEST_PATH+"/file.bin"));
    Message defaultInstance = TestMessageProto.getDefaultInstance();
    TestMessageProto message = (TestMessageProto)
      FileUtil.loadProto(in, defaultInstance);
   
    assertEquals(proto, message);
  }
View Full Code Here

    Path path = new Path(TEST_PATH+"/file.bin");
    Configuration conf = new Configuration();
    FileSystem localFS = FileSystem.getLocal(conf);
    FileUtil.writeProto(localFS, path, proto);
   
    Message defaultInstance = TestMessageProto.getDefaultInstance();
    TestMessageProto message = (TestMessageProto)
      FileUtil.loadProto(localFS, new Path(TEST_PATH+"/file.bin"),
          defaultInstance);
   
    assertEquals(proto, message);
View Full Code Here

        Empty empty = Empty.getDefaultInstance();
        ChannelBuffer buf = (ChannelBuffer) encoder.encode(null, null, empty);

        ProtobufDecoder decoder = new ProtobufDecoder();
        decoder.addMessageType(Empty.getDefaultInstance());
        Message message = (Message) decoder.decode(null, null, buf);
        assertEquals(empty, message);
    }
View Full Code Here

                .build();
        ChannelBuffer buf = (ChannelBuffer) encoder.encode(null, null, query);

        ProtobufDecoder decoder = new ProtobufDecoder();
        decoder.addMessageType(Query.getDefaultInstance());
        Message message = (Message) decoder.decode(null, null, buf);
        assertEquals(query, message);
    }
View Full Code Here

        buf2.writeBytes(buf);

        buf2.readInt();
        ProtobufDecoder decoder = new ProtobufDecoder();
        decoder.addMessageType(Query.getDefaultInstance());
        Message message = (Message) decoder.decode(null, null, buf2);
        assertEquals(query, message);
    }
View Full Code Here

            doRequest(message);
        } else if (message.getType() == MessageType.RESPONSE) {
            Outstanding o = outstandings.remove(message.getId());
            // System.err.println("messageReceived " + this);
            if (o != null) {
                Message resp = fromByteString(o.responsePrototype, message.getResponse());
                o.done.run(resp);
            } else {
                System.err.println("Unknown id " + message.getId());
            }
        }
View Full Code Here

TOP

Related Classes of com.google.protobuf.Message$Builder

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.