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);
}
}
};
}
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);
}
}
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);
}
}
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());
}
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);
}
Aggregations