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 01:20:36 UTC

[GitHub] [incubator-ratis] szetszwo commented on a change in pull request #264: RATIS-1140. Add primary peer id to Raft proto and only create channels with peer for primary servers

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



##########
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:
       It is a good idea.   We may use
   ```
         final List<DataStreamOutputRpc> outs = server.getId().equals(request.getServerId())?  
             proxies.getDataStreamOutput(request): Collections.emptyList();
         return new StreamInfo(request, stateMachine.data().stream(request), outs);
   ```
   Note that request is RaftClientRequest.
   




----------------------------------------------------------------
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