Class WeightedRoundRobin
- java.lang.Object
-
- org.apache.synapse.endpoints.algorithms.WeightedRoundRobin
-
- All Implemented Interfaces:
Cloneable,LoadbalanceAlgorithm,ManagedLifecycle
public class WeightedRoundRobin extends Object implements LoadbalanceAlgorithm, ManagedLifecycle
This algorithm sends messages based on the weights of the endpoints. For example we may have 3 endpoints with following weights.- Epr 1: 5
- Epr 2: 3
- Epr 3: 2
This algorithm will send the first 5 messages through Epr1, next 3 messages through Epr2 and next 2 messages with Epr3. Then algorithm moves again to the first endpoint and cycle continues.
-
-
Constructor Summary
Constructors Constructor Description WeightedRoundRobin()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidchangeWeight(int pos, int weight)LoadbalanceAlgorithmclone()voiddestroy()This method should implement the destroying of the implemented parts of the configuration.int[]getCurrentWeights()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 synapseMessageContext, AlgorithmContext algorithmContext)This method returns the next node according to the algorithm implementation.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)we are not supporting membersvoidsetEndpoints(List<Endpoint> endpoints)Set the endpointsvoidsetLoadBalanceEndpoint(Endpoint endpoint)Set the loadbalance endpoint
-
-
-
Method Detail
-
setApplicationMembers
public void setApplicationMembers(List<org.apache.axis2.clustering.Member> members)
we are not supporting 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 synapseMessageContext, AlgorithmContext algorithmContext)
Description copied from interface:LoadbalanceAlgorithmThis method returns the next node according to the algorithm implementation.- Specified by:
getNextEndpointin interfaceLoadbalanceAlgorithm- Parameters:
synapseMessageContext- 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
-
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
-
changeWeight
public void changeWeight(int pos, int weight)
-
getCurrentWeights
public int[] getCurrentWeights()
-
-