Search in sources :

Example 11 with TopologyMemberImpl

use of org.apache.activemq.artemis.core.client.impl.TopologyMemberImpl in project activemq-artemis by apache.

the class GroupingFailoverTestBase method waitForBackupTopologyAnnouncement.

public void waitForBackupTopologyAnnouncement(ClientSessionFactory sf) throws Exception {
    long start = System.currentTimeMillis();
    ServerLocator locator = sf.getServerLocator();
    do {
        Collection<TopologyMemberImpl> members = locator.getTopology().getMembers();
        for (TopologyMemberImpl member : members) {
            if (member.getBackup() != null) {
                return;
            }
        }
        Thread.sleep(10);
    } while (System.currentTimeMillis() - start < ActiveMQTestBase.WAIT_TIMEOUT);
    throw new IllegalStateException("Timed out waiting for backup announce");
}
Also used : TopologyMemberImpl(org.apache.activemq.artemis.core.client.impl.TopologyMemberImpl) ServerLocator(org.apache.activemq.artemis.api.core.client.ServerLocator)

Example 12 with TopologyMemberImpl

use of org.apache.activemq.artemis.core.client.impl.TopologyMemberImpl in project activemq-artemis by apache.

the class IsolatedTopologyTest method checkTopology.

private void checkTopology(final ActiveMQServer serverParameter, final String clusterName, final String nodeId1, final String nodeId2, final TransportConfiguration cfg1, final TransportConfiguration cfg2) {
    Topology topology = serverParameter.getClusterManager().getClusterConnection(clusterName).getTopology();
    TopologyMemberImpl member1 = topology.getMember(nodeId1);
    TopologyMemberImpl member2 = topology.getMember(nodeId2);
    Assert.assertEquals(member1.getLive().getParams().toString(), cfg1.getParams().toString());
    Assert.assertEquals(member2.getLive().getParams().toString(), cfg2.getParams().toString());
}
Also used : TopologyMemberImpl(org.apache.activemq.artemis.core.client.impl.TopologyMemberImpl) Topology(org.apache.activemq.artemis.core.client.impl.Topology)

Example 13 with TopologyMemberImpl

use of org.apache.activemq.artemis.core.client.impl.TopologyMemberImpl in project activemq-artemis by apache.

the class AutomaticColocatedQuorumVoteTest method testSimpleDistributionBackupStrategyScaleDown.

