[ https://issues.apache.org/jira/browse/ARTEMIS-2336?focusedWorklogId=243613&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-243613 ]
ASF GitHub Bot logged work on ARTEMIS-2336: ------------------------------------------- Author: ASF GitHub Bot Created on: 16/May/19 20:33 Start Date: 16/May/19 20:33 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_r284573830 ########## File path: artemis-core-client/src/main/java/org/apache/activemq/artemis/core/protocol/core/impl/ChannelImpl.java ########## @@ -274,67 +276,103 @@ private void waitForFailOver(String timeoutMsg) { } } - // This must never called by more than one thread concurrently - private boolean send(final Packet packet, final int reconnectID, final boolean flush, final boolean batch) { - if (invokeInterceptors(packet, interceptors, connection) != null) { - return false; + private ActiveMQBuffer beforeSend(final Packet packet, final int reconnectID) { + packet.setChannelID(id); + + if (responseAsyncCache != null && packet.isRequiresResponse() && packet.isResponseAsync()) { + packet.setCorrelationID(responseAsyncCache.nextCorrelationID()); } - synchronized (sendLock) { - packet.setChannelID(id); + if (logger.isTraceEnabled()) { + logger.trace("RemotingConnectionID=" + (connection == null ? "NULL" : connection.getID()) + " Sending packet nonblocking " + packet + " on channelID=" + id); + } - if (responseAsyncCache != null && packet.isRequiresResponse() && packet.isResponseAsync()) { - packet.setCorrelationID(responseAsyncCache.nextCorrelationID()); + ActiveMQBuffer buffer = packet.encode(connection); + + lock.lock(); + + try { + if (failingOver) { + waitForFailOver("RemotingConnectionID=" + (connection == null ? "NULL" : connection.getID()) + " timed-out waiting for fail-over condition on non-blocking send"); } - if (logger.isTraceEnabled()) { - logger.trace("RemotingConnectionID=" + (connection == null ? "NULL" : connection.getID()) + " Sending packet nonblocking " + packet + " on channelID=" + id); + // Sanity check + if (transferring) { + throw ActiveMQClientMessageBundle.BUNDLE.cannotSendPacketDuringFailover(); } - ActiveMQBuffer buffer = packet.encode(connection); + if (resendCache != null && packet.isRequiresConfirmations()) { + addResendPacket(packet); + } - lock.lock(); + } finally { + lock.unlock(); + } - try { - if (failingOver) { - waitForFailOver("RemotingConnectionID=" + (connection == null ? "NULL" : connection.getID()) + " timed-out waiting for fail-over condition on non-blocking send"); - } + if (logger.isTraceEnabled()) { + logger.trace("RemotingConnectionID=" + (connection == null ? "NULL" : connection.getID()) + " Writing buffer for channelID=" + id); + } - // Sanity check - if (transferring) { - throw ActiveMQClientMessageBundle.BUNDLE.cannotSendPacketDuringFailover(); - } + checkReconnectID(reconnectID); - if (resendCache != null && packet.isRequiresConfirmations()) { - addResendPacket(packet); + //We do this outside the lock as ResponseCache is threadsafe and allows responses to come in, + //As the send could block if the response cache cannot add, preventing responses to be handled. + if (responseAsyncCache != null && packet.isRequiresResponse() && packet.isResponseAsync()) { + while (!responseAsyncCache.add(packet)) { + try { + Thread.sleep(1); + } catch (Exception e) { + // Ignore Review comment: If an Thread interrupt will happen, it should start spinning. I would add a time check that on each N seconds will warn that the loop hasn't finished yet ---------------------------------------------------------------- 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: us...@infra.apache.org Issue Time Tracking ------------------- Worklog Id: (was: 243613) Time Spent: 5h 10m (was: 5h) > 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 10m > Remaining Estimate: 0h > > Use sendfile to replicate files during backup sever bootstrap. -- This message was sent by Atlassian JIRA (v7.6.3#76005)