ARTEMIS-2448 group-name ignored in replicated colocated setup

This commit is contained in:
Francesco Nigro 2019-08-07 19:26:21 +02:00 committed by Clebert Suconic
parent 91a67fa690
commit 191323176a
3 changed files with 18 additions and 2 deletions

View File

@ -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

View File

@ -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

View File

@ -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();