Class WeightedRRLCAlgorithm
- java.lang.Object
-
- org.apache.synapse.endpoints.algorithms.WeightedRRLCAlgorithm
-
- All Implemented Interfaces:
Cloneable,LoadbalanceAlgorithm,ManagedLifecycle
public class WeightedRRLCAlgorithm extends Object implements LoadbalanceAlgorithm, ManagedLifecycle
This is a Weighted Round Robin Least Connection algorithm.This algorithm is similar to
WeightedRoundRobinalgorithm except it takes the active connections made by the endpoints in to account. Weights assinged to each endpoint and these are static weights. But depending on the active connections these weights are changed dynamically during the execution.Algorithm assumes that the endpoint connections to total connection ratio should be eqault to endpoint weight to total weights ratio. If the ratios are different it tries to align them by changing the weights dynamically.
-
-
Field Summary
Fields Modifier and Type Field Description static StringLB_WEIGHTED_RRLC_ROUNDS_PER_RECALstatic StringLB_WEIGHTED_RRLC_WEIGHTstatic StringLB_WEIGHTED_RRLC_WEIGHT_MAXstatic StringLB_WEIGHTED_RRLC_WEIGHT_MINstatic intLB_WEIGHTED_RRLC_WEIGHT_SKEW
-
Constructor Summary
Constructors Constructor Description WeightedRRLCAlgorithm()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description LoadbalanceAlgorithmclone()voiddestroy()This method should implement the destroying of the implemented parts of the configuration.intgetCurrentRound()intgetEndpointCursor()StringgetName()Return the name of the load balancing algorithmorg.apache.axis2.clustering.MembergetNextApplicationMember(AlgorithmContext algorithmContext)This method returns the next member to which the request has been sent to, according to the algorithm implementation.EndpointgetNextEndpoint(MessageContext messageContext, AlgorithmContext algorithmContext)This method returns the next node according to the algorithm implementation.intgetRoundsPerRecalculation()intgetTotalConnections()intgetTotalWeight()voidinit(SynapseEnvironment se)This method should implement the initialization of the implemented parts of the configuration.voidreset(AlgorithmContext algorithmContext)Resets the algorithm to its initial position.voidsetApplicationMembers(List<org.apache.axis2.clustering.Member> members)Set the application membersvoidsetEndpoints(List<Endpoint> endpoints)Set the endpointsvoidsetLoadBalanceEndpoint(Endpoint endpoint)Set the loadbalance endpoint
-
-
-
Field Detail
-
LB_WEIGHTED_RRLC_ROUNDS_PER_RECAL
public static final String LB_WEIGHTED_RRLC_ROUNDS_PER_RECAL
- See Also:
- Constant Field Values
-
LB_WEIGHTED_RRLC_WEIGHT
public static final String LB_WEIGHTED_RRLC_WEIGHT
- See Also:
- Constant Field Values
-
LB_WEIGHTED_RRLC_WEIGHT_MIN
public static final String LB_WEIGHTED_RRLC_WEIGHT_MIN
- See Also:
- Constant Field Values
-
LB_WEIGHTED_RRLC_WEIGHT_MAX
public static final String LB_WEIGHTED_RRLC_WEIGHT_MAX
- See Also:
- Constant Field Values
-
LB_WEIGHTED_RRLC_WEIGHT_SKEW
public static final int LB_WEIGHTED_RRLC_WEIGHT_SKEW
- See Also:
- Constant Field Values
-
-
Method Detail
-
setApplicationMembers
public void setApplicationMembers(List<org.apache.axis2.clustering.Member> members)
Description copied from interface:LoadbalanceAlgorithmSet the application members- Specified by:
setApplicationMembersin interfaceLoadbalanceAlgorithm- Parameters:
members- The application members
-
setEndpoints
public void setEndpoints(List<Endpoint> endpoints)
Description copied from interface:LoadbalanceAlgorithmSet the endpoints- Specified by:
setEndpointsin interfaceLoadbalanceAlgorithm- Parameters:
endpoints- The endpoints
-
setLoadBalanceEndpoint
public void setLoadBalanceEndpoint(Endpoint endpoint)
Description copied from interface:LoadbalanceAlgorithmSet the loadbalance endpoint- Specified by:
setLoadBalanceEndpointin interfaceLoadbalanceAlgorithm- Parameters:
endpoint- the endpoint which uses this algorithm
-
getNextEndpoint
public Endpoint getNextEndpoint(MessageContext messageContext, AlgorithmContext algorithmContext)
Description copied from interface:LoadbalanceAlgorithmThis method returns the next node according to the algorithm implementation.- Specified by:
getNextEndpointin interfaceLoadbalanceAlgorithm- Parameters:
messageContext- SynapseMessageContext of the current messagealgorithmContext- The context in which holds run time states related to the algorithm- Returns:
- Next node for directing the message
-
getNextApplicationMember
public org.apache.axis2.clustering.Member getNextApplicationMember(AlgorithmContext algorithmContext)
Description copied from interface:LoadbalanceAlgorithmThis method returns the next member to which the request has been sent to, according to the algorithm implementation.- Specified by:
getNextApplicationMemberin interfaceLoadbalanceAlgorithm- Parameters:
algorithmContext- The context in which holds run time states related to the algorithm- Returns:
- Next application member to which the request has to be sent to
-
reset
public void reset(AlgorithmContext algorithmContext)
Description copied from interface:LoadbalanceAlgorithmResets the algorithm to its initial position. Initial position depends on the implementation.- Specified by:
resetin interfaceLoadbalanceAlgorithm- Parameters:
algorithmContext- The context in which holds run time states related to the algorithm
-
getName
public String getName()
Description copied from interface:LoadbalanceAlgorithmReturn the name of the load balancing algorithm- Specified by:
getNamein interfaceLoadbalanceAlgorithm- Returns:
- the name of the algorithm implemented
-
clone
public LoadbalanceAlgorithm clone()
- Specified by:
clonein interfaceLoadbalanceAlgorithm- Overrides:
clonein classObject
-
getEndpointCursor
public int getEndpointCursor()
-
getRoundsPerRecalculation
public int getRoundsPerRecalculation()
-
getCurrentRound
public int getCurrentRound()
-
getTotalWeight
public int getTotalWeight()
-
getTotalConnections
public int getTotalConnections()
-
init
public void init(SynapseEnvironment se)
Description copied from interface:ManagedLifecycleThis method should implement the initialization of the implemented parts of the configuration.- Specified by:
initin interfaceManagedLifecycle- Parameters:
se- SynapseEnvironment to be used for initialization
-
destroy
public void destroy()
Description copied from interface:ManagedLifecycleThis method should implement the destroying of the implemented parts of the configuration.- Specified by:
destroyin interfaceManagedLifecycle
-
-