Search in sources :

Example 26 with ClusterConnectionConfiguration

use of org.apache.activemq.artemis.core.config.ClusterConnectionConfiguration in project activemq-artemis by apache.

the class ClusterConnectionConfigTest method testRedistributionFlowControl.

@Test
public void testRedistributionFlowControl() throws Exception {
    final int producerWindow = new Random().nextInt(Integer.MAX_VALUE);
    System.out.println("window is: " + producerWindow);
    setupCluster(MessageLoadBalancingType.ON_DEMAND, (ClusterConnectionConfiguration cfg) -> {
        cfg.setProducerWindowSize(producerWindow);
    });
    startServers(0, 1);
    setupSessionFactory(0, isNetty());
    setupSessionFactory(1, isNetty());
    createQueue(0, "queues.testaddress", "queue0", null, false);
    createQueue(1, "queues.testaddress", "queue0", null, false);
    addConsumer(1, 1, "queue0", null);
    waitForBindings(0, "queues.testaddress", 1, 0, true);
    waitForBindings(1, "queues.testaddress", 1, 1, true);
    waitForBindings(0, "queues.testaddress", 1, 1, false);
    waitForBindings(1, "queues.testaddress", 1, 0, false);
    send(0, "queues.testaddress", 1, false, null);
    // receiveMessages(consumers[1].consumer, 0, 1, true);
    Thread.sleep(5000);
    System.out.println("checking records..........................");
    makeSureForwardingFlowControl(producerWindow, 0, 1);
    removeConsumer(1);
}
Also used : ClusterConnectionConfiguration(org.apache.activemq.artemis.core.config.ClusterConnectionConfiguration) Random(java.util.Random) Test(org.junit.Test)

Example 27 with ClusterConnectionConfiguration

use of org.apache.activemq.artemis.core.config.ClusterConnectionConfiguration in project activemq-artemis by apache.

the class ClusterTestBase method setupClusterConnectionWithBackups.

protected void setupClusterConnectionWithBackups(final String name, final String address, final MessageLoadBalancingType messageLoadBalancingType, final int maxHops, final boolean netty, final int nodeFrom, final int[] nodesTo) {
    ActiveMQServer serverFrom = servers[nodeFrom];
    if (serverFrom == null) {
        throw new IllegalStateException("No server at node " + nodeFrom);
    }
    TransportConfiguration connectorFrom = createTransportConfiguration(netty, false, generateParams(nodeFrom, netty));
    serverFrom.getConfiguration().getConnectorConfigurations().put(name, connectorFrom);
    List<String> pairs = new ArrayList<>();
    for (int element : nodesTo) {
        TransportConfiguration serverTotc = createTransportConfiguration(netty, false, generateParams(element, netty));
        serverFrom.getConfiguration().getConnectorConfigurations().put(serverTotc.getName(), serverTotc);
        pairs.add(serverTotc.getName());
    }
    Configuration config = serverFrom.getConfiguration();
    ClusterConnectionConfiguration clusterConf = new ClusterConnectionConfiguration().setName(name).setAddress(address).setConnectorName(name).setRetryInterval(250).setMessageLoadBalancingType(messageLoadBalancingType).setMaxHops(maxHops).setConfirmationWindowSize(1024).setStaticConnectors(pairs);
    config.getClusterConfigurations().add(clusterConf);
}
Also used : ClusterConnectionConfiguration(org.apache.activemq.artemis.core.config.ClusterConnectionConfiguration) ActiveMQServer(org.apache.activemq.artemis.core.server.ActiveMQServer) GroupingHandlerConfiguration(org.apache.activemq.artemis.core.server.group.impl.GroupingHandlerConfiguration) TransportConfiguration(org.apache.activemq.artemis.api.core.TransportConfiguration) Configuration(org.apache.activemq.artemis.core.config.Configuration) SharedStoreMasterPolicyConfiguration(org.apache.activemq.artemis.core.config.ha.SharedStoreMasterPolicyConfiguration) ActiveMQDefaultConfiguration(org.apache.activemq.artemis.api.config.ActiveMQDefaultConfiguration) ClusterConnectionConfiguration(org.apache.activemq.artemis.core.config.ClusterConnectionConfiguration) LiveOnlyPolicyConfiguration(org.apache.activemq.artemis.core.config.ha.LiveOnlyPolicyConfiguration) ReplicatedPolicyConfiguration(org.apache.activemq.artemis.core.config.ha.ReplicatedPolicyConfiguration) ReplicaPolicyConfiguration(org.apache.activemq.artemis.core.config.ha.ReplicaPolicyConfiguration) SharedStoreSlavePolicyConfiguration(org.apache.activemq.artemis.core.config.ha.SharedStoreSlavePolicyConfiguration) DiscoveryGroupConfiguration(org.apache.activemq.artemis.api.core.DiscoveryGroupConfiguration) HAPolicyConfiguration(org.apache.activemq.artemis.core.config.HAPolicyConfiguration) BroadcastGroupConfiguration(org.apache.activemq.artemis.api.core.BroadcastGroupConfiguration) ArrayList(java.util.ArrayList) TransportConfiguration(org.apache.activemq.artemis.api.core.TransportConfiguration) SimpleString(org.apache.activemq.artemis.api.core.SimpleString)

