use of org.apache.activemq.artemis.core.server.impl.SharedNothingBackupActivation in project activemq-artemis by apache.
the class BackupSyncDelay method intercept.
@Override
public boolean intercept(Packet packet, RemotingConnection connection) throws ActiveMQException {
if (packet.getType() == PacketImpl.BACKUP_REGISTRATION) {
try {
SharedNothingBackupActivation activation = (SharedNothingBackupActivation) backup.getActivation();
ReplicationEndpoint repEnd = activation.getReplicationEndpoint();
handler.addSubHandler(repEnd);
Channel repChannel = repEnd.getChannel();
repChannel.setHandler(handler);
handler.setChannel(repChannel);
live.getRemotingService().removeIncomingInterceptor(this);
} catch (Exception e) {
throw new RuntimeException(e);
}
}
return true;
}
use of org.apache.activemq.artemis.core.server.impl.SharedNothingBackupActivation in project activemq-artemis by apache.
the class HAPolicyConfigurationTest method ReplicaTest3.
@Test
public void ReplicaTest3() throws Exception {
Configuration configuration = createConfiguration("replica-hapolicy-config3.xml");
ActiveMQServerImpl server = new ActiveMQServerImpl(configuration);
try {
server.start();
Activation activation = server.getActivation();
assertTrue(activation instanceof SharedNothingBackupActivation);
HAPolicy haPolicy = server.getHAPolicy();
assertTrue(haPolicy instanceof ReplicaPolicy);
ReplicaPolicy replicaPolicy = (ReplicaPolicy) haPolicy;
assertEquals(replicaPolicy.getGroupName(), "tiddles");
assertEquals(replicaPolicy.getMaxSavedReplicatedJournalsSize(), 22);
assertEquals(replicaPolicy.getClusterName(), "33rrrrr");
assertFalse(replicaPolicy.isRestartBackup());
ScaleDownPolicy scaleDownPolicy = replicaPolicy.getScaleDownPolicy();
assertNull(scaleDownPolicy);
} finally {
server.stop();
}
}
use of org.apache.activemq.artemis.core.server.impl.SharedNothingBackupActivation in project activemq-artemis by apache.
the class HAPolicyConfigurationTest method ReplicaTest.
@Test
public void ReplicaTest() throws Exception {
Configuration configuration = createConfiguration("replica-hapolicy-config.xml");
ActiveMQServerImpl server = new ActiveMQServerImpl(configuration);
try {
server.start();
Activation activation = server.getActivation();
assertTrue(activation instanceof SharedNothingBackupActivation);
HAPolicy haPolicy = server.getHAPolicy();
assertTrue(haPolicy instanceof ReplicaPolicy);
ReplicaPolicy replicaPolicy = (ReplicaPolicy) haPolicy;
assertEquals(replicaPolicy.getGroupName(), "tiddles");
assertEquals(replicaPolicy.getMaxSavedReplicatedJournalsSize(), 22);
assertEquals(replicaPolicy.getClusterName(), "33rrrrr");
assertFalse(replicaPolicy.isRestartBackup());
assertTrue(replicaPolicy.isAllowFailback());
assertEquals(replicaPolicy.getInitialReplicationSyncTimeout(), 9876);
ScaleDownPolicy scaleDownPolicy = replicaPolicy.getScaleDownPolicy();
assertNotNull(scaleDownPolicy);
assertEquals(scaleDownPolicy.getGroupName(), "boo!");
assertEquals(scaleDownPolicy.getDiscoveryGroup(), "wahey");
List<String> connectors = scaleDownPolicy.getConnectors();
assertNotNull(connectors);
assertEquals(connectors.size(), 0);
} finally {
server.stop();
}
}
use of org.apache.activemq.artemis.core.server.impl.SharedNothingBackupActivation in project activemq-artemis by apache.
the class GroupingFailoverTestBase method testGroupingLocalHandlerFailsMultipleGroups.
@Test
public void testGroupingLocalHandlerFailsMultipleGroups() throws Exception {
setupBackupServer(2, 0, isFileStorage(), isSharedStore(), isNetty());
setupLiveServer(0, isFileStorage(), isSharedStore(), isNetty(), false);
setupLiveServer(1, isFileStorage(), isSharedStore(), isNetty(), false);
setupClusterConnection("cluster0", "queues", MessageLoadBalancingType.ON_DEMAND, 1, isNetty(), 0, 1);
setupClusterConnection("cluster1", "queues", MessageLoadBalancingType.ON_DEMAND, 1, isNetty(), 1, 0);
setupClusterConnection("cluster0", "queues", MessageLoadBalancingType.ON_DEMAND, 1, isNetty(), 2, 1);
setUpGroupHandler(GroupingHandlerConfiguration.TYPE.LOCAL, 0);
setUpGroupHandler(GroupingHandlerConfiguration.TYPE.REMOTE, 1);
setUpGroupHandler(GroupingHandlerConfiguration.TYPE.LOCAL, 2);
if (!isSharedStore()) {
((ReplicatedPolicyConfiguration) servers[0].getConfiguration().getHAPolicyConfiguration()).setGroupName("group1");
((ReplicatedPolicyConfiguration) servers[1].getConfiguration().getHAPolicyConfiguration()).setGroupName("group2");
((ReplicaPolicyConfiguration) servers[2].getConfiguration().getHAPolicyConfiguration()).setGroupName("group1");
}
startServers(0, 1, 2);
setupSessionFactory(0, isNetty());
setupSessionFactory(1, isNetty());
createQueue(0, "queues.testaddress", "queue0", null, true);
waitForBindings(0, "queues.testaddress", 1, 0, true);
createQueue(1, "queues.testaddress", "queue0", null, true);
waitForBindings(1, "queues.testaddress", 1, 0, true);
addConsumer(0, 0, "queue0", null);
addConsumer(1, 1, "queue0", null);
waitForBindings(0, "queues.testaddress", 1, 1, false);
waitForBindings(1, "queues.testaddress", 1, 1, false);
waitForBindings(0, "queues.testaddress", 1, 1, true);
waitForBindings(1, "queues.testaddress", 1, 1, true);
waitForTopology(servers[1], 2);
sendWithProperty(0, "queues.testaddress", 10, false, Message.HDR_GROUP_ID, new SimpleString("id1"));
sendWithProperty(0, "queues.testaddress", 10, false, Message.HDR_GROUP_ID, new SimpleString("id2"));
sendWithProperty(0, "queues.testaddress", 10, false, Message.HDR_GROUP_ID, new SimpleString("id3"));
sendWithProperty(0, "queues.testaddress", 10, false, Message.HDR_GROUP_ID, new SimpleString("id4"));
sendWithProperty(0, "queues.testaddress", 10, false, Message.HDR_GROUP_ID, new SimpleString("id5"));
sendWithProperty(0, "queues.testaddress", 10, false, Message.HDR_GROUP_ID, new SimpleString("id6"));
verifyReceiveAllWithGroupIDRoundRobin(0, 30, 0, 1);
if (!isSharedStore()) {
SharedNothingBackupActivation backupActivation = (SharedNothingBackupActivation) servers[2].getActivation();
assertTrue(backupActivation.waitForBackupSync(10, TimeUnit.SECONDS));
}
closeSessionFactory(0);
servers[0].fail(true);
waitForServerRestart(2);
setupSessionFactory(2, isNetty());
addConsumer(2, 2, "queue0", null);
waitForBindings(2, "queues.testaddress", 1, 1, true);
waitForBindings(2, "queues.testaddress", 1, 1, false);
waitForBindings(1, "queues.testaddress", 1, 1, true);
waitForBindings(1, "queues.testaddress", 1, 1, false);
sendWithProperty(2, "queues.testaddress", 10, false, Message.HDR_GROUP_ID, new SimpleString("id1"));
sendWithProperty(2, "queues.testaddress", 10, false, Message.HDR_GROUP_ID, new SimpleString("id2"));
sendWithProperty(2, "queues.testaddress", 10, false, Message.HDR_GROUP_ID, new SimpleString("id3"));
sendWithProperty(2, "queues.testaddress", 10, false, Message.HDR_GROUP_ID, new SimpleString("id4"));
sendWithProperty(2, "queues.testaddress", 10, false, Message.HDR_GROUP_ID, new SimpleString("id5"));
sendWithProperty(2, "queues.testaddress", 10, false, Message.HDR_GROUP_ID, new SimpleString("id6"));
verifyReceiveAllWithGroupIDRoundRobin(2, 30, 1, 2);
}
use of org.apache.activemq.artemis.core.server.impl.SharedNothingBackupActivation in project activemq-artemis by apache.
the class ActiveMQTestBase method waitForRemoteBackup.
/**
* @param sessionFactoryP
* @param seconds
* @param waitForSync
* @param backup
*/
public static final void waitForRemoteBackup(ClientSessionFactory sessionFactoryP, int seconds, boolean waitForSync, final ActiveMQServer backup) {
ClientSessionFactoryInternal sessionFactory = (ClientSessionFactoryInternal) sessionFactoryP;
final ActiveMQServerImpl actualServer = (ActiveMQServerImpl) backup;
final long toWait = seconds * 1000;
final long time = System.currentTimeMillis();
int loop = 0;
while (true) {
Activation activation = actualServer.getActivation();
boolean isReplicated = !backup.getHAPolicy().isSharedStore();
boolean isRemoteUpToDate = true;
if (isReplicated) {
if (activation instanceof SharedNothingBackupActivation) {
isRemoteUpToDate = backup.isReplicaSync();
} else {
// we may have already failed over and changed the Activation
if (actualServer.isStarted()) {
// let it fail a few time to have time to start stopping in the case of waiting to failback
isRemoteUpToDate = loop++ > 10;
} else {
// we could be waiting to failback or restart if the server is stopping
isRemoteUpToDate = false;
}
}
}
if ((sessionFactory == null || sessionFactory.getBackupConnector() != null) && (isRemoteUpToDate || !waitForSync) && (!waitForSync || actualServer.getBackupManager() != null && actualServer.getBackupManager().isBackupAnnounced())) {
break;
}
if (System.currentTimeMillis() > (time + toWait)) {
fail("backup started? (" + actualServer.isStarted() + "). Finished synchronizing (" + (activation) + "). SessionFactory!=null ? " + (sessionFactory != null) + " || sessionFactory.getBackupConnector()==" + (sessionFactory != null ? sessionFactory.getBackupConnector() : "not-applicable"));
}
try {
Thread.sleep(100);
} catch (InterruptedException e) {
fail(e.getMessage());
}
}
}
Aggregations