diff --git a/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/cluster/ClusterController.java b/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/cluster/ClusterController.java index 42fcf75c0e..d6d948e88b 100644 --- a/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/cluster/ClusterController.java +++ b/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/cluster/ClusterController.java @@ -92,6 +92,9 @@ public class ClusterController implements ActiveMQComponent { @Override public void start() throws Exception { + if (logger.isDebugEnabled()) { + logger.debug("Starting Cluster Controller " + System.identityHashCode(this) + " for server " + server); + } if (started) return; //set the default locator that will be used to connecting to the default cluster. @@ -129,13 +132,17 @@ public class ClusterController implements ActiveMQComponent { @Override public void stop() throws Exception { + if (logger.isDebugEnabled()) { + + logger.debug("Stopping Cluster Controller " + System.identityHashCode(this) + " for server " + this.server); + } + started = false; //close all the locators for (ServerLocatorInternal serverLocatorInternal : locators.values()) { serverLocatorInternal.close(); } //stop the quorum manager quorumManager.stop(); - started = false; } @Override @@ -428,14 +435,20 @@ public class ClusterController implements ActiveMQComponent { @Override public void run() { try { - serverLocator.connect(); - if (serverLocator == replicationLocator) { - replicationClusterConnectedLatch.countDown(); + if (started) { + serverLocator.connect(); + if (serverLocator == replicationLocator) { + replicationClusterConnectedLatch.countDown(); + } } } catch (ActiveMQException e) { if (!started) { return; } + if (logger.isDebugEnabled()) { + + logger.debug("retry on Cluster Controller " + System.identityHashCode(ClusterController.this) + " server = " + server); + } server.getScheduledPool().schedule(this, serverLocator.getRetryInterval(), TimeUnit.MILLISECONDS); } } 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 8e5af5b65e..798d7d9a69 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 @@ -1059,7 +1059,9 @@ public class ActiveMQServerImpl implements ActiveMQServer { */ void stop(boolean failoverOnServerShutdown, final boolean criticalIOError, boolean restarting, boolean isShutdown) { - logger.debug("Stopping server"); + if (logger.isDebugEnabled()) { + logger.debug("Stopping server " + this); + } synchronized (this) { if (state == SERVER_STATE.STOPPED || state == SERVER_STATE.STOPPING) { @@ -3899,7 +3901,9 @@ public class ActiveMQServerImpl implements ActiveMQServer { public void run() { lockActivation(); try { - runnable.run(); + if (state != SERVER_STATE.STOPPED && state != SERVER_STATE.STOPPING) { + runnable.run(); + } } finally { unlockActivation(); } diff --git a/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/impl/SharedNothingBackupActivation.java b/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/impl/SharedNothingBackupActivation.java index 3c199d2594..36c9c9f8d8 100644 --- a/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/impl/SharedNothingBackupActivation.java +++ b/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/impl/SharedNothingBackupActivation.java @@ -275,8 +275,11 @@ public final class SharedNothingBackupActivation extends Activation { if (logger.isTraceEnabled()) { logger.trace("Calling activeMQServer.stop() and start() to restart the server"); } - activeMQServer.stop(); - activeMQServer.start(); + if (activeMQServer.getState() != ActiveMQServer.SERVER_STATE.STOPPED && + activeMQServer.getState() != ActiveMQServer.SERVER_STATE.STOPPING) { + activeMQServer.stop(); + activeMQServer.start(); + } } catch (Exception e) { ActiveMQServerLogger.LOGGER.errorRestartingBackupServer(e, activeMQServer); } diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/cluster/failover/BackupAuthenticationTest.java b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/cluster/failover/BackupAuthenticationTest.java index 822defd28a..de0ff593df 100644 --- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/cluster/failover/BackupAuthenticationTest.java +++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/cluster/failover/BackupAuthenticationTest.java @@ -44,7 +44,8 @@ public class BackupAuthenticationTest extends FailoverTestBase { } @Test - public void testPasswordSetting() throws Exception { + public void testWrongPasswordSetting() throws Exception { + Wait.assertTrue(liveServer.getServer()::isActive); waitForServerToStart(liveServer.getServer()); backupServer.start(); assertTrue(latch.await(5, TimeUnit.SECONDS)); @@ -54,9 +55,8 @@ public class BackupAuthenticationTest extends FailoverTestBase { */ Wait.waitFor(() -> !backupServer.isStarted()); assertFalse("backup should have stopped", backupServer.isStarted()); - backupConfig.setClusterPassword(CLUSTER_PASSWORD); - backupServer.start(); - waitForRemoteBackup(null, 5, true, backupServer.getServer()); + backupServer.stop(); + liveServer.stop(); } @Override