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

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

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

 ##########
 File path: 
artemis-core-client/src/main/java/org/apache/activemq/artemis/core/remoting/impl/netty/NettyConnection.java
 ##########
 @@ -345,21 +351,41 @@ private boolean canWrite(final int requiredCapacity) {
       return canWrite;
    }
 
+   private Object getFileObject(FileDelegatedChannelBufferWrapper fileBuffer) {
+      if (channel.pipeline().get(SslHandler.class) == null) {
+         return new DefaultFileRegion(fileBuffer.getFile(), 
fileBuffer.getOffset(), fileBuffer.getDataSize());
+      } else {
+         try {
+            RandomAccessFile raf = new RandomAccessFile(fileBuffer.getFile(), 
"r");
+            return new ChunkedFile(raf, fileBuffer.getOffset(), 
fileBuffer.getDataSize(), 8192);
+         } catch (IOException e) {
+            throw new RuntimeException(e);
+         }
+      }
+   }
+
    @Override
    public final void write(ActiveMQBuffer buffer,
                            final boolean flush,
                            final boolean batched,
                            final ChannelFutureListener futureListener) {
-      final int readableBytes = buffer.readableBytes();
+      //no need to lock because the Netty's channel is thread-safe
+      //and the order of write is ensured by the order of the write calls
+      final Channel channel = this.channel;
+
+      int readableBytes = buffer.readableBytes();
+      Object fileObject = null;
+      if (buffer instanceof FileDelegatedChannelBufferWrapper) {
+         readableBytes += 
((FileDelegatedChannelBufferWrapper)buffer).getDataSize();
+         fileObject = getFileObject((FileDelegatedChannelBufferWrapper)buffer);
 
 Review comment:
   Good point. I'll work on it:)
 
----------------------------------------------------------------
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: 240962)
    Time Spent: 2.5h  (was: 2h 20m)

> 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: 2.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