lokeshj1703 commented on code in PR #748:
URL: https://github.com/apache/ratis/pull/748#discussion_r997803444
##########
ratis-netty/src/main/java/org/apache/ratis/netty/client/NettyClientStreamRpc.java:
##########
@@ -390,7 +442,15 @@ public CompletableFuture<DataStreamReply>
streamAsync(DataStreamRequest request)
@Override
public void close() {
- connection.close();
+ final boolean flush = outstandingRequests.shouldFlush(true, 0,
SizeInBytes.ZERO);
Review Comment:
Do we need the shouldFlush call or the flush variable here?
##########
ratis-netty/src/main/java/org/apache/ratis/netty/client/NettyClientStreamRpc.java:
##########
@@ -238,16 +246,48 @@ public String toString() {
}
}
+ class OutstandingRequests {
+ private int count;
+ private long bytes;
+
+ synchronized boolean write(DataStreamRequest request) {
+ count++;
+ bytes += request.getDataLength();
+ final List<WriteOption> options = request.getWriteOptionList();
+ final boolean isClose = options.contains(StandardWriteOption.CLOSE);
+ final boolean isFlush = options.contains(StandardWriteOption.FLUSH);
+ final boolean flush = shouldFlush(isClose || isFlush,
flushRequestCountMin, flushRequestBytesMin);
+ LOG.debug("Stream{} outstanding: count={}, bytes={}, options={}, flush?
{}",
+ request.getStreamId(), count, bytes, options, flush);
+ return flush;
+ }
+
+ synchronized boolean shouldFlush(boolean force, int countMin, SizeInBytes
bytesMin) {
+ if (force || count >= countMin || bytes >= bytesMin.getSize()) {
+ count = 0;
+ bytes = 0;
Review Comment:
Should we reset this state in a different function like flush?
--
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.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]