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_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]
With regards,
Apache Git Services