ARTEMIS-1737 fix for inaccessible slave console after failover

This commit is contained in:
Stanislav Knot 2018-03-08 11:03:37 +01:00 committed by Clebert Suconic
parent 27a4a1dfc5
commit dc096f950d
5 changed files with 47 additions and 1 deletions

View File

@ -432,6 +432,8 @@ public interface ActiveMQServer extends ServiceComponent {
void fail(boolean failoverOnServerShutdown) throws Exception; void fail(boolean failoverOnServerShutdown) throws Exception;
void backToBackup(boolean failoverOnServerShutdown) throws Exception;
Queue updateQueue(String name, Queue updateQueue(String name,
RoutingType routingType, RoutingType routingType,
Integer maxConsumers, Integer maxConsumers,
@ -472,6 +474,8 @@ public interface ActiveMQServer extends ServiceComponent {
void addExternalComponent(ActiveMQComponent externalComponent); void addExternalComponent(ActiveMQComponent externalComponent);
List<ActiveMQComponent> getExternalComponents();
boolean addClientConnection(String clientId, boolean unique); boolean addClientConnection(String clientId, boolean unique);
void removeClientConnection(String clientId); void removeClientConnection(String clientId);

View File

@ -915,6 +915,11 @@ public class ActiveMQServerImpl implements ActiveMQServer {
stop(failoverOnServerShutdown, false, false, true); stop(failoverOnServerShutdown, false, false, true);
} }
@Override
public final void backToBackup(boolean failoverOnServerShutdown) throws Exception {
stop(failoverOnServerShutdown, false, false, false);
}
public final void stop(boolean failoverOnServerShutdown, boolean isExit) throws Exception { public final void stop(boolean failoverOnServerShutdown, boolean isExit) throws Exception {
stop(failoverOnServerShutdown, false, false, isExit); stop(failoverOnServerShutdown, false, false, isExit);
} }
@ -3124,4 +3129,9 @@ public class ActiveMQServerImpl implements ActiveMQServer {
public Set<ActivateCallback> getActivateCallbacks() { public Set<ActivateCallback> getActivateCallbacks() {
return activateCallbacks; return activateCallbacks;
} }
@Override
public List<ActiveMQComponent> getExternalComponents() {
return externalComponents;
}
} }

View File

@ -187,7 +187,7 @@ public class SharedNothingLiveActivation extends LiveActivation {
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
activeMQServer.fail(true); activeMQServer.backToBackup(true);
ActiveMQServerLogger.LOGGER.restartingReplicatedBackupAfterFailback(); ActiveMQServerLogger.LOGGER.restartingReplicatedBackupAfterFailback();
// activeMQServer.moveServerData(replicatedPolicy.getReplicaPolicy().getMaxSavedReplicatedJournalsSize()); // activeMQServer.moveServerData(replicatedPolicy.getReplicaPolicy().getMaxSavedReplicatedJournalsSize());
activeMQServer.setHAPolicy(replicatedPolicy.getReplicaPolicy()); activeMQServer.setHAPolicy(replicatedPolicy.getReplicaPolicy());

View File

@ -275,6 +275,12 @@
<artifactId>slf4j-api</artifactId> <artifactId>slf4j-api</artifactId>
<version>1.7.5</version> <version>1.7.5</version>
</dependency> </dependency>
<dependency>
<groupId>org.apache.activemq</groupId>
<artifactId>artemis-web</artifactId>
<version>${project.version}</version>
<scope>test</scope>
</dependency>
<!-- DB Test Deps --> <!-- DB Test Deps -->
<dependency> <dependency>

View File

@ -16,12 +16,17 @@
*/ */
package org.apache.activemq.artemis.tests.integration.cluster.failover; package org.apache.activemq.artemis.tests.integration.cluster.failover;
import java.util.ArrayList;
import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeUnit;
import org.apache.activemq.artemis.api.core.client.ClientSession; import org.apache.activemq.artemis.api.core.client.ClientSession;
import org.apache.activemq.artemis.component.WebServerComponent;
import org.apache.activemq.artemis.core.config.ha.ReplicaPolicyConfiguration; import org.apache.activemq.artemis.core.config.ha.ReplicaPolicyConfiguration;
import org.apache.activemq.artemis.core.config.ha.ReplicatedPolicyConfiguration; import org.apache.activemq.artemis.core.config.ha.ReplicatedPolicyConfiguration;
import org.apache.activemq.artemis.core.server.ServiceComponent;
import org.apache.activemq.artemis.core.server.cluster.ha.ReplicatedPolicy; import org.apache.activemq.artemis.core.server.cluster.ha.ReplicatedPolicy;
import org.apache.activemq.artemis.dto.AppDTO;
import org.apache.activemq.artemis.dto.WebServerDTO;
import org.junit.Rule; import org.junit.Rule;
import org.junit.Test; import org.junit.Test;
import org.junit.rules.TestRule; import org.junit.rules.TestRule;
@ -125,6 +130,27 @@ public class ReplicatedFailoverTest extends FailoverTest {
} }
} }
@Test
public void testReplicatedFailbackBackupFromLiveBackToBackup() throws Exception {
WebServerDTO wdto = new WebServerDTO();
AppDTO appDTO = new AppDTO();
appDTO.war = "console.war";
appDTO.url = "console";
wdto.apps = new ArrayList<AppDTO>();
wdto.apps.add(appDTO);
wdto.bind = "http://localhost:0";
wdto.path = "console";
WebServerComponent webServerComponent = new WebServerComponent();
webServerComponent.configure(wdto, ".", ".");
webServerComponent.start();
backupServer.getServer().addExternalComponent(webServerComponent);
// this is called when backup servers go from live back to backup
backupServer.getServer().backToBackup(true);
assertTrue(backupServer.getServer().getExternalComponents().get(0).isStarted());
((ServiceComponent)(backupServer.getServer().getExternalComponents().get(0))).stop(true);
}
@Override @Override
protected void createConfigs() throws Exception { protected void createConfigs() throws Exception {
createReplicatedConfigs(); createReplicatedConfigs();