activemq-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From clebertsuco...@apache.org
Subject activemq-artemis git commit: ARTEMIS-2094 - Fix Configuration change loss when network Issue
Date Wed, 26 Sep 2018 18:47:19 GMT
Repository: activemq-artemis
Updated Branches:
  refs/heads/2.6.x 4f6a13e0f -> 89a6ba92a


ARTEMIS-2094 - Fix Configuration change loss when network Issue

(cherry picked from commit cce0e19)

Project: http://git-wip-us.apache.org/repos/asf/activemq-artemis/repo
Commit: http://git-wip-us.apache.org/repos/asf/activemq-artemis/commit/89a6ba92
Tree: http://git-wip-us.apache.org/repos/asf/activemq-artemis/tree/89a6ba92
Diff: http://git-wip-us.apache.org/repos/asf/activemq-artemis/diff/89a6ba92

Branch: refs/heads/2.6.x
Commit: 89a6ba92a7ee6c42927453355e870a49387d670e
Parents: 4f6a13e
Author: Michael André Pearce <michael.andre.pearce@me.com>
Authored: Wed Sep 26 15:47:05 2018 +0100
Committer: Michael André Pearce <michael.andre.pearce@me.com>
Committed: Wed Sep 26 15:48:57 2018 +0100

----------------------------------------------------------------------
 .../core/server/impl/ActiveMQServerImpl.java    | 58 ++++++++++----------
 .../tests/integration/jms/RedeployTest.java     | 21 ++++++-
 .../test/resources/reload-backup-changed.xml    | 14 +++++
 .../test/resources/reload-backup-original.xml   | 14 +++++
 .../src/test/resources/reload-live-changed.xml  | 14 +++++
 .../src/test/resources/reload-live-original.xml | 14 +++++
 6 files changed, 105 insertions(+), 30 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/89a6ba92/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/impl/ActiveMQServerImpl.java
----------------------------------------------------------------------
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 8557852..87aafdc 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
@@ -2390,15 +2390,7 @@ public class ActiveMQServerImpl implements ActiveMQServer {
       }
 
       // Deploy the rest of the stuff
-
-      // Deploy predefined addresses
-      deployAddressesFromConfiguration();
-
-      // Deploy any predefined queues
-      deployQueuesFromConfiguration();
-
-      // Undeploy any addresses and queues not in config
-      undeployAddressesAndQueueNotInConfiguration();
+      deployReloadableConfigFromConfiguration(configuration);
 
       // We need to call this here, this gives any dependent server a chance to deploy its
own addresses
       // this needs to be done before clustering is fully activated
@@ -2620,6 +2612,8 @@ public class ActiveMQServerImpl implements ActiveMQServer {
       }
    }
 
