Skip to content

Commit

Permalink
ARTEMIS-1737 fix for inaccessible slave console after failover
Browse files Browse the repository at this point in the history
  • Loading branch information
sknot-rh committed Mar 8, 2018
1 parent 911072e commit 60510ca
Show file tree
Hide file tree
Showing 5 changed files with 47 additions and 1 deletion.
Expand Up @@ -432,6 +432,8 @@ void destroyQueue(SimpleString queueName,

void fail(boolean failoverOnServerShutdown) throws Exception;

void backToBackup(boolean failoverOnServerShutdown) throws Exception;

Queue updateQueue(String name,
RoutingType routingType,
Integer maxConsumers,
Expand Down Expand Up @@ -472,6 +474,8 @@ Queue updateQueue(String name,

void addExternalComponent(ActiveMQComponent externalComponent);

List<ActiveMQComponent> getExternalComponents();

boolean addClientConnection(String clientId, boolean unique);

void removeClientConnection(String clientId);
Expand Down
Expand Up @@ -915,6 +915,11 @@ public final void fail(boolean failoverOnServerShutdown) throws Exception {
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 {
stop(failoverOnServerShutdown, false, false, isExit);
}
Expand Down Expand Up @@ -3124,4 +3129,9 @@ public void reload(URL uri) throws Exception {
public Set<ActivateCallback> getActivateCallbacks() {
return activateCallbacks;
}

@Override
public List<ActiveMQComponent> getExternalComponents() {
return externalComponents;
}
}
Expand Up @@ -187,7 +187,7 @@ public void run() {
clusterConnection.addClusterTopologyListener(listener1);
if (listener1.waitForBackup()) {
//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();
// activeMQServer.moveServerData(replicatedPolicy.getReplicaPolicy().getMaxSavedReplicatedJournalsSize());
activeMQServer.setHAPolicy(replicatedPolicy.getReplicaPolicy());
Expand Down
6 changes: 6 additions & 0 deletions tests/integration-tests/pom.xml
Expand Up @@ -275,6 +275,12 @@
<artifactId>slf4j-api</artifactId>
<version>1.7.5</version>
</dependency>
<dependency>
<groupId>org.apache.activemq</groupId>
<artifactId>artemis-web</artifactId>
<version>${project.version}</version>
<scope>test</scope>
</dependency>

<!-- DB Test Deps -->
<dependency>
Expand Down
Expand Up @@ -16,12 +16,17 @@
*/
package org.apache.activemq.artemis.tests.integration.cluster.failover;

import java.util.ArrayList;
import java.util.concurrent.TimeUnit;

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.ReplicatedPolicyConfiguration;
import org.apache.activemq.artemis.core.server.ServiceComponent;
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.Test;
import org.junit.rules.TestRule;
Expand Down Expand Up @@ -125,6 +130,27 @@ protected void beforeWaitForRemoteBackupSynchronization() {
}
}

@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
protected void createConfigs() throws Exception {
createReplicatedConfigs();
Expand Down

0 comments on commit 60510ca

Please sign in to comment.