@Test
public void testSimpleDistributionBackupStrategyScaleDown() throws Exception {
    ActiveMQServer server0 = createServer(0, 1, true);
    ActiveMQServer server1 = createServer(1, 0, true);
    TransportConfiguration liveConnector0 = getConnectorTransportConfiguration("liveConnector" + 0, 0);
    TransportConfiguration liveConnector1 = getConnectorTransportConfiguration("liveConnector" + 1, 1);
    try (ServerLocator serverLocator = ActiveMQClient.createServerLocatorWithoutHA(liveConnector0)) {
        server0.start();
        server1.start();
        ClientSessionFactory sessionFactory0 = serverLocator.createSessionFactory(liveConnector0);
        waitForRemoteBackup(sessionFactory0, 10);
        ClientSessionFactory sessionFactory1 = serverLocator.createSessionFactory(liveConnector1);
        waitForRemoteBackup(sessionFactory1, 10);
        Topology topology = serverLocator.getTopology();
        Collection<TopologyMemberImpl> members = topology.getMembers();
        Assert.assertEquals(members.size(), 2);
        Map<String, ActiveMQServer> backupServers0 = server0.getClusterManager().getHAManager().getBackupServers();
        Assert.assertEquals(backupServers0.size(), 1);
        Map<String, ActiveMQServer> backupServers1 = server1.getClusterManager().getHAManager().getBackupServers();
        Assert.assertEquals(backupServers1.size(), 1);
        ActiveMQServer backupServer0 = backupServers0.values().iterator().next();
        ActiveMQServer backupServer1 = backupServers1.values().iterator().next();
        waitForRemoteBackupSynchronization(backupServer0);
        waitForRemoteBackupSynchronization(backupServer1);
        Assert.assertEquals(server0.getNodeID(), backupServer1.getNodeID());
        Assert.assertEquals(server1.getNodeID(), backupServer0.getNodeID());
        Set<TransportConfiguration> backupAcceptors0 = backupServer0.getConfiguration().getAcceptorConfigurations();
        Assert.assertEquals(0, backupAcceptors0.size());
        Set<TransportConfiguration> backupAcceptors1 = backupServer1.getConfiguration().getAcceptorConfigurations();
        Assert.assertEquals(0, backupAcceptors1.size());
        Map<String, TransportConfiguration> connectorConfigurations0 = backupServer0.getConfiguration().getConnectorConfigurations();
        Assert.assertEquals(2, connectorConfigurations0.size());
        Assert.assertEquals("61616", connectorConfigurations0.get("liveConnector0").getParams().get("port"));
        Assert.assertEquals("61617", connectorConfigurations0.get("remoteConnector0").getParams().get("port"));
        Map<String, TransportConfiguration> connectorConfigurations1 = backupServer1.getConfiguration().getConnectorConfigurations();
        Assert.assertEquals(2, connectorConfigurations1.size());
        Assert.assertEquals("61617", connectorConfigurations1.get("liveConnector1").getParams().get("port"));
        Assert.assertEquals("61616", connectorConfigurations1.get("remoteConnector1").getParams().get("port"));
        if (!replicated) {
            Assert.assertEquals(server0.getConfiguration().getJournalDirectory(), backupServer1.getConfiguration().getJournalDirectory());
            Assert.assertEquals(server0.getConfiguration().getBindingsDirectory(), backupServer1.getConfiguration().getBindingsDirectory());
            Assert.assertEquals(server0.getConfiguration().getLargeMessagesDirectory(), backupServer1.getConfiguration().getLargeMessagesDirectory());
            Assert.assertEquals(server0.getConfiguration().getPagingDirectory(), backupServer1.getConfiguration().getPagingDirectory());
            Assert.assertEquals(server1.getConfiguration().getJournalDirectory(), backupServer0.getConfiguration().getJournalDirectory());
            Assert.assertEquals(server1.getConfiguration().getBindingsDirectory(), backupServer0.getConfiguration().getBindingsDirectory());
            Assert.assertEquals(server1.getConfiguration().getLargeMessagesDirectory(), backupServer0.getConfiguration().getLargeMessagesDirectory());
            Assert.assertEquals(server1.getConfiguration().getPagingDirectory(), backupServer0.getConfiguration().getPagingDirectory());
        } else {
            Assert.assertNotEquals(server0.getConfiguration().getJournalDirectory(), backupServer1.getConfiguration().getJournalDirectory());
            Assert.assertNotEquals(server0.getConfiguration().getBindingsDirectory(), backupServer1.getConfiguration().getBindingsDirectory());
            Assert.assertNotEquals(server0.getConfiguration().getLargeMessagesDirectory(), backupServer1.getConfiguration().getLargeMessagesDirectory());
            Assert.assertNotEquals(server0.getConfiguration().getPagingDirectory(), backupServer1.getConfiguration().getPagingDirectory());
            Assert.assertNotEquals(server1.getConfiguration().getJournalDirectory(), backupServer0.getConfiguration().getJournalDirectory());
            Assert.assertNotEquals(server1.getConfiguration().getBindingsDirectory(), backupServer0.getConfiguration().getBindingsDirectory());
            Assert.assertNotEquals(server1.getConfiguration().getLargeMessagesDirectory(), backupServer0.getConfiguration().getLargeMessagesDirectory());
            Assert.assertNotEquals(server1.getConfiguration().getPagingDirectory(), backupServer0.getConfiguration().getPagingDirectory());
        }
    } finally {
        try {
            server0.stop();
        } catch (Throwable e) {
            e.printStackTrace();
        }
        server1.stop();
    }
}
Also used : ActiveMQServer(org.apache.activemq.artemis.core.server.ActiveMQServer) TopologyMemberImpl(org.apache.activemq.artemis.core.client.impl.TopologyMemberImpl) TransportConfiguration(org.apache.activemq.artemis.api.core.TransportConfiguration) ClientSessionFactory(org.apache.activemq.artemis.api.core.client.ClientSessionFactory) Topology(org.apache.activemq.artemis.core.client.impl.Topology) ServerLocator(org.apache.activemq.artemis.api.core.client.ServerLocator) Test(org.junit.Test)

Example 14 with TopologyMemberImpl

use of org.apache.activemq.artemis.core.client.impl.TopologyMemberImpl in project activemq-artemis by apache.

the class AutomaticColocatedQuorumVoteTest method testSimpleDistributionBackupStrategyFull.

@Test
public void testSimpleDistributionBackupStrategyFull() throws Exception {
    ActiveMQServer server0 = createServer(0, 1, false);
    ActiveMQServer server1 = createServer(1, 0, false);
    TransportConfiguration liveConnector0 = getConnectorTransportConfiguration("liveConnector" + 0, 0);
    TransportConfiguration liveConnector1 = getConnectorTransportConfiguration("liveConnector" + 1, 1);
    try (ServerLocator serverLocator = ActiveMQClient.createServerLocatorWithoutHA(liveConnector0)) {
        server0.start();
        server1.start();
        ClientSessionFactory sessionFactory0 = serverLocator.createSessionFactory(liveConnector0);
        waitForRemoteBackup(sessionFactory0, 10);
        ClientSessionFactory sessionFactory1 = serverLocator.createSessionFactory(liveConnector1);
        waitForRemoteBackup(sessionFactory1, 10);
        Topology topology = serverLocator.getTopology();
        Collection<TopologyMemberImpl> members = topology.getMembers();
        Assert.assertEquals(members.size(), 2);
        Map<String, ActiveMQServer> backupServers0 = server0.getClusterManager().getHAManager().getBackupServers();
        Assert.assertEquals(backupServers0.size(), 1);
        Map<String, ActiveMQServer> backupServers1 = server1.getClusterManager().getHAManager().getBackupServers();
        Assert.assertEquals(backupServers1.size(), 1);
        ActiveMQServer backupServer0 = backupServers0.values().iterator().next();
        ActiveMQServer backupServer1 = backupServers1.values().iterator().next();
        waitForRemoteBackupSynchronization(backupServer0);
        waitForRemoteBackupSynchronization(backupServer1);
        Assert.assertEquals(server0.getNodeID(), backupServer1.getNodeID());
        Assert.assertEquals(server1.getNodeID(), backupServer0.getNodeID());
        Set<TransportConfiguration> backupAcceptors0 = backupServer0.getConfiguration().getAcceptorConfigurations();
        Assert.assertEquals(1, backupAcceptors0.size());
        Assert.assertEquals("61716", backupAcceptors0.iterator().next().getParams().get("port"));
        Set<TransportConfiguration> backupAcceptors1 = backupServer1.getConfiguration().getAcceptorConfigurations();
        Assert.assertEquals(1, backupAcceptors1.size());
        Assert.assertEquals("61717", backupAcceptors1.iterator().next().getParams().get("port"));
        Map<String, TransportConfiguration> connectorConfigurations0 = backupServer0.getConfiguration().getConnectorConfigurations();
        Assert.assertEquals(2, connectorConfigurations0.size());
        Assert.assertEquals("61716", connectorConfigurations0.get("liveConnector0").getParams().get("port"));
        Assert.assertEquals("61617", connectorConfigurations0.get("remoteConnector0").getParams().get("port"));
        Map<String, TransportConfiguration> connectorConfigurations1 = backupServer1.getConfiguration().getConnectorConfigurations();
        Assert.assertEquals(2, connectorConfigurations1.size());
        Assert.assertEquals("61717", connectorConfigurations1.get("liveConnector1").getParams().get("port"));
        Assert.assertEquals("61616", connectorConfigurations1.get("remoteConnector1").getParams().get("port"));
        if (!replicated) {
            Assert.assertEquals(server0.getConfiguration().getJournalDirectory(), backupServer1.getConfiguration().getJournalDirectory());
            Assert.assertEquals(server0.getConfiguration().getBindingsDirectory(), backupServer1.getConfiguration().getBindingsDirectory());
            Assert.assertEquals(server0.getConfiguration().getLargeMessagesDirectory(), backupServer1.getConfiguration().getLargeMessagesDirectory());
            Assert.assertEquals(server0.getConfiguration().getPagingDirectory(), backupServer1.getConfiguration().getPagingDirectory());
            Assert.assertEquals(server1.getConfiguration().getJournalDirectory(), backupServer0.getConfiguration().getJournalDirectory());
            Assert.assertEquals(server1.getConfiguration().getBindingsDirectory(), backupServer0.getConfiguration().getBindingsDirectory());
            Assert.assertEquals(server1.getConfiguration().getLargeMessagesDirectory(), backupServer0.getConfiguration().getLargeMessagesDirectory());
            Assert.assertEquals(server1.getConfiguration().getPagingDirectory(), backupServer0.getConfiguration().getPagingDirectory());
        } else {
            Assert.assertNotEquals(server0.getConfiguration().getJournalDirectory(), backupServer1.getConfiguration().getJournalDirectory());
            Assert.assertNotEquals(server0.getConfiguration().getBindingsDirectory(), backupServer1.getConfiguration().getBindingsDirectory());
            Assert.assertNotEquals(server0.getConfiguration().getLargeMessagesDirectory(), backupServer1.getConfiguration().getLargeMessagesDirectory());
            Assert.assertNotEquals(server0.getConfiguration().getPagingDirectory(), backupServer1.getConfiguration().getPagingDirectory());
            Assert.assertNotEquals(server1.getConfiguration().getJournalDirectory(), backupServer0.getConfiguration().getJournalDirectory());
            Assert.assertNotEquals(server1.getConfiguration().getBindingsDirectory(), backupServer0.getConfiguration().getBindingsDirectory());
            Assert.assertNotEquals(server1.getConfiguration().getLargeMessagesDirectory(), backupServer0.getConfiguration().getLargeMessagesDirectory());
            Assert.assertNotEquals(server1.getConfiguration().getPagingDirectory(), backupServer0.getConfiguration().getPagingDirectory());
        }
    } finally {
        try {
            server0.stop();
        } catch (Throwable e) {
            e.printStackTrace();
        }
        server1.stop();
    }
}
Also used : ActiveMQServer(org.apache.activemq.artemis.core.server.ActiveMQServer) TopologyMemberImpl(org.apache.activemq.artemis.core.client.impl.TopologyMemberImpl) TransportConfiguration(org.apache.activemq.artemis.api.core.TransportConfiguration) ClientSessionFactory(org.apache.activemq.artemis.api.core.client.ClientSessionFactory) Topology(org.apache.activemq.artemis.core.client.impl.Topology) ServerLocator(org.apache.activemq.artemis.api.core.client.ServerLocator) Test(org.junit.Test)

