ARTEMIS-423 Do not set backup node as self
This commit is contained in:
parent
d2539e5161
commit
964b145733
|
@ -19,6 +19,7 @@ package org.apache.activemq.artemis.core.server.impl;
|
||||||
import java.util.concurrent.CountDownLatch;
|
import java.util.concurrent.CountDownLatch;
|
||||||
import java.util.concurrent.TimeUnit;
|
import java.util.concurrent.TimeUnit;
|
||||||
|
|
||||||
|
import org.apache.activemq.artemis.api.core.TransportConfiguration;
|
||||||
import org.apache.activemq.artemis.api.core.client.ClusterTopologyListener;
|
import org.apache.activemq.artemis.api.core.client.ClusterTopologyListener;
|
||||||
import org.apache.activemq.artemis.api.core.client.TopologyMember;
|
import org.apache.activemq.artemis.api.core.client.TopologyMember;
|
||||||
|
|
||||||
|
@ -28,12 +29,22 @@ final class BackupTopologyListener implements ClusterTopologyListener {
|
||||||
private final String ownId;
|
private final String ownId;
|
||||||
private static final int WAIT_TIMEOUT = 60;
|
private static final int WAIT_TIMEOUT = 60;
|
||||||
|
|
||||||
public BackupTopologyListener(String ownId) {
|
// Transport configuration of this node
|
||||||
|
private final TransportConfiguration myTc;
|
||||||
|
|
||||||
|
public BackupTopologyListener(String ownId, TransportConfiguration nodeTransportConfig) {
|
||||||
this.ownId = ownId;
|
this.ownId = ownId;
|
||||||
|
this.myTc = nodeTransportConfig;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void nodeUP(TopologyMember topologyMember, boolean last) {
|
public void nodeUP(TopologyMember topologyMember, boolean last) {
|
||||||
|
|
||||||
|
// If the backup is this node then ignore.
|
||||||
|
if (myTc.equals(topologyMember.getBackup())) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
final String nodeID = topologyMember.getNodeId();
|
final String nodeID = topologyMember.getNodeId();
|
||||||
|
|
||||||
if (ownId.equals(nodeID) && topologyMember.getBackup() != null)
|
if (ownId.equals(nodeID) && topologyMember.getBackup() != null)
|
||||||
|
|
|
@ -168,7 +168,7 @@ public class SharedNothingLiveActivation extends LiveActivation {
|
||||||
//backupUpToDate = false;
|
//backupUpToDate = false;
|
||||||
|
|
||||||
if (isFailBackRequest && replicatedPolicy.isAllowAutoFailBack()) {
|
if (isFailBackRequest && replicatedPolicy.isAllowAutoFailBack()) {
|
||||||
BackupTopologyListener listener1 = new BackupTopologyListener(activeMQServer.getNodeID().toString());
|
BackupTopologyListener listener1 = new BackupTopologyListener(activeMQServer.getNodeID().toString(), clusterConnection.getConnector());
|
||||||
clusterConnection.addClusterTopologyListener(listener1);
|
clusterConnection.addClusterTopologyListener(listener1);
|
||||||
if (listener1.waitForBackup()) {
|
if (listener1.waitForBackup()) {
|
||||||
//if we have to many backups kept or are not configured to restart just stop, otherwise restart as a backup
|
//if we have to many backups kept or are not configured to restart just stop, otherwise restart as a backup
|
||||||
|
|
|
@ -20,6 +20,7 @@ import java.nio.channels.ClosedChannelException;
|
||||||
import java.util.concurrent.TimeUnit;
|
import java.util.concurrent.TimeUnit;
|
||||||
|
|
||||||
import org.apache.activemq.artemis.api.core.ActiveMQException;
|
import org.apache.activemq.artemis.api.core.ActiveMQException;
|
||||||
|
import org.apache.activemq.artemis.api.core.TransportConfiguration;
|
||||||
import org.apache.activemq.artemis.core.config.Configuration;
|
import org.apache.activemq.artemis.core.config.Configuration;
|
||||||
import org.apache.activemq.artemis.core.paging.PagingManager;
|
import org.apache.activemq.artemis.core.paging.PagingManager;
|
||||||
import org.apache.activemq.artemis.core.persistence.StorageManager;
|
import org.apache.activemq.artemis.core.persistence.StorageManager;
|
||||||
|
@ -196,7 +197,8 @@ public final class SharedStoreBackupActivation extends Activation {
|
||||||
BackupTopologyListener backupListener;
|
BackupTopologyListener backupListener;
|
||||||
|
|
||||||
FailbackChecker() {
|
FailbackChecker() {
|
||||||
backupListener = new BackupTopologyListener(activeMQServer.getNodeID().toString());
|
TransportConfiguration connector = activeMQServer.getClusterManager().getDefaultConnection(null).getConnector();
|
||||||
|
backupListener = new BackupTopologyListener(activeMQServer.getNodeID().toString(), connector);
|
||||||
activeMQServer.getClusterManager().getDefaultConnection(null).addClusterTopologyListener(backupListener);
|
activeMQServer.getClusterManager().getDefaultConnection(null).addClusterTopologyListener(backupListener);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue