Search in sources :

Example 6 with Message

use of com.google.protobuf.Message in project hbase by apache.

the class HBaseAdmin method coprocessorService.

@Override
public CoprocessorRpcChannel coprocessorService(final ServerName serverName) {
    return new SyncCoprocessorRpcChannel() {

        @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);
            }
        }
    };
}
Also used : RpcController(com.google.protobuf.RpcController) HBaseRpcController(org.apache.hadoop.hbase.ipc.HBaseRpcController) CoprocessorServiceRequest(org.apache.hadoop.hbase.shaded.protobuf.generated.ClientProtos.CoprocessorServiceRequest) Message(com.google.protobuf.Message) ServiceException(org.apache.hadoop.hbase.shaded.com.google.protobuf.ServiceException) CoprocessorServiceResponse(org.apache.hadoop.hbase.shaded.protobuf.generated.ClientProtos.CoprocessorServiceResponse)

Example 7 with Message

use of com.google.protobuf.Message in project hadoop by apache.

the class ClientNamenodeProtocolTranslatorPB method getAclStatus.

@Override
public AclStatus getAclStatus(String src) throws IOException {
    GetAclStatusRequestProto req = GetAclStatusRequestProto.newBuilder().setSrc(src).build();
    try {
        if (Client.isAsynchronousMode()) {
            rpcProxy.getAclStatus(null, req);
            final AsyncGet<Message, Exception> asyncReturnMessage = ProtobufRpcEngine.getAsyncReturnMessage();
            final AsyncGet<AclStatus, Exception> asyncGet = new AsyncGet<AclStatus, Exception>() {

                @Override
                public AclStatus get(long timeout, TimeUnit unit) throws Exception {
                    return PBHelperClient.convert((GetAclStatusResponseProto) asyncReturnMessage.get(timeout, unit));
                }

                @Override
                public boolean isDone() {
                    return asyncReturnMessage.isDone();
                }
            };
            AsyncCallHandler.setLowerLayerAsyncReturn(asyncGet);
            return null;
        } else {
            return PBHelperClient.convert(rpcProxy.getAclStatus(null, req));
        }
    } catch (ServiceException e) {
        throw ProtobufHelper.getRemoteException(e);
    }
}
Also used : Message(com.google.protobuf.Message) AclStatus(org.apache.hadoop.fs.permission.AclStatus) ServiceException(com.google.protobuf.ServiceException) GetAclStatusRequestProto(org.apache.hadoop.hdfs.protocol.proto.AclProtos.GetAclStatusRequestProto) AsyncGet(org.apache.hadoop.util.concurrent.AsyncGet) TimeUnit(java.util.concurrent.TimeUnit) IOException(java.io.IOException) ServiceException(com.google.protobuf.ServiceException)

Example 8 with Message

use of com.google.protobuf.Message in project hadoop by apache.

the class TestObjectWritableProtos method doTest.

/**
   * Write a protobuf to a buffer 'numProtos' times, and then
   * read them back, making sure all data comes through correctly.
   */
private void doTest(int numProtos) throws IOException {
    Configuration conf = new Configuration();
    DataOutputBuffer out = new DataOutputBuffer();
    // Write numProtos protobufs to the buffer
    Message[] sent = new Message[numProtos];
    for (int i = 0; i < numProtos; i++) {
        // Construct a test protocol buffer using one of the
        // protos that ships with the protobuf library
        Message testProto = DescriptorProtos.EnumValueDescriptorProto.newBuilder().setName("test" + i).setNumber(i).build();
        ObjectWritable.writeObject(out, testProto, DescriptorProtos.EnumValueDescriptorProto.class, conf);
        sent[i] = testProto;
    }
    // Read back the data
    DataInputBuffer in = new DataInputBuffer();
    in.reset(out.getData(), out.getLength());
    for (int i = 0; i < numProtos; i++) {
        Message received = (Message) ObjectWritable.readObject(in, conf);
        assertEquals(sent[i], received);
    }
}
Also used : Configuration(org.apache.hadoop.conf.Configuration) Message(com.google.protobuf.Message) DescriptorProtos(com.google.protobuf.DescriptorProtos)

Example 9 with Message

use of com.google.protobuf.Message in project hadoop by apache.

the class TestRpcWritable method testProtobufWrapper.

@Test
public void testProtobufWrapper() throws IOException {
    ByteArrayOutputStream baos = new ByteArrayOutputStream();
    message1.writeDelimitedTo(baos);
    ByteBuffer bb = ByteBuffer.wrap(baos.toByteArray());
    Message actual = RpcWritable.wrap(EchoRequestProto.getDefaultInstance()).readFrom(bb);
    Assert.assertEquals(message1, actual);
    Assert.assertEquals(0, bb.remaining());
}
Also used : Message(com.google.protobuf.Message) ByteArrayOutputStream(java.io.ByteArrayOutputStream) ByteBuffer(java.nio.ByteBuffer) Test(org.junit.Test)

Example 10 with Message

use of com.google.protobuf.Message in project core-java by SpineEventEngine.

the class TypeConverterShould method map_BoolValue_to_boolean.

@Test
public void map_BoolValue_to_boolean() {
    final boolean rowValue = true;
    final Message value = BoolValue.newBuilder().setValue(rowValue).build();
    checkMapping(rowValue, value);
}
Also used : Message(com.google.protobuf.Message) Test(org.junit.Test)

Aggregations

Message (com.google.protobuf.Message)266 Test (org.junit.Test)84 Any (com.google.protobuf.Any)30 ByteString (com.google.protobuf.ByteString)17 IOException (java.io.IOException)16 ArrayList (java.util.ArrayList)15 Command (io.spine.core.Command)14 DynamicMessage (com.google.protobuf.DynamicMessage)13 FieldDescriptor (com.google.protobuf.Descriptors.FieldDescriptor)10 EntityRecord (io.spine.server.entity.EntityRecord)10 Test (org.junit.jupiter.api.Test)9 HeronTuples (com.twitter.heron.proto.system.HeronTuples)8 Event (io.spine.core.Event)8 InvocationTargetException (java.lang.reflect.InvocationTargetException)8 Method (java.lang.reflect.Method)8 Event (io.spine.base.Event)7 MockHttpInputMessage (org.springframework.http.MockHttpInputMessage)7 MockHttpOutputMessage (org.springframework.http.MockHttpOutputMessage)7 Descriptor (com.google.protobuf.Descriptors.Descriptor)6 Builder (com.google.protobuf.Message.Builder)5