[ 
https://issues.apache.org/jira/browse/ARTEMIS-2336?focusedWorklogId=243175&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-243175
 ]

ASF GitHub Bot logged work on ARTEMIS-2336:
-------------------------------------------

                Author: ASF GitHub Bot
            Created on: 16/May/19 08:13
            Start Date: 16/May/19 08:13
    Worklog Time Spent: 10m 
      Work Description: franz1981 commented on 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_r284580080
 
 

 ##########
 File path: 
artemis-server/src/main/java/org/apache/activemq/artemis/core/protocol/core/impl/wireformat/ReplicationSyncFileMessage.java
 ##########
 @@ -150,30 +182,49 @@ 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 ActiveMQBuffer encode(CoreRemotingConnection connection) {
+      if (fileId != -1 && dataSize > 0) {
+         ActiveMQBuffer buffer;
+         int bufferSize = expectedEncodeSize();
+         int encodedSize = bufferSize;
+         boolean isNetty = false;
+         if (connection != null && connection.getTransportConnection() 
instanceof NettyConnection) {
+            bufferSize -= dataSize;
+            isNetty = true;
+         }
+         buffer = createPacket(connection, bufferSize);
+         encodeHeader(buffer);
+         encodeRest(buffer, connection);
+         if (!isNetty) {
+            readFile(buffer.toByteBuffer(buffer.writerIndex(), 
buffer.writableBytes()));
+            buffer.writerIndex(buffer.capacity());
+         }
+         encodeSize(buffer, encodedSize);
+         return buffer;
+      } else {
+         return super.encode(connection);
+      }
    }
 
    @Override
    public void release() {
-      if (byteBuffer != null) {
-         byteBuffer.release();
-         byteBuffer = null;
+      if (fileChannel != null) {
+         try {
+            fileChannel.close();
+         } catch (IOException e) {
+            e.printStackTrace();
 
 Review comment:
   Better use a proper logger 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.
 
For queries about this service, please contact Infrastructure at:
[email protected]


Issue Time Tracking
-------------------

    Worklog Id:     (was: 243175)
    Time Spent: 5h  (was: 4h 50m)

> Use zero copy to replicate journal/page/large message file
> ----------------------------------------------------------
>
>                 Key: ARTEMIS-2336
>                 URL: https://issues.apache.org/jira/browse/ARTEMIS-2336
>             Project: ActiveMQ Artemis
>          Issue Type: Improvement
>          Components: Broker
>            Reporter: yangwei
>            Priority: Major
>          Time Spent: 5h
>  Remaining Estimate: 0h
>
> Use sendfile to replicate files during backup sever bootstrap.



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)

Reply via email to