This commit is contained in:
Clebert Suconic 2020-04-17 18:26:22 -04:00
commit 85f26ce147
4 changed files with 32 additions and 12 deletions

View File

@ -92,6 +92,9 @@ public class ClusterController implements ActiveMQComponent {
@Override @Override
public void start() throws Exception { public void start() throws Exception {
if (logger.isDebugEnabled()) {
logger.debug("Starting Cluster Controller " + System.identityHashCode(this) + " for server " + server);
}
if (started) if (started)
return; return;
//set the default locator that will be used to connecting to the default cluster. //set the default locator that will be used to connecting to the default cluster.
@ -129,13 +132,17 @@ public class ClusterController implements ActiveMQComponent {
@Override @Override
public void stop() throws Exception { 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 //close all the locators
for (ServerLocatorInternal serverLocatorInternal : locators.values()) { for (ServerLocatorInternal serverLocatorInternal : locators.values()) {
serverLocatorInternal.close(); serverLocatorInternal.close();
} }
//stop the quorum manager //stop the quorum manager
quorumManager.stop(); quorumManager.stop();
started = false;
} }
@Override @Override
@ -428,14 +435,20 @@ public class ClusterController implements ActiveMQComponent {
@Override @Override
public void run() { public void run() {
try { try {
serverLocator.connect(); if (started) {
if (serverLocator == replicationLocator) { serverLocator.connect();
replicationClusterConnectedLatch.countDown(); if (serverLocator == replicationLocator) {
replicationClusterConnectedLatch.countDown();
}
} }
} catch (ActiveMQException e) { } catch (ActiveMQException e) {
if (!started) { if (!started) {
return; return;
} }
if (logger.isDebugEnabled()) {
logger.debug("retry on Cluster Controller " + System.identityHashCode(ClusterController.this) + " server = " + server);
}
server.getScheduledPool().schedule(this, serverLocator.getRetryInterval(), TimeUnit.MILLISECONDS); server.getScheduledPool().schedule(this, serverLocator.getRetryInterval(), TimeUnit.MILLISECONDS);
} }
} }

View File

@ -1059,7 +1059,9 @@ public class ActiveMQServerImpl implements ActiveMQServer {
*/ */
void stop(boolean failoverOnServerShutdown, final boolean criticalIOError, boolean restarting, boolean isShutdown) { 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) { synchronized (this) {
if (state == SERVER_STATE.STOPPED || state == SERVER_STATE.STOPPING) { if (state == SERVER_STATE.STOPPED || state == SERVER_STATE.STOPPING) {
@ -3899,7 +3901,9 @@ public class ActiveMQServerImpl implements ActiveMQServer {
public void run() { public void run() {
lockActivation(); lockActivation();
try { try {
runnable.run(); if (state != SERVER_STATE.STOPPED && state != SERVER_STATE.STOPPING) {
runnable.run();
}
} finally { } finally {
unlockActivation(); unlockActivation();
} }

View File

@ -275,8 +275,11 @@ public final class SharedNothingBackupActivation extends Activation {
if (logger.isTraceEnabled()) { if (logger.isTraceEnabled()) {
logger.trace("Calling activeMQServer.stop() and start() to restart the server"); logger.trace("Calling activeMQServer.stop() and start() to restart the server");
} }
activeMQServer.stop(); if (activeMQServer.getState() != ActiveMQServer.SERVER_STATE.STOPPED &&
activeMQServer.start(); activeMQServer.getState() != ActiveMQServer.SERVER_STATE.STOPPING) {
activeMQServer.stop();
activeMQServer.start();
}
} catch (Exception e) { } catch (Exception e) {
ActiveMQServerLogger.LOGGER.errorRestartingBackupServer(e, activeMQServer); ActiveMQServerLogger.LOGGER.errorRestartingBackupServer(e, activeMQServer);
} }

View File

@ -44,7 +44,8 @@ public class BackupAuthenticationTest extends FailoverTestBase {
} }
@Test @Test
public void testPasswordSetting() throws Exception { public void testWrongPasswordSetting() throws Exception {
Wait.assertTrue(liveServer.getServer()::isActive);
waitForServerToStart(liveServer.getServer()); waitForServerToStart(liveServer.getServer());
backupServer.start(); backupServer.start();
assertTrue(latch.await(5, TimeUnit.SECONDS)); assertTrue(latch.await(5, TimeUnit.SECONDS));
@ -54,9 +55,8 @@ public class BackupAuthenticationTest extends FailoverTestBase {
*/ */
Wait.waitFor(() -> !backupServer.isStarted()); Wait.waitFor(() -> !backupServer.isStarted());
assertFalse("backup should have stopped", backupServer.isStarted()); assertFalse("backup should have stopped", backupServer.isStarted());
backupConfig.setClusterPassword(CLUSTER_PASSWORD); backupServer.stop();
backupServer.start(); liveServer.stop();
waitForRemoteBackup(null, 5, true, backupServer.getServer());
} }
@Override @Override