Example 28 with ClusterConnectionConfiguration

use of org.apache.activemq.artemis.core.config.ClusterConnectionConfiguration in project activemq-artemis by apache.

the class ClusterTestBase method setupClusterConnection.

protected void setupClusterConnection(final String name, final String uri, int server) throws Exception {
    ActiveMQServer serverFrom = servers[server];
    if (serverFrom == null) {
        throw new IllegalStateException("No server at node " + server);
    }
    ClusterConnectionConfiguration configuration = new ClusterConnectionConfiguration(new URI(uri)).setName(name);
    serverFrom.getConfiguration().addClusterConfiguration(configuration);
}
Also used : ClusterConnectionConfiguration(org.apache.activemq.artemis.core.config.ClusterConnectionConfiguration) ActiveMQServer(org.apache.activemq.artemis.core.server.ActiveMQServer) URI(java.net.URI)

Example 29 with ClusterConnectionConfiguration

use of org.apache.activemq.artemis.core.config.ClusterConnectionConfiguration in project activemq-artemis by apache.

the class ClusterTestBase method setupDiscoveryClusterConnection.

protected void setupDiscoveryClusterConnection(final String name, final int node, final String discoveryGroupName, final String address, final MessageLoadBalancingType messageLoadBalancingType, final int maxHops, final boolean netty) {
    ActiveMQServer server = servers[node];
    if (server == null) {
        throw new IllegalStateException("No server at node " + node);
    }
    TransportConfiguration connectorConfig = createTransportConfiguration(netty, false, generateParams(node, netty));
    server.getConfiguration().getConnectorConfigurations().put(name, connectorConfig);
    Configuration config = server.getConfiguration();
    ClusterConnectionConfiguration clusterConf = new ClusterConnectionConfiguration().setName(name).setAddress(address).setConnectorName(name).setRetryInterval(100).setDuplicateDetection(true).setMessageLoadBalancingType(messageLoadBalancingType).setMaxHops(maxHops).setConfirmationWindowSize(1024).setDiscoveryGroupName(discoveryGroupName);
    List<ClusterConnectionConfiguration> clusterConfs = config.getClusterConfigurations();
    clusterConfs.add(clusterConf);
}
Also used : ClusterConnectionConfiguration(org.apache.activemq.artemis.core.config.ClusterConnectionConfiguration) ActiveMQServer(org.apache.activemq.artemis.core.server.ActiveMQServer) GroupingHandlerConfiguration(org.apache.activemq.artemis.core.server.group.impl.GroupingHandlerConfiguration) TransportConfiguration(org.apache.activemq.artemis.api.core.TransportConfiguration) Configuration(org.apache.activemq.artemis.core.config.Configuration) SharedStoreMasterPolicyConfiguration(org.apache.activemq.artemis.core.config.ha.SharedStoreMasterPolicyConfiguration) ActiveMQDefaultConfiguration(org.apache.activemq.artemis.api.config.ActiveMQDefaultConfiguration) ClusterConnectionConfiguration(org.apache.activemq.artemis.core.config.ClusterConnectionConfiguration) LiveOnlyPolicyConfiguration(org.apache.activemq.artemis.core.config.ha.LiveOnlyPolicyConfiguration) ReplicatedPolicyConfiguration(org.apache.activemq.artemis.core.config.ha.ReplicatedPolicyConfiguration) ReplicaPolicyConfiguration(org.apache.activemq.artemis.core.config.ha.ReplicaPolicyConfiguration) SharedStoreSlavePolicyConfiguration(org.apache.activemq.artemis.core.config.ha.SharedStoreSlavePolicyConfiguration) DiscoveryGroupConfiguration(org.apache.activemq.artemis.api.core.DiscoveryGroupConfiguration) HAPolicyConfiguration(org.apache.activemq.artemis.core.config.HAPolicyConfiguration) BroadcastGroupConfiguration(org.apache.activemq.artemis.api.core.BroadcastGroupConfiguration) TransportConfiguration(org.apache.activemq.artemis.api.core.TransportConfiguration)

