szetszwo commented on a change in pull request #250:
URL: https://github.com/apache/incubator-ratis/pull/250#discussion_r517237954
##########
File path:
ratis-netty/src/main/java/org/apache/ratis/netty/server/NettyServerStreamRpc.java
##########
@@ -318,21 +318,21 @@ private void read(ChannelHandlerContext ctx,
DataStreamRequestByteBuf request) {
}
} else {
info = streams.get(key);
- localWrite = info.getStream().thenApply(stream -> writeTo(buf, stream));
+ localWrite = info.getPrevious().get()
Review comment:
Good catch. The write should also wait for the previous.
##########
File path:
ratis-netty/src/main/java/org/apache/ratis/netty/server/NettyServerStreamRpc.java
##########
@@ -318,21 +318,21 @@ private void read(ChannelHandlerContext ctx,
DataStreamRequestByteBuf request) {
}
} else {
info = streams.get(key);
- localWrite = info.getStream().thenApply(stream -> writeTo(buf, stream));
+ localWrite = info.getPrevious().get()
+ .thenCombineAsync(info.getStream(), (u, stream) -> writeTo(buf,
stream), executorService);
for (DataStreamOutput out : info.getDataStreamOutputs()) {
remoteWrites.add(out.writeAsync(request.slice().nioBuffer()));
Review comment:
We should do the same for the remote writes.
```
final CompletableFuture<?> previous = info.getPrevious().get();
localWrite = previous.thenComposeAsync(v -> info.getStream())
.thenApplyAsync(stream -> writeTo(buf, stream), executorService);
for (DataStreamOutput out : info.getDataStreamOutputs()) {
remoteWrites.add(previous.thenComposeAsync(v ->
out.writeAsync(request.slice().nioBuffer()), executorService));
}
```
##########
File path:
ratis-netty/src/main/java/org/apache/ratis/netty/server/NettyServerStreamRpc.java
##########
@@ -318,21 +318,21 @@ private void read(ChannelHandlerContext ctx,
DataStreamRequestByteBuf request) {
}
} else {
info = streams.get(key);
- localWrite = info.getStream().thenApply(stream -> writeTo(buf, stream));
+ localWrite = info.getPrevious().get()
+ .thenCombineAsync(info.getStream(), (u, stream) -> writeTo(buf,
stream), executorService);
Review comment:
We should use thenComposeAsync; see the comment below.
----------------------------------------------------------------
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]