use of org.apache.activemq.artemis.core.config.ScaleDownConfiguration in project wildfly by wildfly.
the class ScaleDownAttributes method addScaleDownConfiguration.
static ScaleDownConfiguration addScaleDownConfiguration(OperationContext context, ModelNode model) throws OperationFailedException {
if (!model.hasDefined(SCALE_DOWN.getName())) {
return null;
}
ScaleDownConfiguration scaleDownConfiguration = new ScaleDownConfiguration();
scaleDownConfiguration.setEnabled(SCALE_DOWN.resolveModelAttribute(context, model).asBoolean());
ModelNode clusterName = SCALE_DOWN_CLUSTER_NAME.resolveModelAttribute(context, model);
if (clusterName.isDefined()) {
scaleDownConfiguration.setClusterName(clusterName.asString());
}
ModelNode groupName = SCALE_DOWN_GROUP_NAME.resolveModelAttribute(context, model);
if (groupName.isDefined()) {
scaleDownConfiguration.setGroupName(groupName.asString());
}
ModelNode discoveryGroupName = SCALE_DOWN_DISCOVERY_GROUP.resolveModelAttribute(context, model);
if (discoveryGroupName.isDefined()) {
scaleDownConfiguration.setDiscoveryGroup(discoveryGroupName.asString());
}
ModelNode connectors = SCALE_DOWN_CONNECTORS.resolveModelAttribute(context, model);
if (connectors.isDefined()) {
List<String> connectorNames = new ArrayList<>(connectors.keys());
scaleDownConfiguration.setConnectors(connectorNames);
}
return scaleDownConfiguration;
}
use of org.apache.activemq.artemis.core.config.ScaleDownConfiguration in project activemq-artemis by apache.
the class FileConfigurationParser method parseScaleDownConfig.
private ScaleDownConfiguration parseScaleDownConfig(Element policyNode) {
NodeList scaleDownNode = policyNode.getElementsByTagName("scale-down");
if (scaleDownNode.getLength() > 0) {
ScaleDownConfiguration scaleDownConfiguration = new ScaleDownConfiguration();
Element scaleDownElement = (Element) scaleDownNode.item(0);
scaleDownConfiguration.setEnabled(getBoolean(scaleDownElement, "enabled", scaleDownConfiguration.isEnabled()));
NodeList discoveryGroupRef = scaleDownElement.getElementsByTagName("discovery-group-ref");
if (discoveryGroupRef.item(0) != null) {
scaleDownConfiguration.setDiscoveryGroup(discoveryGroupRef.item(0).getAttributes().getNamedItem("discovery-group-name").getNodeValue());
}
String scaleDownGroupName = getString(scaleDownElement, "group-name", scaleDownConfiguration.getGroupName(), Validators.NO_CHECK);
scaleDownConfiguration.setGroupName(scaleDownGroupName);
NodeList scaleDownConnectorNode = scaleDownElement.getElementsByTagName("connectors");
if (scaleDownConnectorNode != null && scaleDownConnectorNode.getLength() > 0) {
NodeList scaleDownConnectors = scaleDownConnectorNode.item(0).getChildNodes();
for (int i = 0; i < scaleDownConnectors.getLength(); i++) {
Node child = scaleDownConnectors.item(i);
if (child.getNodeName().equals("connector-ref")) {
String connectorName = getTrimmedTextContent(child);
scaleDownConfiguration.getConnectors().add(connectorName);
}
}
}
return scaleDownConfiguration;
}
return null;
}
use of org.apache.activemq.artemis.core.config.ScaleDownConfiguration in project activemq-artemis by apache.
the class ScaleDownFailoverTest method setUp.
@Override
@Before
public void setUp() throws Exception {
super.setUp();
stopCount = 0;
setupLiveServer(0, isFileStorage(), false, isNetty(), true);
setupLiveServer(1, isFileStorage(), false, isNetty(), true);
setupLiveServer(2, isFileStorage(), false, isNetty(), true);
ScaleDownConfiguration scaleDownConfiguration = new ScaleDownConfiguration();
ScaleDownConfiguration scaleDownConfiguration2 = new ScaleDownConfiguration();
scaleDownConfiguration2.setEnabled(false);
ScaleDownConfiguration scaleDownConfiguration3 = new ScaleDownConfiguration();
scaleDownConfiguration3.setEnabled(false);
((LiveOnlyPolicyConfiguration) servers[0].getConfiguration().getHAPolicyConfiguration()).setScaleDownConfiguration(scaleDownConfiguration);
((LiveOnlyPolicyConfiguration) servers[1].getConfiguration().getHAPolicyConfiguration()).setScaleDownConfiguration(scaleDownConfiguration2);
((LiveOnlyPolicyConfiguration) servers[2].getConfiguration().getHAPolicyConfiguration()).setScaleDownConfiguration(scaleDownConfiguration3);
if (isGrouped()) {
scaleDownConfiguration.setGroupName("bill");
scaleDownConfiguration2.setGroupName("bill");
scaleDownConfiguration3.setGroupName("bill");
}
staticServers = servers;
setupClusterConnection("cluster0", "queues", MessageLoadBalancingType.ON_DEMAND, 1, isNetty(), 0, 1, 2);
setupClusterConnection("cluster1", "queues", MessageLoadBalancingType.ON_DEMAND, 1, isNetty(), 1, 0, 2);
setupClusterConnection("cluster2", "queues", MessageLoadBalancingType.ON_DEMAND, 1, isNetty(), 2, 0, 1);
scaleDownConfiguration.getConnectors().addAll(servers[0].getConfiguration().getClusterConfigurations().iterator().next().getStaticConnectors());
scaleDownConfiguration2.getConnectors().addAll(servers[1].getConfiguration().getClusterConfigurations().iterator().next().getStaticConnectors());
scaleDownConfiguration3.getConnectors().addAll(servers[2].getConfiguration().getClusterConfigurations().iterator().next().getStaticConnectors());
startServers(0, 1, 2);
setupSessionFactory(0, isNetty());
setupSessionFactory(1, isNetty());
setupSessionFactory(2, isNetty());
}
use of org.apache.activemq.artemis.core.config.ScaleDownConfiguration in project activemq-artemis by apache.
the class ScaleDownFailureTest method setUp.
@Override
@Before
public void setUp() throws Exception {
super.setUp();
setupLiveServer(0, isFileStorage(), false, isNetty(), true);
setupLiveServer(1, isFileStorage(), false, isNetty(), true);
if (isGrouped()) {
ScaleDownConfiguration scaleDownConfiguration = new ScaleDownConfiguration();
scaleDownConfiguration.setGroupName("bill");
((LiveOnlyPolicyConfiguration) servers[0].getConfiguration().getHAPolicyConfiguration()).setScaleDownConfiguration(scaleDownConfiguration);
((LiveOnlyPolicyConfiguration) servers[1].getConfiguration().getHAPolicyConfiguration()).setScaleDownConfiguration(scaleDownConfiguration);
}
setupClusterConnection("cluster0", "queues", MessageLoadBalancingType.ON_DEMAND, 1, isNetty(), 0, 1);
setupClusterConnection("cluster1", "queues", MessageLoadBalancingType.ON_DEMAND, 1, isNetty(), 1, 0);
startServers(0, 1);
setupSessionFactory(0, isNetty());
setupSessionFactory(1, isNetty());
}
use of org.apache.activemq.artemis.core.config.ScaleDownConfiguration in project activemq-artemis by apache.
the class LiveToLiveFailoverTest method createConfigs.
@Override
protected void createConfigs() throws Exception {
nodeManager0 = new InVMNodeManager(false);
nodeManager1 = new InVMNodeManager(false);
TransportConfiguration liveConnector0 = getConnectorTransportConfiguration(true, 0);
TransportConfiguration liveConnector1 = getConnectorTransportConfiguration(true, 1);
backupConfig = super.createDefaultInVMConfig(1).clearAcceptorConfigurations().addAcceptorConfiguration(getAcceptorTransportConfiguration(true, 1)).setHAPolicyConfiguration(new ColocatedPolicyConfiguration().setRequestBackup(true).setLiveConfig(new SharedStoreMasterPolicyConfiguration()).setBackupConfig(new SharedStoreSlavePolicyConfiguration().setScaleDownConfiguration(new ScaleDownConfiguration().addConnector(liveConnector1.getName())))).addConnectorConfiguration(liveConnector0.getName(), liveConnector0).addConnectorConfiguration(liveConnector1.getName(), liveConnector1).addClusterConfiguration(basicClusterConnectionConfig(liveConnector1.getName(), liveConnector0.getName()));
backupServer = createColocatedTestableServer(backupConfig, nodeManager1, nodeManager0, 1);
liveConfig = super.createDefaultInVMConfig(0).clearAcceptorConfigurations().addAcceptorConfiguration(getAcceptorTransportConfiguration(true, 0)).setHAPolicyConfiguration(new ColocatedPolicyConfiguration().setRequestBackup(true).setBackupRequestRetryInterval(1000).setLiveConfig(new SharedStoreMasterPolicyConfiguration()).setBackupConfig(new SharedStoreSlavePolicyConfiguration().setScaleDownConfiguration(new ScaleDownConfiguration()))).addConnectorConfiguration(liveConnector0.getName(), liveConnector0).addConnectorConfiguration(liveConnector1.getName(), liveConnector1).addClusterConfiguration(basicClusterConnectionConfig(liveConnector0.getName(), liveConnector1.getName()));
liveServer = createColocatedTestableServer(liveConfig, nodeManager0, nodeManager1, 0);
}
Aggregations