activemq-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From clebertsuco...@apache.org
Subject [activemq-artemis] branch master updated: ARTEMIS-2448 group-name ignored in replicated colocated setup
Date Thu, 08 Aug 2019 17:16:32 GMT
This is an automated email from the ASF dual-hosted git repository.

clebertsuconic pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/activemq-artemis.git


The following commit(s) were added to refs/heads/master by this push:
     new 1913231  ARTEMIS-2448 group-name ignored in replicated colocated setup
     new 8049300  This closes #2789
1913231 is described below

commit 191323176a7a2de73295e61ac4066578ba31754a
Author: Francesco Nigro <nigro.fra@gmail.com>
AuthorDate: Wed Aug 7 19:26:21 2019 +0200

    ARTEMIS-2448 group-name ignored in replicated colocated setup
---
 .../artemis/core/server/cluster/ha/ColocatedHAManager.java   | 12 +++++++++++-
 .../artemis/core/server/cluster/ha/ColocatedPolicy.java      |  6 +++++-
 .../artemis/core/config/impl/HAPolicyConfigurationTest.java  |  2 ++
 3 files changed, 18 insertions(+), 2 deletions(-)

diff --git a/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/cluster/ha/ColocatedHAManager.java
b/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/cluster/ha/ColocatedHAManager.java
index 505859c..90f5521 100644
--- a/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/cluster/ha/ColocatedHAManager.java
+++ b/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/cluster/ha/ColocatedHAManager.java
@@ -19,6 +19,7 @@ package org.apache.activemq.artemis.core.server.cluster.ha;
 import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
+import java.util.Objects;
 import java.util.Set;
 
 import org.apache.activemq.artemis.api.core.Pair;
@@ -172,10 +173,19 @@ public class ColocatedHAManager implements HAManager {
     * @throws Exception
     */
    private synchronized boolean activateReplicatedBackup(SimpleString nodeID) throws Exception
{
+      final TopologyMember member;
+      try {
+         member = server.getClusterManager().getDefaultConnection(null).getTopology().getMember(nodeID.toString());
+         if (!Objects.equals(member.getBackupGroupName(), haPolicy.getBackupPolicy().getBackupGroupName()))
{
+            return false;
+         }
+      } catch (Exception e) {
+         ActiveMQServerLogger.LOGGER.activateReplicatedBackupFailed(e);
+         return false;
+      }
       Configuration configuration = server.getConfiguration().copy();
       ActiveMQServer backup = server.createBackupServer(configuration);
       try {
-         TopologyMember member = server.getClusterManager().getDefaultConnection(null).getTopology().getMember(nodeID.toString());
          int portOffset = haPolicy.getBackupPortOffset() * (backupServers.size() + 1);
          String name = "colocated_backup_" + backupServers.size() + 1;
          //make sure we don't restart as we are colocated
diff --git a/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/cluster/ha/ColocatedPolicy.java
b/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/cluster/ha/ColocatedPolicy.java
index b1ace20..b72c755 100644
--- a/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/cluster/ha/ColocatedPolicy.java
+++ b/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/cluster/ha/ColocatedPolicy.java
@@ -65,7 +65,11 @@ public class ColocatedPolicy implements HAPolicy<LiveActivation>
{
 
    @Override
    public String getBackupGroupName() {
-      return null;
+      final HAPolicy<LiveActivation> livePolicy = this.livePolicy;
+      if (livePolicy == null) {
+         return null;
+      }
+      return livePolicy.getBackupGroupName();
    }
 
    @Override
diff --git a/artemis-server/src/test/java/org/apache/activemq/artemis/core/config/impl/HAPolicyConfigurationTest.java
b/artemis-server/src/test/java/org/apache/activemq/artemis/core/config/impl/HAPolicyConfigurationTest.java
index fd9b523..425ff7b 100644
--- a/artemis-server/src/test/java/org/apache/activemq/artemis/core/config/impl/HAPolicyConfigurationTest.java
+++ b/artemis-server/src/test/java/org/apache/activemq/artemis/core/config/impl/HAPolicyConfigurationTest.java
@@ -358,6 +358,8 @@ public class HAPolicyConfigurationTest extends ActiveMQTestBase {
          assertNotNull(livePolicy);
 
          assertEquals(livePolicy.getGroupName(), "purple");
+         assertEquals(livePolicy.getGroupName(), livePolicy.getBackupGroupName());
+         assertEquals(livePolicy.getBackupGroupName(), haPolicy.getBackupGroupName());
          assertTrue(livePolicy.isCheckForLiveServer());
          assertEquals(livePolicy.getClusterName(), "abcdefg");
          ReplicaPolicy backupPolicy = (ReplicaPolicy) colocatedPolicy.getBackupPolicy();


Mime
View raw message