Tag: protocol buffers

Protobuf RPC在Hadoop 2.2.0单节点服务器上不可用?

我正在尝试按照本教程在我安装的本地单节点集群上运行hadoop 2.2.0 mapreduce作业: http : //codesfusion.blogspot.co.at/2013/10/setup-hadoop-2x-220-on- ubuntu.html?m = 1的 虽然在服务器端引发了以下exception: org.apache.hadoop.ipc.RpcNoSuchProtocolException: Unknown protocol: org.apache.hadoop.yarn.api.ApplicationClientProtocolPB at org.apache.hadoop.ipc.ProtobufRpcEngine$Server$ProtoBufRpcInvoker.getProtocolImpl(ProtobufRpcEngine.java:527) at org.apache.hadoop.ipc.ProtobufRpcEngine$Server$ProtoBufRpcInvoker.call(ProtobufRpcEngine.java:566) at org.apache.hadoop.ipc.RPC$Server.call(RPC.java:928) at org.apache.hadoop.ipc.Server$Handler$1.run(Server.java:2048) at org.apache.hadoop.ipc.Server$Handler$1.run(Server.java:2044) at java.security.AccessController.doPrivileged(Native Method) at javax.security.auth.Subject.doAs(Subject.java:415) at org.apache.hadoop.security.UserGroupInformation.doAs(UserGroupInformation.java:1491) at org.apache.hadoop.ipc.Server$Handler.run(Server.java:2042) 有没有办法让我配置Protobuf RPC在服务器端可用? 我需要hadoop本机库吗? 或者我可以在客户端以某种方式切换到Writables / Avro RPC吗?

在使用Protocol Buffers的项目中使用Proguard有什么特点?

我有一个使用Google Protocol Buffers的项目。 一旦我尝试使用ProGuard对其进行模糊处理,似乎protobuf会导致问题。 我将自己的所有类打包到mybuildedclasses.jar 。 Google代码打包到protbuf.jar mybuildedclasses.jar protobuf.jar other external jars 之后我试图混淆mybuildedclasses.jar 。 配置文件与此类似。 最终所有的jar子都装在另一个胖jar子里面。 我运行程序,一旦尝试发送消息,就会打印出这种exception。 Caused by: java.lang.RuntimeException: Generated message class “org.mypackage.messages.Control$MessageControlHandCard$Builder” missing method “getCardId”. at com.google.protobuf.GeneratedMessage.getMethodOrDie(GeneratedMessage. java:1366) at com.google.protobuf.GeneratedMessage.access$1(GeneratedMessage.java:1 361) at com.google.protobuf.GeneratedMessage$FieldAccessorTable$SingularField Accessor.(GeneratedMessage.java:1502) at com.google.protobuf.GeneratedMessage$FieldAccessorTable.(Genera tedMessage.java:1441) at org.mypackage.Control$1.assignDescriptors(SourceFile:32 20) at com.google.protobuf.Descriptors$FileDescriptor.internalBuildGenerated FileFrom(Descriptors.java:300) at org.evogame.common.messages.Control.(SourceFile:3278) … 60 more Caused by: java.lang.NoSuchMethodException: org.evogame.common.messages.Control$ MessageControlHandCard$Builder.getCardId() […]

用于gRPC / protobuf的Java IDL(Protocl缓冲区)

是否可以使用Java定义Protocol Buffers? 那不是 service Greeter { rpc SayHello (HelloRequest) returns (HelloReply) {} } 我想拥有 public interface Greeter { @Grpc HelloReply sayHello (HelloRequest req); } @GrpcMessage() public class HelloReply{ @GrpcField(1) string name; } 这是注释,就像我的POJO上的Hibernate / JPA,而不是生成的代码堆。 我只能找到Protocol Buffers Dynamic Sc​​hema https://github.com/os72/protobuf-dynamic

如何从Spring WebClient的ClientResponse中获取最佳字节数组?