Example 30 with ClusterConnectionConfiguration

use of org.apache.activemq.artemis.core.config.ClusterConnectionConfiguration in project activemq-artemis by apache.

the class SharedNothingLiveActivation method isNodeIdUsed.

/**
 * Determines whether there is another server already running with this server's nodeID.
 * <p>
 * This can happen in case of a successful fail-over followed by the live's restart
 * (attempting a fail-back).
 *
 * @throws Exception
 */
private boolean isNodeIdUsed() throws Exception {
    if (activeMQServer.getConfiguration().getClusterConfigurations().isEmpty())
        return false;
    SimpleString nodeId0;
    try {
        nodeId0 = activeMQServer.getNodeManager().readNodeId();
    } catch (ActiveMQIllegalStateException e) {
        nodeId0 = null;
    }
    ClusterConnectionConfiguration config = ConfigurationUtils.getReplicationClusterConfiguration(activeMQServer.getConfiguration(), replicatedPolicy.getClusterName());
    NodeIdListener listener = new NodeIdListener(nodeId0, activeMQServer.getConfiguration().getClusterUser(), activeMQServer.getConfiguration().getClusterPassword());
    try (ServerLocatorInternal locator = getLocator(config)) {
        locator.addClusterTopologyListener(listener);
        locator.setReconnectAttempts(0);
        try (ClientSessionFactoryInternal factory = locator.connectNoWarnings()) {
            // Just try connecting
            listener.latch.await(5, TimeUnit.SECONDS);
        } catch (Exception notConnected) {
            return false;
        }
        return listener.isNodePresent;
    }
}
Also used : ClusterConnectionConfiguration(org.apache.activemq.artemis.core.config.ClusterConnectionConfiguration) ClientSessionFactoryInternal(org.apache.activemq.artemis.core.client.impl.ClientSessionFactoryInternal) ActiveMQIllegalStateException(org.apache.activemq.artemis.api.core.ActiveMQIllegalStateException) SimpleString(org.apache.activemq.artemis.api.core.SimpleString) ServerLocatorInternal(org.apache.activemq.artemis.core.client.impl.ServerLocatorInternal) ActiveMQException(org.apache.activemq.artemis.api.core.ActiveMQException) ActiveMQDisconnectedException(org.apache.activemq.artemis.api.core.ActiveMQDisconnectedException) ActiveMQIllegalStateException(org.apache.activemq.artemis.api.core.ActiveMQIllegalStateException) ActiveMQAlreadyReplicatingException(org.apache.activemq.artemis.api.core.ActiveMQAlreadyReplicatingException)

Aggregations

ClusterConnectionConfiguration (org.apache.activemq.artemis.core.config.ClusterConnectionConfiguration)36 TransportConfiguration (org.apache.activemq.artemis.api.core.TransportConfiguration)18 Configuration (org.apache.activemq.artemis.core.config.Configuration)18 ArrayList (java.util.ArrayList)12 ReplicaPolicyConfiguration (org.apache.activemq.artemis.core.config.ha.ReplicaPolicyConfiguration)11 SimpleString (org.apache.activemq.artemis.api.core.SimpleString)10 ReplicatedPolicyConfiguration (org.apache.activemq.artemis.core.config.ha.ReplicatedPolicyConfiguration)10 SharedStoreSlavePolicyConfiguration (org.apache.activemq.artemis.core.config.ha.SharedStoreSlavePolicyConfiguration)10 ActiveMQServer (org.apache.activemq.artemis.core.server.ActiveMQServer)10 DiscoveryGroupConfiguration (org.apache.activemq.artemis.api.core.DiscoveryGroupConfiguration)9 SharedStoreMasterPolicyConfiguration (org.apache.activemq.artemis.core.config.ha.SharedStoreMasterPolicyConfiguration)9 BroadcastGroupConfiguration (org.apache.activemq.artemis.api.core.BroadcastGroupConfiguration)8 Test (org.junit.Test)8 URI (java.net.URI)7 ActiveMQDefaultConfiguration (org.apache.activemq.artemis.api.config.ActiveMQDefaultConfiguration)7 HAPolicyConfiguration (org.apache.activemq.artemis.core.config.HAPolicyConfiguration)7 LiveOnlyPolicyConfiguration (org.apache.activemq.artemis.core.config.ha.LiveOnlyPolicyConfiguration)7 GroupingHandlerConfiguration (org.apache.activemq.artemis.core.server.group.impl.GroupingHandlerConfiguration)6 HashMap (java.util.HashMap)4 UDPBroadcastEndpointFactory (org.apache.activemq.artemis.api.core.UDPBroadcastEndpointFactory)3