Search in sources :

Example 1 with ClusterConnectionConfiguration

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

the class ClusterConnectionAdd method createClusterConnectionConfiguration.

static ClusterConnectionConfiguration createClusterConnectionConfiguration(final OperationContext context, final String name, final ModelNode model) throws OperationFailedException {
    final String address = ClusterConnectionDefinition.ADDRESS.resolveModelAttribute(context, model).asString();
    final String connectorName = ClusterConnectionDefinition.CONNECTOR_NAME.resolveModelAttribute(context, model).asString();
    final long retryInterval = ClusterConnectionDefinition.RETRY_INTERVAL.resolveModelAttribute(context, model).asLong();
    final boolean duplicateDetection = ClusterConnectionDefinition.USE_DUPLICATE_DETECTION.resolveModelAttribute(context, model).asBoolean();
    final long connectionTTL = ClusterConnectionDefinition.CONNECTION_TTL.resolveModelAttribute(context, model).asInt();
    final int initialConnectAttempts = ClusterConnectionDefinition.INITIAL_CONNECT_ATTEMPTS.resolveModelAttribute(context, model).asInt();
    final int reconnectAttempts = ClusterConnectionDefinition.RECONNECT_ATTEMPTS.resolveModelAttribute(context, model).asInt();
    final long maxRetryInterval = ClusterConnectionDefinition.MAX_RETRY_INTERVAL.resolveModelAttribute(context, model).asLong();
    final double retryIntervalMultiplier = ClusterConnectionDefinition.RETRY_INTERVAL_MULTIPLIER.resolveModelAttribute(context, model).asDouble();
    final long clientFailureCheckPeriod = ClusterConnectionDefinition.CHECK_PERIOD.resolveModelAttribute(context, model).asInt();
    final String messageLoadBalancingType = ClusterConnectionDefinition.MESSAGE_LOAD_BALANCING_TYPE.resolveModelAttribute(context, model).asString();
    final int maxHops = ClusterConnectionDefinition.MAX_HOPS.resolveModelAttribute(context, model).asInt();
    final int confirmationWindowSize = CommonAttributes.BRIDGE_CONFIRMATION_WINDOW_SIZE.resolveModelAttribute(context, model).asInt();
    final int producerWindowSize = ClusterConnectionDefinition.PRODUCER_WINDOW_SIZE.resolveModelAttribute(context, model).asInt();
    final ModelNode discoveryNode = ClusterConnectionDefinition.DISCOVERY_GROUP_NAME.resolveModelAttribute(context, model);
    final int minLargeMessageSize = CommonAttributes.MIN_LARGE_MESSAGE_SIZE.resolveModelAttribute(context, model).asInt();
    final long callTimeout = CommonAttributes.CALL_TIMEOUT.resolveModelAttribute(context, model).asLong();
    final long callFailoverTimeout = CommonAttributes.CALL_FAILOVER_TIMEOUT.resolveModelAttribute(context, model).asLong();
    final long clusterNotificationInterval = ClusterConnectionDefinition.NOTIFICATION_INTERVAL.resolveModelAttribute(context, model).asLong();
    final int clusterNotificationAttempts = ClusterConnectionDefinition.NOTIFICATION_ATTEMPTS.resolveModelAttribute(context, model).asInt();
    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.valueOf(messageLoadBalancingType)).setMaxHops(maxHops).setConfirmationWindowSize(confirmationWindowSize).setProducerWindowSize(producerWindowSize).setClusterNotificationInterval(clusterNotificationInterval).setClusterNotificationAttempts(clusterNotificationAttempts);
    final String discoveryGroupName = discoveryNode.isDefined() ? discoveryNode.asString() : null;
    final List<String> staticConnectors = discoveryGroupName == null ? getStaticConnectors(model) : null;
    final boolean allowDirectOnly = ClusterConnectionDefinition.ALLOW_DIRECT_CONNECTIONS_ONLY.resolveModelAttribute(context, model).asBoolean();
    if (discoveryGroupName != null) {
        config.setDiscoveryGroupName(discoveryGroupName);
    } else {
        config.setStaticConnectors(staticConnectors).setAllowDirectConnectionsOnly(allowDirectOnly);
    }
    return config;
}
Also used : ClusterConnectionConfiguration(org.apache.activemq.artemis.core.config.ClusterConnectionConfiguration) ModelNode(org.jboss.dmr.ModelNode)

Example 2 with ClusterConnectionConfiguration

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

the class FileConfigurationParser method parseClusterConnectionConfigurationURI.

private void parseClusterConnectionConfigurationURI(final Element e, final Configuration mainConfig) throws Exception {
    String name = e.getAttribute("name");
    String uri = e.getAttribute("address");
    ClusterConnectionConfiguration config = mainConfig.addClusterConfiguration(name, uri);
    System.out.println("Adding cluster connection :: " + config);
}
Also used : ClusterConnectionConfiguration(org.apache.activemq.artemis.core.config.ClusterConnectionConfiguration) SimpleString(org.apache.activemq.artemis.api.core.SimpleString)

Example 3 with ClusterConnectionConfiguration

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

the class ClusterControl method announceReplicatingBackupToLive.

/**
 * XXX HORNETQ-720
 *
 * @param attemptingFailBack if {@code true} then this server wants to trigger a fail-back when
 *                           up-to-date, that is it wants to take over the role of 'live' from the current 'live'
 *                           server.
 * @throws ActiveMQException
 */
public void announceReplicatingBackupToLive(final boolean attemptingFailBack, String replicationClusterName) throws ActiveMQException {
    ClusterConnectionConfiguration config = ConfigurationUtils.getReplicationClusterConfiguration(server.getConfiguration(), replicationClusterName);
    if (config == null) {
        ActiveMQServerLogger.LOGGER.announceBackupNoClusterConnections();
        throw new ActiveMQException("lacking cluster connection");
    }
    TransportConfiguration connector = server.getConfiguration().getConnectorConfigurations().get(config.getConnectorName());
    if (connector == null) {
        ActiveMQServerLogger.LOGGER.announceBackupNoConnector(config.getConnectorName());
        throw new ActiveMQException("lacking cluster connection");
    }
    clusterChannel.send(new BackupRegistrationMessage(connector, clusterUser, clusterPassword, attemptingFailBack));
}
Also used : ClusterConnectionConfiguration(org.apache.activemq.artemis.core.config.ClusterConnectionConfiguration) BackupRegistrationMessage(org.apache.activemq.artemis.core.protocol.core.impl.wireformat.BackupRegistrationMessage) ActiveMQException(org.apache.activemq.artemis.api.core.ActiveMQException) TransportConfiguration(org.apache.activemq.artemis.api.core.TransportConfiguration)

Example 4 with ClusterConnectionConfiguration

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

the class IsolatedTopologyTest method createServer1.

private ActiveMQServer createServer1() 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, "1");
    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, "2");
    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);
    ArrayList<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);
    // Server1 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(1).addConnectorConfiguration("local-cc1", createInVMTransportConnectorConfig(1, "local-cc1")).addConnectorConfiguration("local-cc2", createInVMTransportConnectorConfig(2, "local-cc2")).addConnectorConfiguration("other-cc1", createInVMTransportConnectorConfig(3, "other-cc1")).addConnectorConfiguration("other-cc2", createInVMTransportConnectorConfig(4, "other-cc2")).addAcceptorConfiguration(acceptor1VM1).addAcceptorConfiguration(acceptor2VM1).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)

Example 5 with ClusterConnectionConfiguration

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

the class NonHATopologyTest method internalTest.

public void internalTest(boolean isNetty) throws Exception {
    ActiveMQServer server = null;
    ServerLocatorInternal locator = null;
    try {
        server = createServer(false, isNetty);
        if (!isNetty) {
            server.getConfiguration().getAcceptorConfigurations().add(new TransportConfiguration(NETTY_ACCEPTOR_FACTORY));
            server.getConfiguration().getConnectorConfigurations().put("netty", new TransportConfiguration(NETTY_CONNECTOR_FACTORY));
            ArrayList<String> list = new ArrayList<>();
            list.add("netty");
            Configuration config = server.getConfiguration();
            config.getClusterConfigurations().add(new ClusterConnectionConfiguration().setName("tst").setAddress("jms").setConnectorName("netty").setRetryInterval(1000).setConfirmationWindowSize(1000).setMessageLoadBalancingType(MessageLoadBalancingType.ON_DEMAND).setStaticConnectors(list).setAllowDirectConnectionsOnly(true));
        }
        server.start();
        locator = (ServerLocatorInternal) createNonHALocator(isNetty);
        ClientSessionFactory factory = createSessionFactory(locator);
        Topology topology = locator.getTopology();
        assertEquals(1, topology.getMembers().size());
        factory.close();
        TopologyMemberImpl member = topology.getMembers().iterator().next();
        if (isNetty) {
            assertEquals(NettyConnectorFactory.class.getName(), member.getLive().getFactoryClassName());
        } else {
            assertEquals(InVMConnectorFactory.class.getName(), member.getLive().getFactoryClassName());
        }
    } finally {
        try {
            locator.close();
        } catch (Exception ignored) {
        }
        try {
            server.stop();
        } catch (Exception ignored) {
        }
        server = null;
        locator = null;
    }
}
Also used : ClusterConnectionConfiguration(org.apache.activemq.artemis.core.config.ClusterConnectionConfiguration) TopologyMemberImpl(org.apache.activemq.artemis.core.client.impl.TopologyMemberImpl) Configuration(org.apache.activemq.artemis.core.config.Configuration) ClusterConnectionConfiguration(org.apache.activemq.artemis.core.config.ClusterConnectionConfiguration) TransportConfiguration(org.apache.activemq.artemis.api.core.TransportConfiguration) NettyConnectorFactory(org.apache.activemq.artemis.core.remoting.impl.netty.NettyConnectorFactory) ArrayList(java.util.ArrayList) TransportConfiguration(org.apache.activemq.artemis.api.core.TransportConfiguration) Topology(org.apache.activemq.artemis.core.client.impl.Topology) ServerLocatorInternal(org.apache.activemq.artemis.core.client.impl.ServerLocatorInternal) ActiveMQServer(org.apache.activemq.artemis.core.server.ActiveMQServer) InVMConnectorFactory(org.apache.activemq.artemis.core.remoting.impl.invm.InVMConnectorFactory) ClientSessionFactory(org.apache.activemq.artemis.api.core.client.ClientSessionFactory)

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