Search in sources :

Example 16 with ClusterConnectionConfiguration

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

the class FileConfigurationParser method parseClusterConnectionConfiguration.

private void parseClusterConnectionConfiguration(final Element e, final Configuration mainConfig) throws Exception {
    String name = e.getAttribute("name");
    String address = getString(e, "address", "", Validators.NO_CHECK);
    String connectorName = getString(e, "connector-ref", null, Validators.NOT_NULL_OR_EMPTY);
    if (!mainConfig.getConnectorConfigurations().containsKey(connectorName)) {
        ActiveMQServerLogger.LOGGER.connectorRefNotFound(connectorName, name);
        return;
    }
    boolean duplicateDetection = getBoolean(e, "use-duplicate-detection", ActiveMQDefaultConfiguration.isDefaultClusterDuplicateDetection());
    MessageLoadBalancingType messageLoadBalancingType;
    if (parameterExists(e, "forward-when-no-consumers")) {
        boolean forwardWhenNoConsumers = getBoolean(e, "forward-when-no-consumers", ActiveMQDefaultConfiguration.isDefaultClusterForwardWhenNoConsumers());
        if (forwardWhenNoConsumers) {
            messageLoadBalancingType = MessageLoadBalancingType.STRICT;
        } else {
            messageLoadBalancingType = MessageLoadBalancingType.ON_DEMAND;
        }
    } else {
        messageLoadBalancingType = Enum.valueOf(MessageLoadBalancingType.class, getString(e, "message-load-balancing", ActiveMQDefaultConfiguration.getDefaultClusterMessageLoadBalancingType(), Validators.MESSAGE_LOAD_BALANCING_TYPE));
    }
    int maxHops = getInteger(e, "max-hops", ActiveMQDefaultConfiguration.getDefaultClusterMaxHops(), Validators.GE_ZERO);
    long clientFailureCheckPeriod = getLong(e, "check-period", ActiveMQDefaultConfiguration.getDefaultClusterFailureCheckPeriod(), Validators.GT_ZERO);
    long connectionTTL = getLong(e, "connection-ttl", ActiveMQDefaultConfiguration.getDefaultClusterConnectionTtl(), Validators.GT_ZERO);
    long retryInterval = getLong(e, "retry-interval", ActiveMQDefaultConfiguration.getDefaultClusterRetryInterval(), Validators.GT_ZERO);
    long callTimeout = getLong(e, "call-timeout", ActiveMQClient.DEFAULT_CALL_TIMEOUT, Validators.GT_ZERO);
    long callFailoverTimeout = getLong(e, "call-failover-timeout", ActiveMQClient.DEFAULT_CALL_FAILOVER_TIMEOUT, Validators.MINUS_ONE_OR_GT_ZERO);
    double retryIntervalMultiplier = getDouble(e, "retry-interval-multiplier", ActiveMQDefaultConfiguration.getDefaultClusterRetryIntervalMultiplier(), Validators.GT_ZERO);
    int minLargeMessageSize = getTextBytesAsIntBytes(e, "min-large-message-size", ActiveMQClient.DEFAULT_MIN_LARGE_MESSAGE_SIZE, Validators.GT_ZERO);
    long maxRetryInterval = getLong(e, "max-retry-interval", ActiveMQDefaultConfiguration.getDefaultClusterMaxRetryInterval(), Validators.GT_ZERO);
    int initialConnectAttempts = getInteger(e, "initial-connect-attempts", ActiveMQDefaultConfiguration.getDefaultClusterInitialConnectAttempts(), Validators.MINUS_ONE_OR_GE_ZERO);
    int reconnectAttempts = getInteger(e, "reconnect-attempts", ActiveMQDefaultConfiguration.getDefaultClusterReconnectAttempts(), Validators.MINUS_ONE_OR_GE_ZERO);
    int confirmationWindowSize = getTextBytesAsIntBytes(e, "confirmation-window-size", ActiveMQDefaultConfiguration.getDefaultClusterConfirmationWindowSize(), Validators.GT_ZERO);
    int producerWindowSize = getTextBytesAsIntBytes(e, "producer-window-size", ActiveMQDefaultConfiguration.getDefaultBridgeProducerWindowSize(), Validators.MINUS_ONE_OR_GT_ZERO);
    long clusterNotificationInterval = getLong(e, "notification-interval", ActiveMQDefaultConfiguration.getDefaultClusterNotificationInterval(), Validators.GT_ZERO);
    int clusterNotificationAttempts = getInteger(e, "notification-attempts", ActiveMQDefaultConfiguration.getDefaultClusterNotificationAttempts(), Validators.GT_ZERO);
    String scaleDownConnector = e.getAttribute("scale-down-connector");
    String discoveryGroupName = null;
    List<String> staticConnectorNames = new ArrayList<>();
    boolean allowDirectConnectionsOnly = false;
    NodeList children = e.getChildNodes();
    for (int j = 0; j < children.getLength(); j++) {
        Node child = children.item(j);
        if (child.getNodeName().equals("discovery-group-ref")) {
            discoveryGroupName = child.getAttributes().getNamedItem("discovery-group-name").getNodeValue();
        } else if (child.getNodeName().equals("static-connectors")) {
            Node attr = child.getAttributes().getNamedItem("allow-direct-connections-only");
            if (attr != null) {
                allowDirectConnectionsOnly = "true".equalsIgnoreCase(attr.getNodeValue()) || allowDirectConnectionsOnly;
            }
            getStaticConnectors(staticConnectorNames, child);
        }
    }
    ClusterConnectionConfiguration config = new ClusterConnectionConfiguration().setName(name).setAddress(address).setConnectorName(connectorName).setMinLargeMessageSize(minLargeMessageSize).setClientFailureCheckPeriod(clientFailureCheckPeriod).setConnectionTTL(connectionTTL).setRetryInterval(retryInterval).setRetryIntervalMultiplier(retryIntervalMultiplier).setMaxRetryInterval(maxRetryInterval).setInitialConnectAttempts(initialConnectAttempts).setReconnectAttempts(reconnectAttempts).setCallTimeout(callTimeout).setCallFailoverTimeout(callFailoverTimeout).setDuplicateDetection(duplicateDetection).setMessageLoadBalancingType(messageLoadBalancingType).setMaxHops(maxHops).setConfirmationWindowSize(confirmationWindowSize).setProducerWindowSize(producerWindowSize).setAllowDirectConnectionsOnly(allowDirectConnectionsOnly).setClusterNotificationInterval(clusterNotificationInterval).setClusterNotificationAttempts(clusterNotificationAttempts);
    if (discoveryGroupName == null) {
        config.setStaticConnectors(staticConnectorNames);
    } else {
        config.setDiscoveryGroupName(discoveryGroupName);
    }
    mainConfig.getClusterConfigurations().add(config);
}
Also used : ClusterConnectionConfiguration(org.apache.activemq.artemis.core.config.ClusterConnectionConfiguration) NodeList(org.w3c.dom.NodeList) Node(org.w3c.dom.Node) ArrayList(java.util.ArrayList) MessageLoadBalancingType(org.apache.activemq.artemis.core.server.cluster.impl.MessageLoadBalancingType) SimpleString(org.apache.activemq.artemis.api.core.SimpleString)

