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/03/22 12:02:34 UTC

[GitHub] [ratis] szetszwo commented on a change in pull request #626: RATIS-1556. Support reference-counted buffer in StateMachine.DataChannel

szetszwo commented on a change in pull request #626:
URL: https://github.com/apache/ratis/pull/626#discussion_r832091581



##########
File path: ratis-netty/src/main/java/org/apache/ratis/netty/server/DataStreamManagement.java
##########
@@ -294,8 +293,9 @@ static long writeTo(ByteBuf buf, WriteOption[] options, DataStream stream) {
     final DataChannel channel = stream.getDataChannel();
     long byteWritten = 0;
     for (ByteBuffer buffer : buf.nioBuffers()) {
+      final ReferenceCountedObject<ByteBuffer> wrapped = ReferenceCountedObject.wrap(buffer, buf::retain, buf::release);

Review comment:
       @lokeshj1703 , thanks for reviewing this.
   
   Ratis would have buf.retain() called at least once before passing it to StateMachine via write(wrapped).  After write(wrapped), Ratis will release it.  StateMachine implementation may choose to further retain it.  In such case, the buf will be released until both Ratis and the StateMachine have released it.  If StateMachine don't retain it, the buf will be released by Ratis as usual.




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