use of org.apache.activemq.artemis.api.core.DiscoveryGroupConfiguration in project wildfly by wildfly.
the class DiscoveryGroupAdd method createDiscoveryGroupConfiguration.
static DiscoveryGroupConfiguration createDiscoveryGroupConfiguration(final OperationContext context, final String name, final ModelNode model) throws OperationFailedException {
final long refreshTimeout = DiscoveryGroupDefinition.REFRESH_TIMEOUT.resolveModelAttribute(context, model).asLong();
final long initialWaitTimeout = DiscoveryGroupDefinition.INITIAL_WAIT_TIMEOUT.resolveModelAttribute(context, model).asLong();
return new DiscoveryGroupConfiguration().setName(name).setRefreshTimeout(refreshTimeout).setDiscoveryInitialWaitTimeout(initialWaitTimeout);
}
use of org.apache.activemq.artemis.api.core.DiscoveryGroupConfiguration in project activemq-artemis by apache.
the class FileConfigurationParser method parseDiscoveryGroupConfiguration.
private void parseDiscoveryGroupConfiguration(final Element e, final Configuration mainConfig) {
String name = e.getAttribute("name");
long discoveryInitialWaitTimeout = getLong(e, "initial-wait-timeout", ActiveMQClient.DEFAULT_DISCOVERY_INITIAL_WAIT_TIMEOUT, Validators.GT_ZERO);
long refreshTimeout = getLong(e, "refresh-timeout", ActiveMQDefaultConfiguration.getDefaultBroadcastRefreshTimeout(), Validators.GT_ZERO);
String localBindAddress = 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(localBindAddress).setLocalBindPort(localBindPort);
}
DiscoveryGroupConfiguration config = new DiscoveryGroupConfiguration().setName(name).setRefreshTimeout(refreshTimeout).setDiscoveryInitialWaitTimeout(discoveryInitialWaitTimeout).setBroadcastEndpointFactory(endpointFactory);
if (mainConfig.getDiscoveryGroupConfigurations().containsKey(name)) {
ActiveMQServerLogger.LOGGER.discoveryGroupAlreadyDeployed(name);
return;
} else {
mainConfig.getDiscoveryGroupConfigurations().put(name, config);
}
}
use of org.apache.activemq.artemis.api.core.DiscoveryGroupConfiguration in project activemq-artemis by apache.
the class UDPServerLocatorSchema method internalNewObject.
@Override
protected ServerLocator internalNewObject(URI uri, Map<String, String> query, String name) throws Exception {
ConnectionOptions options = newConnectionOptions(uri, query);
DiscoveryGroupConfiguration dgc = getDiscoveryGroupConfiguration(uri, query, getHost(uri), getPort(uri), name);
if (options.isHa()) {
return ActiveMQClient.createServerLocatorWithHA(dgc);
} else {
return ActiveMQClient.createServerLocatorWithoutHA(dgc);
}
}
use of org.apache.activemq.artemis.api.core.DiscoveryGroupConfiguration in project activemq-artemis by apache.
the class ClusterManager method deployClusterConnection.
private void deployClusterConnection(final ClusterConnectionConfiguration config) throws Exception {
if (!config.validateConfiguration()) {
return;
}
TransportConfiguration connector = config.getTransportConfiguration(configuration);
if (connector == null) {
return;
}
if (clusterConnections.containsKey(config.getName())) {
ActiveMQServerLogger.LOGGER.clusterConnectionAlreadyExists(config.getConnectorName());
return;
}
ClusterConnectionImpl clusterConnection;
if (config.getDiscoveryGroupName() != null) {
DiscoveryGroupConfiguration dg = config.getDiscoveryGroupConfiguration(configuration);
if (dg == null)
return;
if (logger.isDebugEnabled()) {
logger.debug(this + " Starting a Discovery Group Cluster Connection, name=" + config.getDiscoveryGroupName() + ", dg=" + dg);
}
clusterConnection = new ClusterConnectionImpl(this, dg, connector, new SimpleString(config.getName()), new SimpleString(config.getAddress() != null ? config.getAddress() : ""), config.getMinLargeMessageSize(), config.getClientFailureCheckPeriod(), config.getConnectionTTL(), config.getRetryInterval(), config.getRetryIntervalMultiplier(), config.getMaxRetryInterval(), config.getInitialConnectAttempts(), config.getReconnectAttempts(), config.getCallTimeout(), config.getCallFailoverTimeout(), config.isDuplicateDetection(), config.getMessageLoadBalancingType(), config.getConfirmationWindowSize(), config.getProducerWindowSize(), executorFactory, server, postOffice, managementService, scheduledExecutor, config.getMaxHops(), nodeManager, server.getConfiguration().getClusterUser(), server.getConfiguration().getClusterPassword(), config.isAllowDirectConnectionsOnly(), config.getClusterNotificationInterval(), config.getClusterNotificationAttempts());
clusterController.addClusterConnection(clusterConnection.getName(), dg, config);
} else {
TransportConfiguration[] tcConfigs = config.getTransportConfigurations(configuration);
if (logger.isDebugEnabled()) {
logger.debug(this + " defining cluster connection towards " + Arrays.toString(tcConfigs));
}
clusterConnection = new ClusterConnectionImpl(this, tcConfigs, connector, new SimpleString(config.getName()), new SimpleString(config.getAddress()), config.getMinLargeMessageSize(), config.getClientFailureCheckPeriod(), config.getConnectionTTL(), config.getRetryInterval(), config.getRetryIntervalMultiplier(), config.getMaxRetryInterval(), config.getInitialConnectAttempts(), config.getReconnectAttempts(), config.getCallTimeout(), config.getCallFailoverTimeout(), config.isDuplicateDetection(), config.getMessageLoadBalancingType(), config.getConfirmationWindowSize(), config.getProducerWindowSize(), executorFactory, server, postOffice, managementService, scheduledExecutor, config.getMaxHops(), nodeManager, server.getConfiguration().getClusterUser(), server.getConfiguration().getClusterPassword(), config.isAllowDirectConnectionsOnly(), config.getClusterNotificationInterval(), config.getClusterNotificationAttempts());
clusterController.addClusterConnection(clusterConnection.getName(), tcConfigs, config);
}
if (defaultClusterConnection == null) {
defaultClusterConnection = clusterConnection;
clusterController.setDefaultClusterConnectionName(defaultClusterConnection.getName());
}
managementService.registerCluster(clusterConnection, config);
clusterConnections.put(config.getName(), clusterConnection);
if (logger.isTraceEnabled()) {
logger.trace("ClusterConnection.start at " + clusterConnection, new Exception("trace"));
}
}
use of org.apache.activemq.artemis.api.core.DiscoveryGroupConfiguration in project activemq-artemis by apache.
the class HAClientTopologyWithDiscoveryTest method createHAServerLocator.
@Override
protected ServerLocator createHAServerLocator() {
ServerLocator locator = ActiveMQClient.createServerLocatorWithHA(new DiscoveryGroupConfiguration().setBroadcastEndpointFactory(new UDPBroadcastEndpointFactory().setGroupAddress(groupAddress).setGroupPort(groupPort)));
locator.setBlockOnNonDurableSend(true).setBlockOnDurableSend(true);
addServerLocator(locator);
return locator;
}
Aggregations