Search in sources :

Example 11 with BroadcastGroupConfiguration

use of org.apache.activemq.artemis.api.core.BroadcastGroupConfiguration in project wildfly by wildfly.

the class SocketBroadcastGroupAdd method createBroadcastGroupConfiguration.

static BroadcastGroupConfiguration createBroadcastGroupConfiguration(final OperationContext context, final Set<String> connectors, final String name, final ModelNode model) throws OperationFailedException {
    final long broadcastPeriod = BroadcastGroupDefinition.BROADCAST_PERIOD.resolveModelAttribute(context, model).asLong();
    final List<String> connectorRefs = new ArrayList<>();
    if (model.hasDefined(CommonAttributes.CONNECTORS)) {
        for (ModelNode ref : model.get(CommonAttributes.CONNECTORS).asList()) {
            final String refName = ref.asString();
            if (!connectors.contains(refName)) {
                throw MessagingLogger.ROOT_LOGGER.wrongConnectorRefInBroadCastGroup(name, refName, connectors);
            }
            connectorRefs.add(refName);
        }
    }
    return new BroadcastGroupConfiguration().setName(name).setBroadcastPeriod(broadcastPeriod).setConnectorInfos(connectorRefs);
}
Also used : ArrayList(java.util.ArrayList) ModelNode(org.jboss.dmr.ModelNode) BroadcastGroupConfiguration(org.apache.activemq.artemis.api.core.BroadcastGroupConfiguration)

Example 12 with BroadcastGroupConfiguration

use of org.apache.activemq.artemis.api.core.BroadcastGroupConfiguration in project wildfly by wildfly.

the class SocketBroadcastGroupAdd method createBroadcastGroupConfiguration.

static BroadcastGroupConfiguration createBroadcastGroupConfiguration(final String name, final BroadcastGroupConfiguration config, final SocketBinding socketBinding) throws Exception {
    final String localAddress = socketBinding.getAddress().getHostAddress();
    if (socketBinding.getMulticastAddress() == null) {
        throw MessagingLogger.ROOT_LOGGER.socketBindingMulticastNotSet("socket-broadcast-group", name, socketBinding.getName());
    }
    final String groupAddress = socketBinding.getMulticastAddress().getHostAddress();
    final int localPort = socketBinding.getPort();
    final int groupPort = socketBinding.getMulticastPort();
    final long broadcastPeriod = config.getBroadcastPeriod();
    final List<String> connectorRefs = config.getConnectorInfos();
    final BroadcastEndpointFactory endpointFactory = new UDPBroadcastEndpointFactory().setGroupAddress(groupAddress).setGroupPort(groupPort).setLocalBindAddress(localAddress).setLocalBindPort(localPort);
    return new BroadcastGroupConfiguration().setName(name).setBroadcastPeriod(broadcastPeriod).setConnectorInfos(connectorRefs).setEndpointFactory(endpointFactory);
}
Also used : UDPBroadcastEndpointFactory(org.apache.activemq.artemis.api.core.UDPBroadcastEndpointFactory) BroadcastGroupConfiguration(org.apache.activemq.artemis.api.core.BroadcastGroupConfiguration) UDPBroadcastEndpointFactory(org.apache.activemq.artemis.api.core.UDPBroadcastEndpointFactory) BroadcastEndpointFactory(org.apache.activemq.artemis.api.core.BroadcastEndpointFactory)

Example 13 with BroadcastGroupConfiguration

use of org.apache.activemq.artemis.api.core.BroadcastGroupConfiguration in project wildfly by wildfly.

the class BroadcastGroupAdd method addBroadcastGroupConfigs.

static void addBroadcastGroupConfigs(final OperationContext context, final Configuration configuration, final ModelNode model) throws OperationFailedException {
    if (model.hasDefined(CommonAttributes.BROADCAST_GROUP)) {
        final List<BroadcastGroupConfiguration> configs = configuration.getBroadcastGroupConfigurations();
        final Set<String> connectors = configuration.getConnectorConfigurations().keySet();
        for (Property prop : model.get(CommonAttributes.BROADCAST_GROUP).asPropertyList()) {
            configs.add(createBroadcastGroupConfiguration(context, connectors, prop.getName(), prop.getValue()));
        }
    }
}
Also used : BroadcastGroupConfiguration(org.apache.activemq.artemis.api.core.BroadcastGroupConfiguration) Property(org.jboss.dmr.Property)