Example 17 with ClusterConnectionConfiguration

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

the class ConfigurationImpl method addClusterConfiguration.

@Override
public ClusterConnectionConfiguration addClusterConfiguration(String name, String uri) throws Exception {
    ClusterConnectionConfiguration newConfig = new ClusterConnectionConfiguration(new URI(uri)).setName(name);
    clusterConfigurations.add(newConfig);
    return newConfig;
}
Also used : ClusterConnectionConfiguration(org.apache.activemq.artemis.core.config.ClusterConnectionConfiguration) URI(java.net.URI)

Example 18 with ClusterConnectionConfiguration

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

the class BackupManager method start.

/*
   * Start the backup manager if not already started. This entails deploying a backup connector based on a cluster
   * configuration, informing the cluster manager so that it can add it to its topology and announce itself to the cluster.
   * */
@Override
public synchronized void start() throws Exception {
    if (started)
        return;
    // deploy the backup connectors using the cluster configuration
    for (ClusterConnectionConfiguration config : configuration.getClusterConfigurations()) {
        deployBackupConnector(config);
    }
    // as we wait for replication to start and be notified by the replication manager.
    for (BackupConnector conn : backupConnectors) {
        conn.start();
        if (server.getHAPolicy().isBackup() && server.getHAPolicy().isSharedStore()) {
            conn.informTopology();
            conn.announceBackup();
        }
    }
    started = true;
}
Also used : ClusterConnectionConfiguration(org.apache.activemq.artemis.core.config.ClusterConnectionConfiguration)

Example 19 with ClusterConnectionConfiguration

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

the class FailoverTestBase method adaptLiveConfigForReplicatedFailBack.

