From 3099c4bd8c239eedda329eac0bffdbf651189e68 Mon Sep 17 00:00:00 2001 From: Clebert Suconic Date: Wed, 10 Aug 2016 17:34:55 -0400 Subject: [PATCH] ARTEMIS-601 Highlighting reload events with log.info --- .../artemis/jms/server/impl/JMSServerManagerImpl.java | 3 +++ .../activemq/artemis/core/server/ActiveMQServerLogger.java | 5 +++++ .../artemis/core/server/impl/ActiveMQServerImpl.java | 2 ++ .../artemis/core/server/reload/ReloadManagerImpl.java | 3 ++- 4 files changed, 12 insertions(+), 1 deletion(-) diff --git a/artemis-jms-server/src/main/java/org/apache/activemq/artemis/jms/server/impl/JMSServerManagerImpl.java b/artemis-jms-server/src/main/java/org/apache/activemq/artemis/jms/server/impl/JMSServerManagerImpl.java index 364bb7546e..ce9a27c6dc 100644 --- a/artemis-jms-server/src/main/java/org/apache/activemq/artemis/jms/server/impl/JMSServerManagerImpl.java +++ b/artemis-jms-server/src/main/java/org/apache/activemq/artemis/jms/server/impl/JMSServerManagerImpl.java @@ -56,6 +56,7 @@ import org.apache.activemq.artemis.core.remoting.impl.netty.TransportConstants; import org.apache.activemq.artemis.core.security.Role; import org.apache.activemq.artemis.core.server.ActivateCallback; import org.apache.activemq.artemis.core.server.ActiveMQServer; +import org.apache.activemq.artemis.core.server.ActiveMQServerLogger; import org.apache.activemq.artemis.core.server.PostQueueCreationCallback; import org.apache.activemq.artemis.core.server.PostQueueDeletionCallback; import org.apache.activemq.artemis.core.server.Queue; @@ -1761,6 +1762,8 @@ public class JMSServerManagerImpl implements JMSServerManager, ActivateCallback private final class JMSReloader implements ReloadCallback { @Override public void reload(URL url) throws Exception { + ActiveMQServerLogger.LOGGER.reloadingConfiguration("jms"); + InputStream input = url.openStream(); Reader reader = new InputStreamReader(input); String xml = XMLUtil.readerToString(reader); diff --git a/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/ActiveMQServerLogger.java b/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/ActiveMQServerLogger.java index 663c15cb4d..7ff773bc2f 100644 --- a/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/ActiveMQServerLogger.java +++ b/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/ActiveMQServerLogger.java @@ -328,6 +328,11 @@ public interface ActiveMQServerLogger extends BasicLogger { format = Message.Format.MESSAGE_FORMAT) void removingBackupData(String path); + @LogMessage(level = Logger.Level.INFO) + @Message(id = 221056, value = "Reloading configuration ...{0}", + format = Message.Format.MESSAGE_FORMAT) + void reloadingConfiguration(String module); + @LogMessage(level = Logger.Level.WARN) @Message(id = 222000, value = "ActiveMQServer is being finalized and has not been stopped. Please remember to stop the server before letting it go out of scope", format = Message.Format.MESSAGE_FORMAT) diff --git a/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/impl/ActiveMQServerImpl.java b/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/impl/ActiveMQServerImpl.java index 7edd985cfc..3b86c22021 100644 --- a/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/impl/ActiveMQServerImpl.java +++ b/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/impl/ActiveMQServerImpl.java @@ -2373,7 +2373,9 @@ public class ActiveMQServerImpl implements ActiveMQServer { @Override public void reload(URL uri) throws Exception { Configuration config = new FileConfigurationParser().parseMainConfig(uri.openStream()); + ActiveMQServerLogger.LOGGER.reloadingConfiguration("security"); securityRepository.swap(config.getSecurityRoles().entrySet()); + ActiveMQServerLogger.LOGGER.reloadingConfiguration("address settings"); addressSettingsRepository.swap(config.getAddressesSettings().entrySet()); } } diff --git a/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/reload/ReloadManagerImpl.java b/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/reload/ReloadManagerImpl.java index 0ccbea14c0..a735b936d5 100644 --- a/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/reload/ReloadManagerImpl.java +++ b/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/reload/ReloadManagerImpl.java @@ -121,12 +121,13 @@ public class ReloadManagerImpl implements ReloadManager { class ReloadRegistry { private final File file; private final URL uri; - private volatile long lastModified; + private long lastModified; private final List callbacks = new LinkedList<>(); ReloadRegistry(URL uri) { this.file = new File(uri.getPath()); + this.lastModified = file.lastModified(); this.uri = uri; }