From 9c18dd04df2e8f19f34a215a6d98561941b11708 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michael=20Andr=C3=A9=20Pearce?= Date: Fri, 5 Jan 2018 17:53:34 +0000 Subject: [PATCH] ARTEMIS-1585 - Log connector details on start Log connector details when they start. This is similar to that of acceptors, and helps when any issues later. --- .../artemis/core/client/ActiveMQClientLogger.java | 8 ++++++++ .../core/remoting/impl/netty/NettyConnector.java | 15 ++++++++++----- .../core/remoting/impl/invm/InVMConnector.java | 4 ++++ 3 files changed, 22 insertions(+), 5 deletions(-) diff --git a/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/client/ActiveMQClientLogger.java b/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/client/ActiveMQClientLogger.java index a06e221bc3..848cfa098b 100644 --- a/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/client/ActiveMQClientLogger.java +++ b/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/client/ActiveMQClientLogger.java @@ -64,6 +64,14 @@ public interface ActiveMQClientLogger extends BasicLogger { @Message(id = 211001, value = "session created", format = Message.Format.MESSAGE_FORMAT) void dumpingSessionStack(@Cause Exception e); + @LogMessage(level = Logger.Level.INFO) + @Message(id = 211002, value = "Started {0} Netty Connector version {1} to {2}:{3,number,#}", format = Message.Format.MESSAGE_FORMAT) + void startedNettyConnector(String connectorType, String version, String host, Integer port); + + @LogMessage(level = Logger.Level.INFO) + @Message(id = 211003, value = "Started InVM Connector", format = Message.Format.MESSAGE_FORMAT) + void startedInVMConnector(); + @LogMessage(level = Logger.Level.WARN) @Message(id = 212000, value = "{0}", format = Message.Format.MESSAGE_FORMAT) void warn(String message); diff --git a/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/remoting/impl/netty/NettyConnector.java b/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/remoting/impl/netty/NettyConnector.java index 5d3b82d7b5..792c8aa227 100644 --- a/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/remoting/impl/netty/NettyConnector.java +++ b/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/remoting/impl/netty/NettyConnector.java @@ -119,6 +119,10 @@ import static org.apache.activemq.artemis.utils.Base64.encodeBytes; public class NettyConnector extends AbstractConnector { + public static String NIO_CONNECTOR_TYPE = "NIO"; + public static String EPOLL_CONNECTOR_TYPE = "EPOLL"; + public static String KQUEUE_CONNECTOR_TYPE = "KQUEUE"; + private static final Logger logger = Logger.getLogger(NettyConnector.class); // Constants ----------------------------------------------------- @@ -423,13 +427,15 @@ public class NettyConnector extends AbstractConnector { remotingThreads = Runtime.getRuntime().availableProcessors() * 3; } + String connectorType; + if (useEpoll && Epoll.isAvailable()) { if (useGlobalWorkerPool) { group = SharedEventLoopGroup.getInstance((threadFactory -> new EpollEventLoopGroup(remotingThreads, threadFactory))); } else { group = new EpollEventLoopGroup(remotingThreads); } - + connectorType = EPOLL_CONNECTOR_TYPE; channelClazz = EpollSocketChannel.class; logger.debug("Connector " + this + " using native epoll"); } else if (useKQueue && KQueue.isAvailable()) { @@ -438,7 +444,7 @@ public class NettyConnector extends AbstractConnector { } else { group = new KQueueEventLoopGroup(remotingThreads); } - + connectorType = KQUEUE_CONNECTOR_TYPE; channelClazz = KQueueSocketChannel.class; logger.debug("Connector " + this + " using native kqueue"); } else { @@ -449,7 +455,7 @@ public class NettyConnector extends AbstractConnector { channelClazz = NioSocketChannel.class; group = new NioEventLoopGroup(remotingThreads); } - + connectorType = NIO_CONNECTOR_TYPE; channelClazz = NioSocketChannel.class; logger.debug("Connector + " + this + " using nio"); } @@ -634,8 +640,7 @@ public class NettyConnector extends AbstractConnector { batchFlusherFuture = scheduledThreadPool.scheduleWithFixedDelay(flusher, batchDelay, batchDelay, TimeUnit.MILLISECONDS); } - - logger.debug("Started Netty Connector version " + TransportConstants.NETTY_VERSION); + ActiveMQClientLogger.LOGGER.startedNettyConnector(connectorType, TransportConstants.NETTY_VERSION, host, port); } @Override diff --git a/artemis-server/src/main/java/org/apache/activemq/artemis/core/remoting/impl/invm/InVMConnector.java b/artemis-server/src/main/java/org/apache/activemq/artemis/core/remoting/impl/invm/InVMConnector.java index c84020c764..e635bc46b7 100644 --- a/artemis-server/src/main/java/org/apache/activemq/artemis/core/remoting/impl/invm/InVMConnector.java +++ b/artemis-server/src/main/java/org/apache/activemq/artemis/core/remoting/impl/invm/InVMConnector.java @@ -29,6 +29,7 @@ import java.util.concurrent.TimeUnit; import org.apache.activemq.artemis.api.core.ActiveMQException; import org.apache.activemq.artemis.api.core.client.ActiveMQClient; +import org.apache.activemq.artemis.core.client.ActiveMQClientLogger; import org.apache.activemq.artemis.core.server.ActiveMQComponent; import org.apache.activemq.artemis.core.server.ActiveMQMessageBundle; import org.apache.activemq.artemis.spi.core.remoting.AbstractConnector; @@ -47,6 +48,8 @@ import org.jboss.logging.Logger; public class InVMConnector extends AbstractConnector { + public static String INVM_CONNECTOR_TYPE = "IN-VM"; + private static final Logger logger = Logger.getLogger(InVMConnector.class); public static final Map DEFAULT_CONFIG; @@ -195,6 +198,7 @@ public class InVMConnector extends AbstractConnector { @Override public synchronized void start() { started = true; + ActiveMQClientLogger.LOGGER.startedInVMConnector(); } public BufferHandler getHandler() {