protected final void adaptLiveConfigForReplicatedFailBack(TestableServer server) {
    Configuration configuration = server.getServer().getConfiguration();
    final TransportConfiguration backupConnector = getConnectorTransportConfiguration(false);
    if (server.getServer().getHAPolicy().isSharedStore()) {
        ClusterConnectionConfiguration cc = configuration.getClusterConfigurations().get(0);
        Assert.assertNotNull("cluster connection configuration", cc);
        Assert.assertNotNull("static connectors", cc.getStaticConnectors());
        cc.getStaticConnectors().add(backupConnector.getName());
        // backupConnector is only necessary for fail-back tests
        configuration.getConnectorConfigurations().put(backupConnector.getName(), backupConnector);
        return;
    }
    ReplicatedPolicy haPolicy = (ReplicatedPolicy) server.getServer().getHAPolicy();
    haPolicy.setCheckForLiveServer(true);
}
Also used : ClusterConnectionConfiguration(org.apache.activemq.artemis.core.config.ClusterConnectionConfiguration) Configuration(org.apache.activemq.artemis.core.config.Configuration) SharedStoreMasterPolicyConfiguration(org.apache.activemq.artemis.core.config.ha.SharedStoreMasterPolicyConfiguration) ClusterConnectionConfiguration(org.apache.activemq.artemis.core.config.ClusterConnectionConfiguration) ReplicaPolicyConfiguration(org.apache.activemq.artemis.core.config.ha.ReplicaPolicyConfiguration) SharedStoreSlavePolicyConfiguration(org.apache.activemq.artemis.core.config.ha.SharedStoreSlavePolicyConfiguration) TransportConfiguration(org.apache.activemq.artemis.api.core.TransportConfiguration) ReplicatedPolicy(org.apache.activemq.artemis.core.server.cluster.ha.ReplicatedPolicy) TransportConfiguration(org.apache.activemq.artemis.api.core.TransportConfiguration)

Example 20 with ClusterConnectionConfiguration

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

the class IsolatedTopologyTest method createServer2.

private ActiveMQServer createServer2() throws Exception {
    Map<String, Object> params = new HashMap<>();
    params.put(TransportConstants.CLUSTER_CONNECTION, "cc1");
    params.put(org.apache.activemq.artemis.core.remoting.impl.invm.TransportConstants.SERVER_ID_PROP_NAME, "3");
    TransportConfiguration acceptor1VM1 = new TransportConfiguration(ActiveMQTestBase.INVM_ACCEPTOR_FACTORY, params, "acceptor-cc1");
    params = new HashMap<>();
    params.put(TransportConstants.CLUSTER_CONNECTION, "cc2");
    params.put(org.apache.activemq.artemis.core.remoting.impl.invm.TransportConstants.SERVER_ID_PROP_NAME, "4");
    TransportConfiguration acceptor2VM1 = new TransportConfiguration(ActiveMQTestBase.INVM_ACCEPTOR_FACTORY, params, "acceptor-cc2");
    List<String> connectTo = new ArrayList<>();
    connectTo.add("other-cc1");
    ClusterConnectionConfiguration server1CC1 = new ClusterConnectionConfiguration().setName("cc1").setAddress("jms").setConnectorName("local-cc1").setRetryInterval(250).setConfirmationWindowSize(1024).setMessageLoadBalancingType(MessageLoadBalancingType.ON_DEMAND).setStaticConnectors(connectTo);
    List<String> connectTo2 = new ArrayList<>();
    connectTo2.add("other-cc2");
    ClusterConnectionConfiguration server1CC2 = new ClusterConnectionConfiguration().setName("cc2").setAddress("jms").setConnectorName("local-cc2").setRetryInterval(250).setConfirmationWindowSize(1024).setMessageLoadBalancingType(MessageLoadBalancingType.ON_DEMAND).setStaticConnectors(connectTo2);
    // Server2 with two acceptors, each acceptor on a different cluster connection
    // talking to a different connector.
    // i.e. two cluster connections isolated on the same node
    Configuration config1 = createBasicConfig(2).addAcceptorConfiguration(acceptor1VM1).addAcceptorConfiguration(acceptor2VM1).addConnectorConfiguration("local-cc1", createInVMTransportConnectorConfig(3, "local-cc1")).addConnectorConfiguration("local-cc2", createInVMTransportConnectorConfig(4, "local-cc2")).addConnectorConfiguration("other-cc1", createInVMTransportConnectorConfig(1, "other-cc1")).addConnectorConfiguration("other-cc2", createInVMTransportConnectorConfig(2, "other-cc2")).addClusterConfiguration(server1CC1).addClusterConfiguration(server1CC2);
    return createServer(false, config1);
}
Also used : ClusterConnectionConfiguration(org.apache.activemq.artemis.core.config.ClusterConnectionConfiguration) Configuration(org.apache.activemq.artemis.core.config.Configuration) ClusterConnectionConfiguration(org.apache.activemq.artemis.core.config.ClusterConnectionConfiguration) TransportConfiguration(org.apache.activemq.artemis.api.core.TransportConfiguration) HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) TransportConfiguration(org.apache.activemq.artemis.api.core.TransportConfiguration)

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