我正在尝试从Spring 5(5.0.0.RC2)开始使用反应式编程的代码库中的新WebClient ,并且我已成功将JSON响应从端点映射到我的应用程序中的DTO,这非常好用: WebClient client = WebClient.create(baseURI); Mono dto = client.get() .uri(uri) .accept(MediaType.APPLICATION_JSON) .exchange() .flatMap(response -> response.bodyToMono(DTO.class)); 但是,现在我正在尝试使用协议缓冲区(二进制数据作为application/octet-stream )的端点的响应体,所以我想从响应中获取原始字节,然后我将映射我自己的一个对象。 我使用Google Guava的Bytes让它像这样工作: Mono bytes = client.get() .uri(uri) .accept(MediaType.APPLICATION_OCTET_STREAM) .exchange() .flatMapMany(response -> response.body(BodyExtractors.toDataBuffers())) .map(dataBuffer -> { ByteBuffer byteBuffer = dataBuffer.asByteBuffer(); byte[] byteArray = new byte[byteBuffer.remaining()]; byteBuffer.get(byteArray, 0, bytes.length); return byteArray; }) .reduce(Bytes::concat) 这有效,但有更简单,更优雅的方式来获取这些字节吗?

协议缓冲区中的inheritance

如何处理Google Protocol Buffers 3.0中的inheritance? Java等效代码: public class Bar { String name; } public class Foo extends Bar { String id; } 什么是Proto等效代码? message Bar { string name = 1; } message Foo { string id = 2; }

如何使用Protocol Buffers对Map 进行编码?

我正在尝试使用Protocol Buffers进行消息序列化。 我的消息格式应该包含Map 条目……但是如何编写.proto定义? 据我所知,Protocol Buffers没有内置Map类型。 我可以使用重复字段来模拟它。 但我遇到的最大问题是,您需要定义所有类型。 我希望我的信息灵活,所以我不能指定类型。 有任何想法吗?

处理protobuffers中的空值

我正在研究从数据库中获取数据并构造protobuff消息的东西。 鉴于可以从数据库中为某些字段提取空值,我将在尝试构建protobuff消息时获得Null指针exception。 从线程http://code.google.com/p/protobuf/issues/detail?id=57中的protobuffs中不支持知道null,我想知道处理NPE的唯一其他方法是抛出是将手动检查插入到与原型相对应的java文件中,如下所示! message ProtoPerson{ optional string firstName = 1; optional string lastName = 2; optional string address1 = 3; } ProtoPerson.Builder builder = ProtoPerson.Builder.newBuilder(); if (p.getFirstName() != null) builder.setFirstName(p.getFirstName()); if (p.getLastName() != null) builder.setLastName(p.getLastName()); if (p.getAddress1() != null) builder.setAddress1(p.getAddress1()); … 那么有人可以澄清是否有任何其他可能有效的方法来处理protobuff构造期间的空值?

用于处理protobuf的Eclipse插件

协议缓冲区 (protobuf)是一种以高效且可扩展的格式编码结构化数据的方法。 有Netbeans的插件 ,但我找不到Eclipse的插件 。 它存在吗? 如果是,请分享链接。 谢谢。

如何在Java代码和.proto文件之间共享枚举值

我有一个class级,我希望protobuf。 在该类中,其中一个字段是一个枚举(在它自己的类中)。 我可以避免在.proto文件中定义相同的枚举值吗? 或者我是否必须手动确保java代码中的枚举定义与.proto文件中的枚举定义相同? java代码: public enum Location { UNDEF(0),HOME(1), WORK(2); … } .proto文件对应的代码: message Address{ enum location { UNDEF = 0; HOME = 1; WORK = 2; } optional location addressLocation; … }

Gradle无法检测osdetector插件

我在使用gradle的Java GRPC项目中使用OpenSSL。 我阅读了文档 ,其中提到我们应该按照此链接中的说明进行安全设置。 我在build.gradle文件中包含了osdetector插件。 但是当我构建项目时,gradle无法解析osdetector插件并抛出错误 > Failed to apply plugin [id ‘com.google.protobuf’] > Plugin with id ‘osdetector’ not found. 我的gradle文件如下: def neo4jVersion = “2.3.3” apply plugin: ‘application’ apply plugin: ‘java’ apply plugin: ‘com.google.protobuf’ apply plugin: ‘idea’ apply plugin: ‘com.google.osdetector’ buildscript { repositories { mavenCentral() } dependencies { classpath ‘com.google.protobuf:protobuf-gradle-plugin:0.7.3’ classpath ‘com.google.gradle:osdetector-gradle-plugin:1.4.0’ } } protobuf […]