+
+
    private JournalLoadInformation[] loadJournals() throws Exception {
       JournalLoader journalLoader = activation.createJournalLoader(postOffice, pagingManager,
storageManager, queueFactory, nodeManager, managementService, groupingHandler, configuration,
parentServer);
 
@@ -3169,30 +3163,36 @@ public class ActiveMQServerImpl implements ActiveMQServer {
 
       @Override
       public void reload(URL uri) throws Exception {
+         Configuration config = new FileConfigurationParser().parseMainConfig(uri.openStream());
+         configuration.setSecurityRoles(config.getSecurityRoles());
+         configuration.setAddressesSettings(config.getAddressesSettings());
+         configuration.setDivertConfigurations(config.getDivertConfigurations());
+         configuration.setAddressConfigurations(config.getAddressConfigurations());
+         configuration.setQueueConfigurations(config.getQueueConfigurations());
          if (isActive()) {
-            Configuration config = new FileConfigurationParser().parseMainConfig(uri.openStream());
-            ActiveMQServerLogger.LOGGER.reloadingConfiguration("security");
-            securityRepository.swap(config.getSecurityRoles().entrySet());
-            configuration.setSecurityRoles(config.getSecurityRoles());
-
-            ActiveMQServerLogger.LOGGER.reloadingConfiguration("address settings");
-            addressSettingsRepository.swap(config.getAddressesSettings().entrySet());
-            configuration.setAddressesSettings(config.getAddressesSettings());
-
-            ActiveMQServerLogger.LOGGER.reloadingConfiguration("diverts");
-            for (DivertConfiguration divertConfig : config.getDivertConfigurations()) {
-               if (postOffice.getBinding(new SimpleString(divertConfig.getName())) == null)
{
-                  deployDivert(divertConfig);
-               }
-            }
+            deployReloadableConfigFromConfiguration(configuration);
+         }
+      }
+   }
 
-            ActiveMQServerLogger.LOGGER.reloadingConfiguration("addresses");
-            undeployAddressesAndQueueNotInConfiguration(config);
-            deployAddressesFromConfiguration(config);
-            configuration.setAddressConfigurations(config.getAddressConfigurations());
-            configuration.setQueueConfigurations(config.getQueueConfigurations());
+   private void deployReloadableConfigFromConfiguration(Configuration config) throws Exception
{
+      ActiveMQServerLogger.LOGGER.reloadingConfiguration("security");
+      securityRepository.swap(config.getSecurityRoles().entrySet());
+
+      ActiveMQServerLogger.LOGGER.reloadingConfiguration("address settings");
+      addressSettingsRepository.swap(config.getAddressesSettings().entrySet());
+
+      ActiveMQServerLogger.LOGGER.reloadingConfiguration("diverts");
+      for (DivertConfiguration divertConfig : config.getDivertConfigurations()) {
+         if (postOffice.getBinding(new SimpleString(divertConfig.getName())) == null) {
+            deployDivert(divertConfig);
          }
       }
+
+      ActiveMQServerLogger.LOGGER.reloadingConfiguration("addresses");
+      undeployAddressesAndQueueNotInConfiguration(config);
+      deployAddressesFromConfiguration(config);
+      deployQueuesFromListCoreQueueConfiguration(config.getQueueConfigurations());
    }
 
    public Set<ActivateCallback> getActivateCallbacks() {

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/89a6ba92/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/jms/RedeployTest.java
----------------------------------------------------------------------
diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/jms/RedeployTest.java
b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/jms/RedeployTest.java
index b9999d0..ba63166 100644
--- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/jms/RedeployTest.java
+++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/jms/RedeployTest.java
@@ -21,6 +21,7 @@ import java.net.URL;
 import java.nio.file.Files;
 import java.nio.file.Path;
 import java.nio.file.StandardCopyOption;
+import java.util.HashSet;
 import java.util.List;
 import java.util.Set;
 import java.util.concurrent.TimeUnit;
@@ -41,6 +42,7 @@ import org.apache.activemq.artemis.api.core.SimpleString;
 import org.apache.activemq.artemis.core.postoffice.QueueBinding;
 import org.apache.activemq.artemis.core.security.Role;
 import org.apache.activemq.artemis.core.server.impl.AddressInfo;
+import org.apache.activemq.artemis.core.settings.impl.AddressFullMessagePolicy;
 import org.apache.activemq.artemis.core.settings.impl.AddressSettings;
 import org.apache.activemq.artemis.jms.client.ActiveMQConnectionFactory;
 import org.apache.activemq.artemis.jms.server.embedded.EmbeddedJMS;
@@ -108,6 +110,12 @@ public class RedeployTest extends ActiveMQTestBase {
 
    @Test
    public void testRedeployWithFailover() throws Exception {
+
+      Set<Role> original = new HashSet<>();
+      original.add(new Role("a", false, true, false, false, false, false, false, false, false,
false));
+      Set<Role> changed = new HashSet<>();
+      changed.add(new Role("b", false, true, false, false, false, false, false, false, false,
false));
+
       EmbeddedJMS live = new EmbeddedJMS();
       EmbeddedJMS backup = new EmbeddedJMS();
 
@@ -135,6 +143,11 @@ public class RedeployTest extends ActiveMQTestBase {
 
          Wait.waitFor(() -> backup.getActiveMQServer().isReplicaSync(), 10000, 200);
 
+         assertEquals("Test address settings original - live", AddressFullMessagePolicy.BLOCK,
live.getActiveMQServer().getAddressSettingsRepository().getMatch("myQueue").getAddressFullMessagePolicy());
+         assertEquals("Test address settings original - backup", AddressFullMessagePolicy.BLOCK,
backup.getActiveMQServer().getAddressSettingsRepository().getMatch("myQueue").getAddressFullMessagePolicy());
+         assertEquals("Test security settings original - live", original, live.getActiveMQServer().getSecurityRepository().getMatch("myQueue"));
+         assertEquals("Test security settings original - backup", original, backup.getActiveMQServer().getSecurityRepository().getMatch("myQueue"));
+
          final ReusableLatch liveReloadLatch = new ReusableLatch(1);
          Runnable liveTick = () -> liveReloadLatch.countDown();
          live.getActiveMQServer().getReloadManager().setTick(liveTick);
@@ -162,9 +175,13 @@ public class RedeployTest extends ActiveMQTestBase {
             Session session = connection.createSession();
             Queue queue = session.createQueue("myQueue2");
             MessageProducer producer = session.createProducer(queue);
-            producer.send(session.createTextMessage("text"));
+            producer.send(session.createTextMessage("text1"));
          }
 
+         assertFalse(backup.getActiveMQServer().isActive());
+         assertEquals("Test address settings redeploy - live", AddressFullMessagePolicy.PAGE,
live.getActiveMQServer().getAddressSettingsRepository().getMatch("myQueue").getAddressFullMessagePolicy());
+         assertEquals("Test security settings redeploy - live", changed, live.getActiveMQServer().getSecurityRepository().getMatch("myQueue"));
+
          live.stop();
 
          Wait.waitFor(() -> (backup.getActiveMQServer().isActive()), 5000, 100);
@@ -180,6 +197,8 @@ public class RedeployTest extends ActiveMQTestBase {
             Assert.assertNotNull("Queue wasn't deployed accordingly", consumer.receive(5000));
             Assert.assertNotNull(consumer.receive(5000));
          }
+         assertEquals("Test address settings redeploy - backup", changed, backup.getActiveMQServer().getSecurityRepository().getMatch("myQueue"));
+         assertEquals("Test security settings redeploy - backup", AddressFullMessagePolicy.PAGE,
backup.getActiveMQServer().getAddressSettingsRepository().getMatch("myQueue").getAddressFullMessagePolicy());
       } finally {
          live.stop();
          backup.stop();

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/89a6ba92/tests/integration-tests/src/test/resources/reload-backup-changed.xml
----------------------------------------------------------------------
diff --git a/tests/integration-tests/src/test/resources/reload-backup-changed.xml b/tests/integration-tests/src/test/resources/reload-backup-changed.xml
index 8ea9241..a4d94f7 100644
--- a/tests/integration-tests/src/test/resources/reload-backup-changed.xml
+++ b/tests/integration-tests/src/test/resources/reload-backup-changed.xml
@@ -78,5 +78,19 @@ under the License.
             </anycast>
          </address>
       </addresses>
+
+      <address-settings>
+         <address-setting match="#" >
+            <address-full-policy>PAGE</address-full-policy>
+            <config-delete-queues>FORCE</config-delete-queues>
+            <config-delete-addresses>FORCE</config-delete-addresses>
+         </address-setting>
+      </address-settings>
+
+      <security-settings>
+         <security-setting match="#" >
+            <permission type="consume" roles="b" />
+         </security-setting>
+      </security-settings>
    </core>
 </configuration>

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/89a6ba92/tests/integration-tests/src/test/resources/reload-backup-original.xml
----------------------------------------------------------------------
diff --git a/tests/integration-tests/src/test/resources/reload-backup-original.xml b/tests/integration-tests/src/test/resources/reload-backup-original.xml
index 54a01a9..5dd92b3 100644
--- a/tests/integration-tests/src/test/resources/reload-backup-original.xml
+++ b/tests/integration-tests/src/test/resources/reload-backup-original.xml
@@ -73,5 +73,19 @@ under the License.
             </anycast>
          </address>
       </addresses>
+
+      <address-settings>
+         <address-setting match="#" >
+            <address-full-policy>BLOCK</address-full-policy>
+            <config-delete-queues>FORCE</config-delete-queues>
+            <config-delete-addresses>FORCE</config-delete-addresses>
+         </address-setting>
+      </address-settings>
+
+      <security-settings>
+         <security-setting match="#" >
+            <permission type="consume" roles="a" />
+         </security-setting>
+      </security-settings>
    </core>
 </configuration>

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/89a6ba92/tests/integration-tests/src/test/resources/reload-live-changed.xml
----------------------------------------------------------------------
diff --git a/tests/integration-tests/src/test/resources/reload-live-changed.xml b/tests/integration-tests/src/test/resources/reload-live-changed.xml
index 17120ce..f603263 100644
--- a/tests/integration-tests/src/test/resources/reload-live-changed.xml
+++ b/tests/integration-tests/src/test/resources/reload-live-changed.xml
@@ -78,5 +78,19 @@ under the License.
             </anycast>
          </address>
       </addresses>
+
+      <address-settings>
+         <address-setting match="#" >
+            <address-full-policy>PAGE</address-full-policy>
+            <config-delete-queues>FORCE</config-delete-queues>
+            <config-delete-addresses>FORCE</config-delete-addresses>
+         </address-setting>
+      </address-settings>
+
+      <security-settings>
+         <security-setting match="#" >
+            <permission type="consume" roles="b" />
+         </security-setting>
+      </security-settings>
    </core>
 </configuration>

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/89a6ba92/tests/integration-tests/src/test/resources/reload-live-original.xml
----------------------------------------------------------------------
diff --git a/tests/integration-tests/src/test/resources/reload-live-original.xml b/tests/integration-tests/src/test/resources/reload-live-original.xml
index 9051d58..3979c9a 100644
--- a/tests/integration-tests/src/test/resources/reload-live-original.xml
+++ b/tests/integration-tests/src/test/resources/reload-live-original.xml
@@ -73,5 +73,19 @@ under the License.
             </anycast>
          </address>
       </addresses>
+
+      <address-settings>
+         <address-setting match="#" >
+            <address-full-policy>BLOCK</address-full-policy>
+            <config-delete-queues>FORCE</config-delete-queues>
+            <config-delete-addresses>FORCE</config-delete-addresses>
+         </address-setting>
+      </address-settings>
+
+      <security-settings>
+         <security-setting match="#" >
+            <permission type="consume" roles="a" />
+         </security-setting>
+      </security-settings>
    </core>
 </configuration>


Mime
View raw message