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