runzhiwang commented on a change in pull request #213:
URL: https://github.com/apache/incubator-ratis/pull/213#discussion_r502097596
##########
File path:
ratis-netty/src/main/java/org/apache/ratis/netty/server/NettyServerStreamRpc.java
##########
@@ -51,27 +57,52 @@
private RandomAccessFile stream;
private FileChannel fileChannel;
private File file = new File("client-data-stream");
+ private List<DataStreamClientImpl> clients = new ArrayList<>();
+ private List<DataStreamOutput> streams = new ArrayList<>();
Review comment:
@szetszwo Could you help explain this ? If with the implementation of
this patch, streamId always be one, it's weird.
In my understanding, each request has a unique streamId, and it's similar to
[DataStreamClientImpl](https://github.com/apache/incubator-ratis/blob/master/ratis-client/src/main/java/org/apache/ratis/client/impl/DataStreamClientImpl.java).
I think we can change the patch by following code:
`private Map<Long, List<DataStreamOutput>> streamMap = new ...;`
```
public void channelRead(ChannelHandlerContext ctx, Object msg) {
...
streamMap.computeIfAbsent(streamId, new ArrayList<>());
for (DataStreamClientImpl client : clients) {
streamMap.get(streamId).add(client.stream());
}
streams.computeIfAbsent(streamId, id -> getDataStreamFuture(buf,
released))
.thenAccept(stream -> writeTo(buf, streamMap.get(streamId),
stream, released.get()))
.thenAccept(dummy -> sendReply(req, ctx));
}
```
```
private void writeTo(ByteBuf buf, List<DataStreamOutput> streamOutputList,
DataStream stream, boolean released) {
...
// forward requests to other stream servers.
for (DataStreamOutput streamOutput : streamOutputList) {
streamOutput.streamAsync(buf.nioBuffer());
}
...
}
```
And one more question, when stream between server, should we use the
streamId got from client->server ?
----------------------------------------------------------------
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:
[email protected]