Example 14 with BroadcastGroupConfiguration

use of org.apache.activemq.artemis.api.core.BroadcastGroupConfiguration in project activemq-artemis by apache.

the class FileConfigurationParser method parseBroadcastGroupConfiguration.

private void parseBroadcastGroupConfiguration(final Element e, final Configuration mainConfig) {
    String name = e.getAttribute("name");
    List<String> connectorNames = new ArrayList<>();
    NodeList children = e.getChildNodes();
    for (int j = 0; j < children.getLength(); j++) {
        Node child = children.item(j);
        if (child.getNodeName().equals("connector-ref")) {
            String connectorName = getString(e, "connector-ref", null, Validators.NOT_NULL_OR_EMPTY);
            connectorNames.add(connectorName);
        }
    }
    long broadcastPeriod = getLong(e, "broadcast-period", ActiveMQDefaultConfiguration.getDefaultBroadcastPeriod(), Validators.GT_ZERO);
    String localAddress = getString(e, "local-bind-address", null, Validators.NO_CHECK);
    int localBindPort = getInteger(e, "local-bind-port", -1, Validators.MINUS_ONE_OR_GT_ZERO);
    String groupAddress = getString(e, "group-address", null, Validators.NO_CHECK);
    int groupPort = getInteger(e, "group-port", -1, Validators.MINUS_ONE_OR_GT_ZERO);
    String jgroupsFile = getString(e, "jgroups-file", null, Validators.NO_CHECK);
    String jgroupsChannel = getString(e, "jgroups-channel", null, Validators.NO_CHECK);
    // TODO: validate if either jgroups or UDP is being filled
    BroadcastEndpointFactory endpointFactory;
    if (jgroupsFile != null) {
        endpointFactory = new JGroupsFileBroadcastEndpointFactory().setFile(jgroupsFile).setChannelName(jgroupsChannel);
    } else {
        endpointFactory = new UDPBroadcastEndpointFactory().setGroupAddress(groupAddress).setGroupPort(groupPort).setLocalBindAddress(localAddress).setLocalBindPort(localBindPort);
    }
    BroadcastGroupConfiguration config = new BroadcastGroupConfiguration().setName(name).setBroadcastPeriod(broadcastPeriod).setConnectorInfos(connectorNames).setEndpointFactory(endpointFactory);
    mainConfig.getBroadcastGroupConfigurations().add(config);
}
Also used : NodeList(org.w3c.dom.NodeList) Node(org.w3c.dom.Node) ArrayList(java.util.ArrayList) JGroupsFileBroadcastEndpointFactory(org.apache.activemq.artemis.api.core.JGroupsFileBroadcastEndpointFactory) SimpleString(org.apache.activemq.artemis.api.core.SimpleString) UDPBroadcastEndpointFactory(org.apache.activemq.artemis.api.core.UDPBroadcastEndpointFactory) BroadcastGroupConfiguration(org.apache.activemq.artemis.api.core.BroadcastGroupConfiguration) JGroupsFileBroadcastEndpointFactory(org.apache.activemq.artemis.api.core.JGroupsFileBroadcastEndpointFactory) UDPBroadcastEndpointFactory(org.apache.activemq.artemis.api.core.UDPBroadcastEndpointFactory) BroadcastEndpointFactory(org.apache.activemq.artemis.api.core.BroadcastEndpointFactory)

Example 15 with BroadcastGroupConfiguration

use of org.apache.activemq.artemis.api.core.BroadcastGroupConfiguration in project activemq-artemis by apache.

the class ClusterTestBase method setupLiveServerWithDiscovery.

