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"));
}
}
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");
}
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);
}
Aggregations