franz1981 commented on a change in pull request #2666: ARTEMIS-2336 Use zero 
copy to replicate journal/page/large message file
URL: https://github.com/apache/activemq-artemis/pull/2666#discussion_r283271485
 
 

 ##########
 File path: 
artemis-server/src/main/java/org/apache/activemq/artemis/core/protocol/core/impl/wireformat/ReplicationSyncFileMessage.java
 ##########
 @@ -150,30 +161,54 @@ public void encodeRest(final ActiveMQBuffer buffer) {
          default:
             // no-op
       }
-
       buffer.writeInt(dataSize);
-      /*
-       * sending -1 will close the file in case of a journal, but not in case 
of a largeMessage
-       * (which might receive appends)
-       */
-      if (dataSize > 0) {
-         buffer.writeBytes(byteBuffer, 0, byteBuffer.writerIndex());
-      }
 
       release();
    }
 
    @Override
-   public void release() {
-      if (byteBuffer != null) {
-         byteBuffer.release();
-         byteBuffer = null;
+   public ActiveMQBuffer encode(CoreRemotingConnection connection) {
+      if (connection != null && connection.getTransportConnection() instanceof 
NettyConnection) {
+         ActiveMQBuffer buffer;
+         int bufferSize = expectedEncodeSize();
+         if (fileId != -1 && dataSize > 0) {
+            bufferSize -= dataSize;
+         }
+         buffer = createPacket(connection, bufferSize);
+
+         encodeHeader(buffer);
+
+         encodeRest(buffer, connection);
+
+         encodeSize(buffer, expectedEncodeSize());
+
+         return fileId != -1 && dataSize > 0 ? new 
FileDelegatedChannelBufferWrapper(file, offset, dataSize, buffer) : buffer;
 
 Review comment:
   When we ask NettyConnection to write, the write happens asynchronously so 
the reading of the file/file region, while in the original version the reading 
of file was performed in the caller thread: my concern is...
   what happen to an in-flight write request (using the file) if Artemis will 
mark the file for deletion/or to be moved and will do it?
   Maybe Artemis won't do it, I'm not aware of this: I'm saying that is 
something to be taken into account...

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


With regards,
Apache Git Services

Reply via email to