protected void setupLiveServerWithDiscovery(final int node, final String groupAddress, final int port, final boolean fileStorage, final boolean netty, final boolean sharedStorage) throws Exception {
    if (servers[node] != null) {
        throw new IllegalArgumentException("Already a server at node " + node);
    }
    Map<String, Object> params = generateParams(node, netty);
    TransportConfiguration connector = createTransportConfiguration(netty, false, params);
    List<String> connectorPairs = new ArrayList<>();
    connectorPairs.add(connector.getName());
    UDPBroadcastEndpointFactory endpoint = new UDPBroadcastEndpointFactory().setGroupAddress(groupAddress).setGroupPort(port);
    BroadcastGroupConfiguration bcConfig = new BroadcastGroupConfiguration().setName("bg1").setBroadcastPeriod(200).setConnectorInfos(connectorPairs).setEndpointFactory(endpoint);
    DiscoveryGroupConfiguration dcConfig = new DiscoveryGroupConfiguration().setName("dg1").setRefreshTimeout(1000).setDiscoveryInitialWaitTimeout(1000).setBroadcastEndpointFactory(endpoint);
    Configuration configuration = createBasicConfig(node).setJournalMaxIO_AIO(1000).clearAcceptorConfigurations().addAcceptorConfiguration(createTransportConfiguration(netty, true, params)).addConnectorConfiguration(connector.getName(), connector).addBroadcastGroupConfiguration(bcConfig).addDiscoveryGroupConfiguration(dcConfig.getName(), dcConfig).setHAPolicyConfiguration(sharedStorage ? new SharedStoreMasterPolicyConfiguration() : new ReplicatedPolicyConfiguration());
    ActiveMQServer server;
    if (fileStorage) {
        if (sharedStorage) {
            server = createInVMFailoverServer(true, configuration, nodeManagers[node], node);
        } else {
            server = addServer(ActiveMQServers.newActiveMQServer(configuration));
            server.setIdentity("Server " + node);
        }
    } else {
        if (sharedStorage) {
            server = createInVMFailoverServer(false, configuration, nodeManagers[node], node);
        } else {
            server = addServer(ActiveMQServers.newActiveMQServer(configuration, false));
            server.setIdentity("Server " + node);
        }
    }
    servers[node] = server;
}
Also used : 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) SharedStoreMasterPolicyConfiguration(org.apache.activemq.artemis.core.config.ha.SharedStoreMasterPolicyConfiguration) TransportConfiguration(org.apache.activemq.artemis.api.core.TransportConfiguration) SimpleString(org.apache.activemq.artemis.api.core.SimpleString) DiscoveryGroupConfiguration(org.apache.activemq.artemis.api.core.DiscoveryGroupConfiguration) ActiveMQServer(org.apache.activemq.artemis.core.server.ActiveMQServer) ReplicatedPolicyConfiguration(org.apache.activemq.artemis.core.config.ha.ReplicatedPolicyConfiguration) UDPBroadcastEndpointFactory(org.apache.activemq.artemis.api.core.UDPBroadcastEndpointFactory) BroadcastGroupConfiguration(org.apache.activemq.artemis.api.core.BroadcastGroupConfiguration)

Aggregations

BroadcastGroupConfiguration (org.apache.activemq.artemis.api.core.BroadcastGroupConfiguration)20 ArrayList (java.util.ArrayList)13 UDPBroadcastEndpointFactory (org.apache.activemq.artemis.api.core.UDPBroadcastEndpointFactory)13 DiscoveryGroupConfiguration (org.apache.activemq.artemis.api.core.DiscoveryGroupConfiguration)10 TransportConfiguration (org.apache.activemq.artemis.api.core.TransportConfiguration)10 Configuration (org.apache.activemq.artemis.core.config.Configuration)7 HashMap (java.util.HashMap)6 SimpleString (org.apache.activemq.artemis.api.core.SimpleString)6 BroadcastEndpointFactory (org.apache.activemq.artemis.api.core.BroadcastEndpointFactory)5 SharedStoreMasterPolicyConfiguration (org.apache.activemq.artemis.core.config.ha.SharedStoreMasterPolicyConfiguration)5 ClusterConnectionConfiguration (org.apache.activemq.artemis.core.config.ClusterConnectionConfiguration)4 ModelNode (org.jboss.dmr.ModelNode)4 ActiveMQDefaultConfiguration (org.apache.activemq.artemis.api.config.ActiveMQDefaultConfiguration)3 HAPolicyConfiguration (org.apache.activemq.artemis.core.config.HAPolicyConfiguration)3 LiveOnlyPolicyConfiguration (org.apache.activemq.artemis.core.config.ha.LiveOnlyPolicyConfiguration)3 ActiveMQServer (org.apache.activemq.artemis.core.server.ActiveMQServer)3 HashSet (java.util.HashSet)2 Map (java.util.Map)2 Set (java.util.Set)2 ChannelBroadcastEndpointFactory (org.apache.activemq.artemis.api.core.ChannelBroadcastEndpointFactory)2