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);
}
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);
}
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()));
}
}
}
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);
}
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;
}
Aggregations