Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Counter example not supported grpc #451

Closed
shibd opened this issue May 21, 2020 · 3 comments
Closed

Counter example not supported grpc #451

shibd opened this issue May 21, 2020 · 3 comments

Comments

@shibd
Copy link
Contributor

shibd commented May 21, 2020

Describe the bug

我尝试在Counter中增加grpc的实现,启动报错。我在counter的resource文件中输出了raft.desc。经过排查,发现这个类ProtobufMsgFactory只能加载最新的raft.desc,如果我在应用中声明了这个文件,那么jraft-core包中的文件将加载不到。

Exception in thread "main" java.lang.NullPointerException: null default instance: com.alipay.sofa.jraft.rpc.RpcRequests$AppendEntriesRequest
	at com.alipay.sofa.jraft.util.Requires.requireNonNull(Requires.java:55)
	at com.alipay.sofa.jraft.rpc.impl.GrpcServer.registerProcessor(GrpcServer.java:94)
	at com.alipay.sofa.jraft.rpc.RaftRpcServerFactory.addRaftRequestProcessors(RaftRpcServerFactory.java:101)
	at com.alipay.sofa.jraft.rpc.RaftRpcServerFactory.createRaftRpcServer(RaftRpcServerFactory.java:75)
	at com.alipay.sofa.jraft.rpc.RaftRpcServerFactory.createRaftRpcServer(RaftRpcServerFactory.java:61)
	at com.alipay.sofa.jraft.example.counter.CounterServer.<init>(CounterServer.java:53)
	at com.alipay.sofa.jraft.example.counter.CounterServer.main(CounterServer.java:136)

Expected behavior

ProtobufMsgFactory应该要能加载*.desc的文件

Actual behavior

ProtobufMsgFactory 只能加载raft.desc的文件

Minimal yet complete reproducer code (or GitHub URL to code)

参见:shibd#3

Environment

  • SOFAJRaft version: master
  • JVM version (e.g. java -version): 1.8
  • OS version (e.g. uname -a): mac os
  • Maven version:
  • IDE version:
@sofastack-bot
Copy link

sofastack-bot bot commented May 21, 2020

Hi @shibd, we detect non-English characters in the issue. This comment is an auto translation by @sofastack-robot to help other users to understand this issue.

We encourage you to describe your issue in English which is more friendly to other users.

Describe the bug I tried to add the implementation of grpc in Counter and started reporting errors. I output raft.desc in the counter's resource file. After investigation, it was found that this class ProtobufMsgFactory can only load the latest raft.desc. If I declare this file in the application, the files in the jraft-core package will not be loaded. `Exception in thread&quot; main &quot;java.lang.NullPointerException: null default instance: com.alipay.sofa.jraft.rpc.RpcRequests $ AppendEntriesRequest at com.alipay.sofa.jraft.util.Requires.requireNonNull (Requires.java : 55) at com.alipay.sofa.jraft.rpc.impl.GrpcServer.registerProcessor (GrpcServer.java:94) at com.alipay.sofa.jraft.rpc.RaftRpcServerFactory.addRaftRequestProcessors (RaftRpcServerFactory.java:101) at com. alipay.sofa.jraft.rpc.RaftRpcServerFactory.createRaftRpcServer (RaftRpcServerFactory.java:75) at com.alipay.sofa.jraft.rpc.RaftRpcServerFactory.createRaftRpcServer (RaftRpcServerFactory.java:61) at com.alipay.sofa.jraft.example. counter.CounterServer. <init> (CounterServer.java:53) at com.alipay.sofa.jraft.example.counter.CounterServer.main (CounterServer.java:136) ### Expected behavior ProtobufMsgFactoryshould be able to load* .desc的 文件 ### Actual behavior ProtobufMsgFactory can only load raft.descfiles ### Minimal yet complete reproducer code (or GitHub URL to code) See: https://github.com/shibd/sofa-jraft / pull / 2 / files ### Environment-SOFAJRaft version: master-JVM version (egjava -version): 1.8-OS version (eg uname -a`): mac os-Maven version:-IDE version:

@fengjiachun
Copy link
Contributor

jraft-core之外的不应该依靠 ProtobufMsgFactory 来加载,
参考如下方式:
两步:

  1. com.alipay.sofa.jraft.rpc.impl.GrpcRaftRpcFactory#registerProtobufSerializer 注册 request 和 response proto
  2. com.alipay.sofa.jraft.rpc.impl.MarshallerHelper#registerRespInstance 注册 request 和response 的映射关系

@shibd
Copy link
Contributor Author

shibd commented May 21, 2020

jraft-core之外的不应该依靠 ProtobufMsgFactory 来加载,
参考如下方式:
两步:

  1. com.alipay.sofa.jraft.rpc.impl.GrpcRaftRpcFactory#registerProtobufSerializer 注册 request 和 response proto
  2. com.alipay.sofa.jraft.rpc.impl.MarshallerHelper#registerRespInstance 注册 request 和response 的映射关系

好的,谢谢。用这个后没问题了,跑通了。shibd#3

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants