Search in sources :

Example 11 with ServerLocatorInternal

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

the class ServerLocatorConnectTest method testMultipleConnectorSingleServerNoConnect.

@Test
public void testMultipleConnectorSingleServerNoConnect() throws Exception {
    ServerLocatorInternal locator = (ServerLocatorInternal) ActiveMQClient.createServerLocatorWithoutHA(createTransportConfiguration(isNetty(), false, generateParams(1, isNetty())), createTransportConfiguration(isNetty(), false, generateParams(2, isNetty())), createTransportConfiguration(isNetty(), false, generateParams(3, isNetty())), createTransportConfiguration(isNetty(), false, generateParams(4, isNetty())), createTransportConfiguration(isNetty(), false, generateParams(5, isNetty())));
    ClientSessionFactoryInternal csf = null;
    try {
        csf = locator.connect();
    } catch (ActiveMQNotConnectedException nce) {
    // ok
    } catch (Exception e) {
        assertTrue(e instanceof ActiveMQException);
        fail("Invalid Exception type:" + ((ActiveMQException) e).getType());
    }
    assertNull(csf);
    locator.close();
}
Also used : ClientSessionFactoryInternal(org.apache.activemq.artemis.core.client.impl.ClientSessionFactoryInternal) ActiveMQException(org.apache.activemq.artemis.api.core.ActiveMQException) ActiveMQNotConnectedException(org.apache.activemq.artemis.api.core.ActiveMQNotConnectedException) ServerLocatorInternal(org.apache.activemq.artemis.core.client.impl.ServerLocatorInternal) ActiveMQNotConnectedException(org.apache.activemq.artemis.api.core.ActiveMQNotConnectedException) ActiveMQException(org.apache.activemq.artemis.api.core.ActiveMQException) Test(org.junit.Test)

Example 12 with ServerLocatorInternal

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

the class ClusterManager method stop.

@Override
public void stop() throws Exception {
    haManager.stop();
    synchronized (this) {
        if (state == State.STOPPED || state == State.STOPPING) {
            return;
        }
        state = State.STOPPING;
        clusterController.stop();
        for (BroadcastGroup group : broadcastGroups.values()) {
            group.stop();
            managementService.unregisterBroadcastGroup(group.getName());
        }
        broadcastGroups.clear();
        for (ClusterConnection clusterConnection : clusterConnections.values()) {
            clusterConnection.stop();
            managementService.unregisterCluster(clusterConnection.getName().toString());
        }
        for (Bridge bridge : bridges.values()) {
            bridge.stop();
            managementService.unregisterBridge(bridge.getName().toString());
        }
        bridges.clear();
    }
    for (ServerLocatorInternal clusterLocator : clusterLocators) {
        try {
            clusterLocator.close();
        } catch (Exception e) {
            ActiveMQServerLogger.LOGGER.errorClosingServerLocator(e, clusterLocator);
        }
    }
    clusterLocators.clear();
    state = State.STOPPED;
    clearClusterConnections();
}
Also used : ServerLocatorInternal(org.apache.activemq.artemis.core.client.impl.ServerLocatorInternal) ActiveMQException(org.apache.activemq.artemis.api.core.ActiveMQException)

Example 13 with ServerLocatorInternal

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

the class MultipleLivesMultipleBackupsFailoverTest method testMultipleFailovers2LiveServers.

@Test
public void testMultipleFailovers2LiveServers() throws Exception {
    NodeManager nodeManager1 = new InVMNodeManager(!sharedStore);
    NodeManager nodeManager2 = new InVMNodeManager(!sharedStore);
    createLiveConfig(nodeManager1, 0, 3, 4, 5);
    createBackupConfig(nodeManager1, 0, 1, true, new int[] { 0, 2 }, 3, 4, 5);
    createBackupConfig(nodeManager1, 0, 2, true, new int[] { 0, 1 }, 3, 4, 5);
    createLiveConfig(nodeManager2, 3, 0);
    createBackupConfig(nodeManager2, 3, 4, true, new int[] { 3, 5 }, 0, 1, 2);
    createBackupConfig(nodeManager2, 3, 5, true, new int[] { 3, 4 }, 0, 1, 2);
    servers.get(0).start();
    waitForServerToStart(servers.get(0).getServer());
    servers.get(3).start();
    waitForServerToStart(servers.get(3).getServer());
    servers.get(1).start();
    waitForServerToStart(servers.get(1).getServer());
    servers.get(2).start();
    servers.get(4).start();
    waitForServerToStart(servers.get(4).getServer());
    servers.get(5).start();
    waitForServerToStart(servers.get(4).getServer());
    locator = getServerLocator(0).setBlockOnNonDurableSend(true).setBlockOnDurableSend(true).setBlockOnAcknowledge(true).setReconnectAttempts(15);
    ClientSessionFactoryInternal sf = createSessionFactoryAndWaitForTopology(locator, 4, servers.get(0).getServer());
    ClientSession session = sendAndConsume(sf, true);
    System.out.println(((ServerLocatorInternal) locator).getTopology().describe());
    Thread.sleep(500);
    servers.get(0).crash(session);
    int liveAfter0 = waitForNewLive(10000, true, servers, 1, 2);
    locator2 = getServerLocator(3).setBlockOnNonDurableSend(true).setBlockOnDurableSend(true).setBlockOnAcknowledge(true).setReconnectAttempts(15);
    ClientSessionFactoryInternal sf2 = createSessionFactoryAndWaitForTopology(locator2, 4);
    ClientSession session2 = sendAndConsume(sf2, true);
    System.setProperty("foo", "bar");
    servers.get(3).crash(session2);
    int liveAfter3 = waitForNewLive(10000, true, servers, 4, 5);
    locator.close();
    locator2.close();
    if (liveAfter0 == 2) {
        Thread.sleep(500);
        servers.get(1).stop();
        Thread.sleep(500);
        servers.get(2).stop();
    } else {
        Thread.sleep(500);
        servers.get(2).stop();
        Thread.sleep(500);
        servers.get(1).stop();
    }
    if (liveAfter3 == 4) {
        Thread.sleep(500);
        servers.get(5).stop();
        Thread.sleep(500);
        servers.get(4).stop();
    } else {
        Thread.sleep(500);
        servers.get(4).stop();
        Thread.sleep(500);
        servers.get(5).stop();
    }
}
Also used : InVMNodeManager(org.apache.activemq.artemis.core.server.impl.InVMNodeManager) NodeManager(org.apache.activemq.artemis.core.server.NodeManager) ClientSessionFactoryInternal(org.apache.activemq.artemis.core.client.impl.ClientSessionFactoryInternal) InVMNodeManager(org.apache.activemq.artemis.core.server.impl.InVMNodeManager) ClientSession(org.apache.activemq.artemis.api.core.client.ClientSession) ServerLocatorInternal(org.apache.activemq.artemis.core.client.impl.ServerLocatorInternal) Test(org.junit.Test)

Example 14 with ServerLocatorInternal

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

the class ClusterTestBase method setupSessionFactory.

protected void setupSessionFactory(final int node, final int backupNode, final boolean netty, final boolean blocking) throws Exception {
    if (sfs[node] != null) {
        throw new IllegalArgumentException("Already a server at " + node);
    }
    Map<String, Object> params = generateParams(node, netty);
    TransportConfiguration serverToTC = createTransportConfiguration(netty, false, params);
    locators[node] = addServerLocator(ActiveMQClient.createServerLocatorWithHA(serverToTC)).setRetryInterval(100).setRetryIntervalMultiplier(1d).setReconnectAttempts(300).setBlockOnNonDurableSend(blocking).setBlockOnDurableSend(blocking);
    final String identity = "TestClientConnector,live=" + node + ",backup=" + backupNode;
    ((ServerLocatorInternal) locators[node]).setIdentity(identity);
    ClientSessionFactory sf = createSessionFactory(locators[node]);
    sfs[node] = sf;
}
Also used : TransportConfiguration(org.apache.activemq.artemis.api.core.TransportConfiguration) SimpleString(org.apache.activemq.artemis.api.core.SimpleString) ClientSessionFactory(org.apache.activemq.artemis.api.core.client.ClientSessionFactory) ServerLocatorInternal(org.apache.activemq.artemis.core.client.impl.ServerLocatorInternal)

Example 15 with ServerLocatorInternal

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

the class ClusterConnectionConfigTest method makeSureForwardingFlowControl.

private void makeSureForwardingFlowControl(int producerWindow, int... indices) throws NoSuchFieldException, IllegalAccessException {
    for (int i : indices) {
        ClusterConnectionImpl cc = (ClusterConnectionImpl) servers[i].getClusterManager().getClusterConnection("cluster" + i);
        Map<String, MessageFlowRecord> map = cc.getRecords();
        assertEquals(1, map.size());
        MessageFlowRecord record = map.entrySet().iterator().next().getValue();
        // NoSuchFieldException
        Field f = record.getClass().getDeclaredField("targetLocator");
        f.setAccessible(true);
        ServerLocatorInternal targetLocator = (ServerLocatorInternal) f.get(record);
        assertEquals(producerWindow, targetLocator.getProducerWindowSize());
    }
}
Also used : MessageFlowRecord(org.apache.activemq.artemis.core.server.cluster.MessageFlowRecord) Field(java.lang.reflect.Field) ServerLocatorInternal(org.apache.activemq.artemis.core.client.impl.ServerLocatorInternal) ClusterConnectionImpl(org.apache.activemq.artemis.core.server.cluster.impl.ClusterConnectionImpl)

Aggregations

ServerLocatorInternal (org.apache.activemq.artemis.core.client.impl.ServerLocatorInternal)16 ClientSessionFactoryInternal (org.apache.activemq.artemis.core.client.impl.ClientSessionFactoryInternal)6 Test (org.junit.Test)6 SimpleString (org.apache.activemq.artemis.api.core.SimpleString)4 TransportConfiguration (org.apache.activemq.artemis.api.core.TransportConfiguration)4 ActiveMQException (org.apache.activemq.artemis.api.core.ActiveMQException)3 CountDownLatch (java.util.concurrent.CountDownLatch)2 DiscoveryGroupConfiguration (org.apache.activemq.artemis.api.core.DiscoveryGroupConfiguration)2 ClientSessionFactory (org.apache.activemq.artemis.api.core.client.ClientSessionFactory)2 ClusterConnectionConfiguration (org.apache.activemq.artemis.core.config.ClusterConnectionConfiguration)2 Field (java.lang.reflect.Field)1 ArrayList (java.util.ArrayList)1 ActiveMQAlreadyReplicatingException (org.apache.activemq.artemis.api.core.ActiveMQAlreadyReplicatingException)1 ActiveMQDisconnectedException (org.apache.activemq.artemis.api.core.ActiveMQDisconnectedException)1 ActiveMQIllegalStateException (org.apache.activemq.artemis.api.core.ActiveMQIllegalStateException)1 ActiveMQNotConnectedException (org.apache.activemq.artemis.api.core.ActiveMQNotConnectedException)1 ClientSession (org.apache.activemq.artemis.api.core.client.ClientSession)1 ServerLocatorImpl (org.apache.activemq.artemis.core.client.impl.ServerLocatorImpl)1 Topology (org.apache.activemq.artemis.core.client.impl.Topology)1 TopologyMemberImpl (org.apache.activemq.artemis.core.client.impl.TopologyMemberImpl)1