Search in sources :

Example 1 with ScaleDownConfiguration

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;
}
Also used : ScaleDownConfiguration(org.apache.activemq.artemis.core.config.ScaleDownConfiguration) ArrayList(java.util.ArrayList) ModelNode(org.jboss.dmr.ModelNode)

Example 2 with 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;
}
Also used : ScaleDownConfiguration(org.apache.activemq.artemis.core.config.ScaleDownConfiguration) NodeList(org.w3c.dom.NodeList) Element(org.w3c.dom.Element) Node(org.w3c.dom.Node) SimpleString(org.apache.activemq.artemis.api.core.SimpleString)

Example 3 with ScaleDownConfiguration

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());
}
Also used : LiveOnlyPolicyConfiguration(org.apache.activemq.artemis.core.config.ha.LiveOnlyPolicyConfiguration) ScaleDownConfiguration(org.apache.activemq.artemis.core.config.ScaleDownConfiguration) Before(org.junit.Before)

Example 4 with ScaleDownConfiguration

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());
}
Also used : LiveOnlyPolicyConfiguration(org.apache.activemq.artemis.core.config.ha.LiveOnlyPolicyConfiguration) ScaleDownConfiguration(org.apache.activemq.artemis.core.config.ScaleDownConfiguration) Before(org.junit.Before)

Example 5 with ScaleDownConfiguration

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);
}
Also used : InVMNodeManager(org.apache.activemq.artemis.core.server.impl.InVMNodeManager) ScaleDownConfiguration(org.apache.activemq.artemis.core.config.ScaleDownConfiguration) ColocatedPolicyConfiguration(org.apache.activemq.artemis.core.config.ha.ColocatedPolicyConfiguration) SharedStoreSlavePolicyConfiguration(org.apache.activemq.artemis.core.config.ha.SharedStoreSlavePolicyConfiguration) SharedStoreMasterPolicyConfiguration(org.apache.activemq.artemis.core.config.ha.SharedStoreMasterPolicyConfiguration) TransportConfiguration(org.apache.activemq.artemis.api.core.TransportConfiguration)

Aggregations

ScaleDownConfiguration (org.apache.activemq.artemis.core.config.ScaleDownConfiguration)9 LiveOnlyPolicyConfiguration (org.apache.activemq.artemis.core.config.ha.LiveOnlyPolicyConfiguration)4 Before (org.junit.Before)4 TransportConfiguration (org.apache.activemq.artemis.api.core.TransportConfiguration)3 SharedStoreMasterPolicyConfiguration (org.apache.activemq.artemis.core.config.ha.SharedStoreMasterPolicyConfiguration)3 SharedStoreSlavePolicyConfiguration (org.apache.activemq.artemis.core.config.ha.SharedStoreSlavePolicyConfiguration)3 ArrayList (java.util.ArrayList)2 SimpleString (org.apache.activemq.artemis.api.core.SimpleString)2 ColocatedPolicyConfiguration (org.apache.activemq.artemis.core.config.ha.ColocatedPolicyConfiguration)2 InVMNodeManager (org.apache.activemq.artemis.core.server.impl.InVMNodeManager)2 Configuration (org.apache.activemq.artemis.core.config.Configuration)1 CoreQueueConfiguration (org.apache.activemq.artemis.core.config.CoreQueueConfiguration)1 ReplicaPolicyConfiguration (org.apache.activemq.artemis.core.config.ha.ReplicaPolicyConfiguration)1 ReplicatedPolicyConfiguration (org.apache.activemq.artemis.core.config.ha.ReplicatedPolicyConfiguration)1 AddressSettings (org.apache.activemq.artemis.core.settings.impl.AddressSettings)1 ModelNode (org.jboss.dmr.ModelNode)1 Element (org.w3c.dom.Element)1 Node (org.w3c.dom.Node)1 NodeList (org.w3c.dom.NodeList)1