[
https://issues.apache.org/jira/browse/ARTEMIS-2336?focusedWorklogId=243174&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-243174
]
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_r284586047
##########
File path:
artemis-core-client/src/main/java/org/apache/activemq/artemis/core/remoting/impl/netty/NettyConnection.java
##########
@@ -385,6 +402,34 @@ public final void write(ActiveMQBuffer buffer,
}
}
+ @Override
+ public void write(ActiveMQBuffer buffer,
+ RandomAccessFile raf,
+ FileChannel fileChannel,
+ long offset,
+ int dataSize,
+ boolean closeChannel) {
+ final int readableBytes = buffer.readableBytes() + dataSize;
+ if (logger.isDebugEnabled()) {
+ final int remainingBytes = this.writeBufferHighWaterMark -
readableBytes;
+ if (remainingBytes < 0) {
+ logger.debug("a write request is exceeding by " +
(-remainingBytes) + " bytes the writeBufferHighWaterMark size [ " +
this.writeBufferHighWaterMark + " ] : consider to set it at least of " +
readableBytes + " bytes");
+ }
+ }
+
+ //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;
+ final ByteBuf bytes = buffer.byteBuf();
+ assert readableBytes >= 0;
+ channel.write(bytes);
+ channel.writeAndFlush(getFileObject(raf, fileChannel, offset,
dataSize)).addListener(future -> {
+ if ((closeChannel || !future.isSuccess()) && fileChannel.isOpen()) {
Review comment:
I've proposed a different solution on caller side to make this more
efficient and effective
----------------------------------------------------------------
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: 243174)
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)