Example 15 with TopologyMemberImpl

use of org.apache.activemq.artemis.core.client.impl.TopologyMemberImpl in project activemq-artemis by apache.

the class ClusterTestBase method logTopologyDiagram.

private void logTopologyDiagram() {
    StringBuffer topologyDiagram = new StringBuffer();
    for (ActiveMQServer activeMQServer : servers) {
        if (activeMQServer != null) {
            topologyDiagram.append("\n").append(activeMQServer.getIdentity()).append("\n");
            if (activeMQServer.isStarted()) {
                Set<ClusterConnection> ccs = activeMQServer.getClusterManager().getClusterConnections();
                if (ccs.size() >= 1) {
                    ClusterConnectionImpl clusterConnection = (ClusterConnectionImpl) ccs.iterator().next();
                    Collection<TopologyMemberImpl> members = clusterConnection.getTopology().getMembers();
                    for (TopologyMemberImpl member : members) {
                        String nodeId = member.getNodeId();
                        String liveServer = null;
                        String backupServer = null;
                        for (ActiveMQServer server : servers) {
                            if (server != null && server.getNodeID() != null && server.isActive() && server.getNodeID().toString().equals(nodeId)) {
                                if (server.isActive()) {
                                    liveServer = server.getIdentity();
                                    if (member.getLive() != null) {
                                        liveServer += "(notified)";
                                    } else {
                                        liveServer += "(not notified)";
                                    }
                                } else {
                                    backupServer = server.getIdentity();
                                    if (member.getBackup() != null) {
                                        liveServer += "(notified)";
                                    } else {
                                        liveServer += "(not notified)";
                                    }
                                }
                            }
                        }
                        topologyDiagram.append("\t").append("|\n").append("\t->").append(liveServer).append("/").append(backupServer).append("\n");
                    }
                } else {
                    topologyDiagram.append("-> no cluster connections\n");
                }
            } else {
                topologyDiagram.append("-> stopped\n");
            }
        }
    }
    topologyDiagram.append("\n");
    log.info(topologyDiagram.toString());
}
Also used : ActiveMQServer(org.apache.activemq.artemis.core.server.ActiveMQServer) TopologyMemberImpl(org.apache.activemq.artemis.core.client.impl.TopologyMemberImpl) ClusterConnection(org.apache.activemq.artemis.core.server.cluster.ClusterConnection) SimpleString(org.apache.activemq.artemis.api.core.SimpleString) ClusterConnectionImpl(org.apache.activemq.artemis.core.server.cluster.impl.ClusterConnectionImpl)

Aggregations

TopologyMemberImpl (org.apache.activemq.artemis.core.client.impl.TopologyMemberImpl)16 TransportConfiguration (org.apache.activemq.artemis.api.core.TransportConfiguration)9 Topology (org.apache.activemq.artemis.core.client.impl.Topology)9 ActiveMQServer (org.apache.activemq.artemis.core.server.ActiveMQServer)7 ClusterConnection (org.apache.activemq.artemis.core.server.cluster.ClusterConnection)6 SimpleString (org.apache.activemq.artemis.api.core.SimpleString)5 ClientSessionFactory (org.apache.activemq.artemis.api.core.client.ClientSessionFactory)4 ServerLocator (org.apache.activemq.artemis.api.core.client.ServerLocator)4 ActiveMQException (org.apache.activemq.artemis.api.core.ActiveMQException)3 ClusterConnectionImpl (org.apache.activemq.artemis.core.server.cluster.impl.ClusterConnectionImpl)3 Test (org.junit.Test)3 ArrayList (java.util.ArrayList)2 ClusterManager (org.apache.activemq.artemis.core.server.cluster.ClusterManager)2 IOException (java.io.IOException)1 URISyntaxException (java.net.URISyntaxException)1 SQLException (java.sql.SQLException)1 JMSException (javax.jms.JMSException)1 JsonArrayBuilder (javax.json.JsonArrayBuilder)1 JsonObjectBuilder (javax.json.JsonObjectBuilder)1 XAException (javax.transaction.xa.XAException)1