You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@ratis.apache.org by GitBox <gi...@apache.org> on 2022/10/18 10:37:18 UTC

[GitHub] [ratis] lokeshj1703 commented on a diff in pull request #748: RATIS-1157. Buffer packets when the size of packets are too small.

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: issues-unsubscribe@ratis.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org