szetszwo commented on code in PR #748:
URL: https://github.com/apache/ratis/pull/748#discussion_r998094417


##########
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:
   They need to be reset in a `synchronized` block so that we should reset them 
here.



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

Reply via email to