You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@ratis.apache.org by GitBox <gi...@apache.org> on 2020/11/10 04:21:06 UTC

[GitHub] [incubator-ratis] amaliujia commented on a change in pull request #264: RATIS-1140. Do not create DataStreamOutput for non-primary server

amaliujia commented on a change in pull request #264:
URL: https://github.com/apache/incubator-ratis/pull/264#discussion_r520276919



##########
File path: ratis-netty/src/main/java/org/apache/ratis/netty/server/NettyServerStreamRpc.java
##########
@@ -247,13 +248,13 @@ public void addRaftPeers(Collection<RaftPeer> newPeers) {
     proxies.addPeers(newPeers);
   }
 
-  private StreamInfo newStreamInfo(ByteBuf buf) {
+  private StreamInfo newStreamInfo(ByteBuf buf, boolean isPrimary) {
     try {
       final RaftClientRequest request = ClientProtoUtils.toRaftClientRequest(
           RaftClientRequestProto.parseFrom(buf.nioBuffer()));
       final StateMachine stateMachine = server.getStateMachine(request.getRaftGroupId());
       return new StreamInfo(request, stateMachine.data().stream(request),
-          proxies.getDataStreamOutput(request));
+          isPrimary ? proxies.getDataStreamOutput(request) : Collections.EMPTY_LIST);

Review comment:
       Ack. Didn't notice that the RaftClientRequest in header has the server id.
   
   Now this PR becomes very simple again :)




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org