org.apache.activemq.artemis.core.config.ha.ColocatedPolicyConfiguration

Here are the examples of the java api class org.apache.activemq.artemis.core.config.ha.ColocatedPolicyConfiguration taken from open source projects.

1. FileConfigurationParser#createColocatedHaPolicy()

View license
private ColocatedPolicyConfiguration createColocatedHaPolicy(Element policyNode, boolean replicated) {
    ColocatedPolicyConfiguration configuration = new ColocatedPolicyConfiguration();
    boolean requestBackup = getBoolean(policyNode, "request-backup", configuration.isRequestBackup());
    configuration.setRequestBackup(requestBackup);
    int backupRequestRetries = getInteger(policyNode, "backup-request-retries", configuration.getBackupRequestRetries(), Validators.MINUS_ONE_OR_GE_ZERO);
    configuration.setBackupRequestRetries(backupRequestRetries);
    long backupRequestRetryInterval = getLong(policyNode, "backup-request-retry-interval", configuration.getBackupRequestRetryInterval(), Validators.GT_ZERO);
    configuration.setBackupRequestRetryInterval(backupRequestRetryInterval);
    int maxBackups = getInteger(policyNode, "max-backups", configuration.getMaxBackups(), Validators.GE_ZERO);
    configuration.setMaxBackups(maxBackups);
    int backupPortOffset = getInteger(policyNode, "backup-port-offset", configuration.getBackupPortOffset(), Validators.GT_ZERO);
    configuration.setBackupPortOffset(backupPortOffset);
    NodeList remoteConnectorNode = policyNode.getElementsByTagName("excludes");
    if (remoteConnectorNode != null && remoteConnectorNode.getLength() > 0) {
        NodeList remoteConnectors = remoteConnectorNode.item(0).getChildNodes();
        for (int i = 0; i < remoteConnectors.getLength(); i++) {
            Node child = remoteConnectors.item(i);
            if (child.getNodeName().equals("connector-ref")) {
                String connectorName = getTrimmedTextContent(child);
                configuration.getExcludedConnectors().add(connectorName);
            }
        }
    }
    NodeList masterNodeList = policyNode.getElementsByTagName("master");
    if (masterNodeList.getLength() > 0) {
        Element masterNode = (Element) masterNodeList.item(0);
        configuration.setLiveConfig(replicated ? createReplicatedHaPolicy(masterNode) : createSharedStoreMasterHaPolicy(masterNode));
    }
    NodeList slaveNodeList = policyNode.getElementsByTagName("slave");
    if (slaveNodeList.getLength() > 0) {
        Element slaveNode = (Element) slaveNodeList.item(0);
        configuration.setBackupConfig(replicated ? createReplicaHaPolicy(slaveNode) : createSharedStoreSlaveHaPolicy(slaveNode));
    }
    return configuration;
}

2. AutomaticColocatedQuorumVoteTest#getConfiguration()

View license
private Configuration getConfiguration(String identity, boolean scaleDown, TransportConfiguration liveConnector, TransportConfiguration liveAcceptor, TransportConfiguration... otherLiveNodes) throws Exception {
    Configuration configuration = createDefaultInVMConfig().clearAcceptorConfigurations().addAcceptorConfiguration(liveAcceptor).addConnectorConfiguration(liveConnector.getName(), liveConnector).setJournalDirectory(getJournalDir() + identity).setBindingsDirectory(getBindingsDir() + identity).setLargeMessagesDirectory(getLargeMessagesDir() + identity).setPagingDirectory(getPageDir() + identity).addQueueConfiguration(new CoreQueueConfiguration().setAddress("jms.queue.testQueue").setName("jms.queue.testQueue"));
    List<String> transportConfigurationList = new ArrayList<>();
    final ColocatedPolicyConfiguration haPolicy = new ColocatedPolicyConfiguration();
    for (TransportConfiguration otherLiveNode : otherLiveNodes) {
        configuration.addConnectorConfiguration(otherLiveNode.getName(), otherLiveNode);
        transportConfigurationList.add(otherLiveNode.getName());
        haPolicy.getExcludedConnectors().add(otherLiveNode.getName());
    }
    String[] input = new String[transportConfigurationList.size()];
    transportConfigurationList.toArray(input);
    configuration.addClusterConfiguration(basicClusterConnectionConfig(liveConnector.getName(), input));
    haPolicy.setBackupPortOffset(100);
    haPolicy.setBackupRequestRetries(-1);
    haPolicy.setBackupRequestRetryInterval(500);
    haPolicy.setMaxBackups(1);
    haPolicy.setRequestBackup(true);
    configuration.setHAPolicyConfiguration(haPolicy);
    if (!replicated) {
        SharedStoreMasterPolicyConfiguration ssmc = new SharedStoreMasterPolicyConfiguration();
        SharedStoreSlavePolicyConfiguration sssc = new SharedStoreSlavePolicyConfiguration();
        haPolicy.setLiveConfig(ssmc);
        haPolicy.setBackupConfig(sssc);
        if (scaleDown) {
            sssc.setScaleDownConfiguration(new ScaleDownConfiguration());
        }
    } else {
        ReplicatedPolicyConfiguration rpc = new ReplicatedPolicyConfiguration();
        ReplicaPolicyConfiguration rpc2 = new ReplicaPolicyConfiguration();
        haPolicy.setLiveConfig(rpc);
        haPolicy.setBackupConfig(rpc2);
        if (scaleDown) {
            rpc2.setScaleDownConfiguration(new ScaleDownConfiguration());
        }
    }
    return configuration;
}

3. HAAutomaticBackupSharedStore#setUpHAPolicy()

View license
private void setUpHAPolicy(int node) {
    ActiveMQServer server = getServer(node);
    ColocatedPolicyConfiguration haPolicyConfiguration = new ColocatedPolicyConfiguration();
    HAPolicyConfiguration liveConfiguration = new SharedStoreMasterPolicyConfiguration();
    haPolicyConfiguration.setLiveConfig(liveConfiguration);
    HAPolicyConfiguration backupConfiguration = new SharedStoreSlavePolicyConfiguration();
    haPolicyConfiguration.setBackupConfig(backupConfiguration);
    server.getConfiguration().setHAPolicyConfiguration(haPolicyConfiguration);
}