ARTEMIS-3755 mitigate NPE related to fail-back
This commit is contained in:
parent
84e68c76e9
commit
650952ba67
|
@ -1773,6 +1773,11 @@ public interface ActiveMQServerLogger extends BasicLogger {
|
||||||
@Message(id = 222307, value = "The queues element is deprecated and replaced by the addresses element")
|
@Message(id = 222307, value = "The queues element is deprecated and replaced by the addresses element")
|
||||||
void queuesElementDeprecated();
|
void queuesElementDeprecated();
|
||||||
|
|
||||||
|
@LogMessage(level = Logger.Level.WARN)
|
||||||
|
@Message(id = 222308, value = "Unable to listen for incoming fail-back request because {0} is null. Ensure the broker has the proper cluster-connection configuration.",
|
||||||
|
format = Message.Format.MESSAGE_FORMAT)
|
||||||
|
void failBackCheckerFailure(String component);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@LogMessage(level = Logger.Level.ERROR)
|
@LogMessage(level = Logger.Level.ERROR)
|
||||||
|
|
|
@ -35,6 +35,8 @@ import org.apache.activemq.artemis.core.server.NodeManager;
|
||||||
import org.apache.activemq.artemis.core.server.NodeManager.LockListener;
|
import org.apache.activemq.artemis.core.server.NodeManager.LockListener;
|
||||||
import org.apache.activemq.artemis.core.server.NodeManager.NodeManagerException;
|
import org.apache.activemq.artemis.core.server.NodeManager.NodeManagerException;
|
||||||
import org.apache.activemq.artemis.core.server.QueueFactory;
|
import org.apache.activemq.artemis.core.server.QueueFactory;
|
||||||
|
import org.apache.activemq.artemis.core.server.cluster.ClusterConnection;
|
||||||
|
import org.apache.activemq.artemis.core.server.cluster.ClusterManager;
|
||||||
import org.apache.activemq.artemis.core.server.cluster.ha.ScaleDownPolicy;
|
import org.apache.activemq.artemis.core.server.cluster.ha.ScaleDownPolicy;
|
||||||
import org.apache.activemq.artemis.core.server.cluster.ha.SharedStoreSlavePolicy;
|
import org.apache.activemq.artemis.core.server.cluster.ha.SharedStoreSlavePolicy;
|
||||||
import org.apache.activemq.artemis.core.server.group.GroupingHandler;
|
import org.apache.activemq.artemis.core.server.group.GroupingHandler;
|
||||||
|
@ -253,15 +255,29 @@ public final class SharedStoreBackupActivation extends Activation {
|
||||||
BackupTopologyListener backupListener;
|
BackupTopologyListener backupListener;
|
||||||
|
|
||||||
FailbackChecker() {
|
FailbackChecker() {
|
||||||
TransportConfiguration connector = activeMQServer.getClusterManager().getDefaultConnection(null).getConnector();
|
ClusterManager clusterManager = activeMQServer.getClusterManager();
|
||||||
backupListener = new BackupTopologyListener(activeMQServer.getNodeID().toString(), connector);
|
if (clusterManager != null) {
|
||||||
activeMQServer.getClusterManager().getDefaultConnection(null).addClusterTopologyListener(backupListener);
|
ClusterConnection clusterConnection = clusterManager.getDefaultConnection(null);
|
||||||
|
if (clusterConnection != null) {
|
||||||
|
TransportConfiguration connector = clusterConnection.getConnector();
|
||||||
|
if (connector != null) {
|
||||||
|
backupListener = new BackupTopologyListener(activeMQServer.getNodeID().toString(), connector);
|
||||||
|
clusterConnection.addClusterTopologyListener(backupListener);
|
||||||
|
} else {
|
||||||
|
ActiveMQServerLogger.LOGGER.failBackCheckerFailure("connector");
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
ActiveMQServerLogger.LOGGER.failBackCheckerFailure("cluster connection");
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
ActiveMQServerLogger.LOGGER.failBackCheckerFailure("cluster manager");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
try {
|
try {
|
||||||
if (!restarting.get() && activeMQServer.getNodeManager().isAwaitingFailback() && backupListener.waitForBackup()) {
|
if (!restarting.get() && activeMQServer.getNodeManager().isAwaitingFailback() && backupListener != null && backupListener.waitForBackup()) {
|
||||||
if (!restarting.compareAndSet(false, true)) {
|
if (!restarting.compareAndSet(false, true)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue