use of org.apache.activemq.artemis.core.config.ClusterConnectionConfiguration in project activemq-artemis by apache.
the class FileConfigurationParser method parseClusterConnectionConfiguration.
private void parseClusterConnectionConfiguration(final Element e, final Configuration mainConfig) throws Exception {
String name = e.getAttribute("name");
String address = getString(e, "address", "", Validators.NO_CHECK);
String connectorName = getString(e, "connector-ref", null, Validators.NOT_NULL_OR_EMPTY);
if (!mainConfig.getConnectorConfigurations().containsKey(connectorName)) {
ActiveMQServerLogger.LOGGER.connectorRefNotFound(connectorName, name);
return;
}
boolean duplicateDetection = getBoolean(e, "use-duplicate-detection", ActiveMQDefaultConfiguration.isDefaultClusterDuplicateDetection());
MessageLoadBalancingType messageLoadBalancingType;
if (parameterExists(e, "forward-when-no-consumers")) {
boolean forwardWhenNoConsumers = getBoolean(e, "forward-when-no-consumers", ActiveMQDefaultConfiguration.isDefaultClusterForwardWhenNoConsumers());
if (forwardWhenNoConsumers) {
messageLoadBalancingType = MessageLoadBalancingType.STRICT;
} else {
messageLoadBalancingType = MessageLoadBalancingType.ON_DEMAND;
}
} else {
messageLoadBalancingType = Enum.valueOf(MessageLoadBalancingType.class, getString(e, "message-load-balancing", ActiveMQDefaultConfiguration.getDefaultClusterMessageLoadBalancingType(), Validators.MESSAGE_LOAD_BALANCING_TYPE));
}
int maxHops = getInteger(e, "max-hops", ActiveMQDefaultConfiguration.getDefaultClusterMaxHops(), Validators.GE_ZERO);
long clientFailureCheckPeriod = getLong(e, "check-period", ActiveMQDefaultConfiguration.getDefaultClusterFailureCheckPeriod(), Validators.GT_ZERO);
long connectionTTL = getLong(e, "connection-ttl", ActiveMQDefaultConfiguration.getDefaultClusterConnectionTtl(), Validators.GT_ZERO);
long retryInterval = getLong(e, "retry-interval", ActiveMQDefaultConfiguration.getDefaultClusterRetryInterval(), Validators.GT_ZERO);
long callTimeout = getLong(e, "call-timeout", ActiveMQClient.DEFAULT_CALL_TIMEOUT, Validators.GT_ZERO);
long callFailoverTimeout = getLong(e, "call-failover-timeout", ActiveMQClient.DEFAULT_CALL_FAILOVER_TIMEOUT, Validators.MINUS_ONE_OR_GT_ZERO);
double retryIntervalMultiplier = getDouble(e, "retry-interval-multiplier", ActiveMQDefaultConfiguration.getDefaultClusterRetryIntervalMultiplier(), Validators.GT_ZERO);
int minLargeMessageSize = getTextBytesAsIntBytes(e, "min-large-message-size", ActiveMQClient.DEFAULT_MIN_LARGE_MESSAGE_SIZE, Validators.GT_ZERO);
long maxRetryInterval = getLong(e, "max-retry-interval", ActiveMQDefaultConfiguration.getDefaultClusterMaxRetryInterval(), Validators.GT_ZERO);
int initialConnectAttempts = getInteger(e, "initial-connect-attempts", ActiveMQDefaultConfiguration.getDefaultClusterInitialConnectAttempts(), Validators.MINUS_ONE_OR_GE_ZERO);
int reconnectAttempts = getInteger(e, "reconnect-attempts", ActiveMQDefaultConfiguration.getDefaultClusterReconnectAttempts(), Validators.MINUS_ONE_OR_GE_ZERO);
int confirmationWindowSize = getTextBytesAsIntBytes(e, "confirmation-window-size", ActiveMQDefaultConfiguration.getDefaultClusterConfirmationWindowSize(), Validators.GT_ZERO);
int producerWindowSize = getTextBytesAsIntBytes(e, "producer-window-size", ActiveMQDefaultConfiguration.getDefaultBridgeProducerWindowSize(), Validators.MINUS_ONE_OR_GT_ZERO);
long clusterNotificationInterval = getLong(e, "notification-interval", ActiveMQDefaultConfiguration.getDefaultClusterNotificationInterval(), Validators.GT_ZERO);
int clusterNotificationAttempts = getInteger(e, "notification-attempts", ActiveMQDefaultConfiguration.getDefaultClusterNotificationAttempts(), Validators.GT_ZERO);
String scaleDownConnector = e.getAttribute("scale-down-connector");
String discoveryGroupName = null;
List<String> staticConnectorNames = new ArrayList<>();
boolean allowDirectConnectionsOnly = false;
NodeList children = e.getChildNodes();
for (int j = 0; j < children.getLength(); j++) {
Node child = children.item(j);
if (child.getNodeName().equals("discovery-group-ref")) {
discoveryGroupName = child.getAttributes().getNamedItem("discovery-group-name").getNodeValue();
} else if (child.getNodeName().equals("static-connectors")) {
Node attr = child.getAttributes().getNamedItem("allow-direct-connections-only");
if (attr != null) {
allowDirectConnectionsOnly = "true".equalsIgnoreCase(attr.getNodeValue()) || allowDirectConnectionsOnly;
}
getStaticConnectors(staticConnectorNames, child);
}
}
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).setMaxHops(maxHops).setConfirmationWindowSize(confirmationWindowSize).setProducerWindowSize(producerWindowSize).setAllowDirectConnectionsOnly(allowDirectConnectionsOnly).setClusterNotificationInterval(clusterNotificationInterval).setClusterNotificationAttempts(clusterNotificationAttempts);
if (discoveryGroupName == null) {
config.setStaticConnectors(staticConnectorNames);
} else {
config.setDiscoveryGroupName(discoveryGroupName);
}
mainConfig.getClusterConfigurations().add(config);
}
use of org.apache.activemq.artemis.core.config.ClusterConnectionConfiguration in project activemq-artemis by apache.
the class ConfigurationImpl method addClusterConfiguration.
@Override
public ClusterConnectionConfiguration addClusterConfiguration(String name, String uri) throws Exception {
ClusterConnectionConfiguration newConfig = new ClusterConnectionConfiguration(new URI(uri)).setName(name);
clusterConfigurations.add(newConfig);
return newConfig;
}
use of org.apache.activemq.artemis.core.config.ClusterConnectionConfiguration in project activemq-artemis by apache.
the class BackupManager method start.
/*
* Start the backup manager if not already started. This entails deploying a backup connector based on a cluster
* configuration, informing the cluster manager so that it can add it to its topology and announce itself to the cluster.
* */
@Override
public synchronized void start() throws Exception {
if (started)
return;
// deploy the backup connectors using the cluster configuration
for (ClusterConnectionConfiguration config : configuration.getClusterConfigurations()) {
deployBackupConnector(config);
}
// as we wait for replication to start and be notified by the replication manager.
for (BackupConnector conn : backupConnectors) {
conn.start();
if (server.getHAPolicy().isBackup() && server.getHAPolicy().isSharedStore()) {
conn.informTopology();
conn.announceBackup();
}
}
started = true;
}
use of org.apache.activemq.artemis.core.config.ClusterConnectionConfiguration in project activemq-artemis by apache.
the class FailoverTestBase method adaptLiveConfigForReplicatedFailBack.
protected final void adaptLiveConfigForReplicatedFailBack(TestableServer server) {
Configuration configuration = server.getServer().getConfiguration();
final TransportConfiguration backupConnector = getConnectorTransportConfiguration(false);
if (server.getServer().getHAPolicy().isSharedStore()) {
ClusterConnectionConfiguration cc = configuration.getClusterConfigurations().get(0);
Assert.assertNotNull("cluster connection configuration", cc);
Assert.assertNotNull("static connectors", cc.getStaticConnectors());
cc.getStaticConnectors().add(backupConnector.getName());
// backupConnector is only necessary for fail-back tests
configuration.getConnectorConfigurations().put(backupConnector.getName(), backupConnector);
return;
}
ReplicatedPolicy haPolicy = (ReplicatedPolicy) server.getServer().getHAPolicy();
haPolicy.setCheckForLiveServer(true);
}
use of org.apache.activemq.artemis.core.config.ClusterConnectionConfiguration in project activemq-artemis by apache.
the class IsolatedTopologyTest method createServer2.
private ActiveMQServer createServer2() 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, "3");
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, "4");
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);
List<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);
// Server2 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(2).addAcceptorConfiguration(acceptor1VM1).addAcceptorConfiguration(acceptor2VM1).addConnectorConfiguration("local-cc1", createInVMTransportConnectorConfig(3, "local-cc1")).addConnectorConfiguration("local-cc2", createInVMTransportConnectorConfig(4, "local-cc2")).addConnectorConfiguration("other-cc1", createInVMTransportConnectorConfig(1, "other-cc1")).addConnectorConfiguration("other-cc2", createInVMTransportConnectorConfig(2, "other-cc2")).addClusterConfiguration(server1CC1).addClusterConfiguration(server1CC2);
return createServer(false, config1);
}
Aggregations