Search in sources :

Example 1 with AlgorithmContext

use of org.apache.synapse.endpoints.algorithms.AlgorithmContext in project wso2-synapse by wso2.

the class LoadbalanceEndpoint method init.

@Override
public void init(SynapseEnvironment synapseEnvironment) {
    ConfigurationContext cc = ((Axis2SynapseEnvironment) synapseEnvironment).getAxis2ConfigurationContext();
    if (!initialized) {
        super.init(synapseEnvironment);
        if (algorithmContext == null) {
            algorithmContext = new AlgorithmContext(isClusteringEnabled, cc, getName());
        }
        // initlize the algorithm
        if (algorithm != null && algorithm instanceof ManagedLifecycle) {
            ManagedLifecycle lifecycle = (ManagedLifecycle) algorithm;
            lifecycle.init(synapseEnvironment);
        }
        loadBalanceEPInitialized = true;
        buildMessage = Boolean.parseBoolean(SynapsePropertiesLoader.getPropertyValue(SynapseConstants.BUILD_MESSAGE_ON_FAILOVER, "false"));
    }
}
Also used : ConfigurationContext(org.apache.axis2.context.ConfigurationContext) Axis2SynapseEnvironment(org.apache.synapse.core.axis2.Axis2SynapseEnvironment) AlgorithmContext(org.apache.synapse.endpoints.algorithms.AlgorithmContext) ManagedLifecycle(org.apache.synapse.ManagedLifecycle)

Example 2 with AlgorithmContext

use of org.apache.synapse.endpoints.algorithms.AlgorithmContext in project wso2-synapse by wso2.

the class DynamicLoadbalanceEndpoint method init.

@Override
public void init(SynapseEnvironment synapseEnvironment) {
    ConfigurationContext cc = ((Axis2SynapseEnvironment) synapseEnvironment).getAxis2ConfigurationContext();
    if (!initialized) {
        super.init(synapseEnvironment);
        if (algorithmContext == null) {
            algorithmContext = new AlgorithmContext(isClusteringEnabled, cc, getName());
        }
        // Initialize the SAL Sessions if already has not been initialized.
        SALSessions salSessions = SALSessions.getInstance();
        if (!salSessions.isInitialized()) {
            salSessions.initialize(isClusteringEnabled, cc);
        }
    }
    log.info("Dynamic load balance endpoint initialized");
}
Also used : ConfigurationContext(org.apache.axis2.context.ConfigurationContext) Axis2SynapseEnvironment(org.apache.synapse.core.axis2.Axis2SynapseEnvironment) AlgorithmContext(org.apache.synapse.endpoints.algorithms.AlgorithmContext) SALSessions(org.apache.synapse.endpoints.dispatch.SALSessions)

Example 3 with AlgorithmContext

use of org.apache.synapse.endpoints.algorithms.AlgorithmContext in project wso2-synapse by wso2.

the class ServiceLoadBalanceMembershipHandler method getNextApplicationMember.

public Member getNextApplicationMember(String host) {
    DomainAlgorithmContext domainAlgorithmContext = getDomainAlgorithmContext(host);
    String lbDomain = domainAlgorithmContext.getDomain();
    LoadbalanceAlgorithm algorithm = domainAlgorithmContext.getAlgorithm();
    GroupManagementAgent groupMgtAgent = clusteringAgent.getGroupManagementAgent(lbDomain);
    if (groupMgtAgent == null) {
        String msg = "A LoadBalanceEventHandler has not been specified in the axis2.xml " + "file for the domain " + lbDomain + " for host " + host;
        log.error(msg);
        throw new SynapseException(msg);
    }
    algorithm.setApplicationMembers(groupMgtAgent.getMembers());
    AlgorithmContext context = domainAlgorithmContext.getAlgorithmContext();
    return algorithm.getNextApplicationMember(context);
}
Also used : AlgorithmContext(org.apache.synapse.endpoints.algorithms.AlgorithmContext) SynapseException(org.apache.synapse.SynapseException) GroupManagementAgent(org.apache.axis2.clustering.management.GroupManagementAgent) LoadbalanceAlgorithm(org.apache.synapse.endpoints.algorithms.LoadbalanceAlgorithm)

Aggregations

AlgorithmContext (org.apache.synapse.endpoints.algorithms.AlgorithmContext)3 ConfigurationContext (org.apache.axis2.context.ConfigurationContext)2 Axis2SynapseEnvironment (org.apache.synapse.core.axis2.Axis2SynapseEnvironment)2 GroupManagementAgent (org.apache.axis2.clustering.management.GroupManagementAgent)1 ManagedLifecycle (org.apache.synapse.ManagedLifecycle)1 SynapseException (org.apache.synapse.SynapseException)1 LoadbalanceAlgorithm (org.apache.synapse.endpoints.algorithms.LoadbalanceAlgorithm)1 SALSessions (org.apache.synapse.endpoints.dispatch.SALSessions)1