Class RoundRobin
- java.lang.Object
-
- org.apache.synapse.endpoints.algorithms.RoundRobin
-
- All Implemented Interfaces:
Cloneable
,LoadbalanceAlgorithm
public class RoundRobin extends Object implements LoadbalanceAlgorithm
This is the implementation of the round robin load balancing algorithm. It simply iterates through the endpoint list one by one for until an active endpoint is found.
-
-
Constructor Summary
Constructors Constructor Description RoundRobin()
RoundRobin(List endpoints)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description LoadbalanceAlgorithm
clone()
String
getName()
Return the name of the load balancing algorithmorg.apache.axis2.clustering.Member
getNextApplicationMember(AlgorithmContext algorithmContext)
This method returns the next member to which the request has been sent to, according to the algorithm implementation.Endpoint
getNextEndpoint(MessageContext synCtx, AlgorithmContext algorithmContext)
Choose an active endpoint using the round robin algorithm.void
reset(AlgorithmContext algorithmContext)
Resets the algorithm to its initial position.void
setApplicationMembers(List<org.apache.axis2.clustering.Member> members)
Set the application membersvoid
setEndpoints(List<Endpoint> endpoints)
Set the endpointsvoid
setLoadBalanceEndpoint(Endpoint endpoint)
Set the loadbalance endpoint
-
-
-
Constructor Detail
-
RoundRobin
public RoundRobin()
-
RoundRobin
public RoundRobin(List endpoints)
-
-
Method Detail
-
setApplicationMembers
public void setApplicationMembers(List<org.apache.axis2.clustering.Member> members)
Description copied from interface:LoadbalanceAlgorithm
Set the application members- Specified by:
setApplicationMembers
in interfaceLoadbalanceAlgorithm
- Parameters:
members
- The application members
-
setEndpoints
public void setEndpoints(List<Endpoint> endpoints)
Description copied from interface:LoadbalanceAlgorithm
Set the endpoints- Specified by:
setEndpoints
in interfaceLoadbalanceAlgorithm
- Parameters:
endpoints
- The endpoints
-
setLoadBalanceEndpoint
public void setLoadBalanceEndpoint(Endpoint endpoint)
Description copied from interface:LoadbalanceAlgorithm
Set the loadbalance endpoint- Specified by:
setLoadBalanceEndpoint
in interfaceLoadbalanceAlgorithm
- Parameters:
endpoint
- the endpoint which uses this algorithm
-
getNextEndpoint
public Endpoint getNextEndpoint(MessageContext synCtx, AlgorithmContext algorithmContext)
Choose an active endpoint using the round robin algorithm. If there are no active endpoints available, returns null.- Specified by:
getNextEndpoint
in interfaceLoadbalanceAlgorithm
- Parameters:
synCtx
- MessageContext instance which holds all per-message propertiesalgorithmContext
- The context in which holds run time states related to the algorithm- Returns:
- endpoint to send the next message
-
getNextApplicationMember
public org.apache.axis2.clustering.Member getNextApplicationMember(AlgorithmContext algorithmContext)
Description copied from interface:LoadbalanceAlgorithm
This method returns the next member to which the request has been sent to, according to the algorithm implementation.- Specified by:
getNextApplicationMember
in 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
-
clone
public LoadbalanceAlgorithm clone()
- Specified by:
clone
in interfaceLoadbalanceAlgorithm
- Overrides:
clone
in classObject
-
reset
public void reset(AlgorithmContext algorithmContext)
Description copied from interface:LoadbalanceAlgorithm
Resets the algorithm to its initial position. Initial position depends on the implementation.- Specified by:
reset
in interfaceLoadbalanceAlgorithm
- Parameters:
algorithmContext
- The context in which holds run time states related to the algorithm
-
getName
public String getName()
Description copied from interface:LoadbalanceAlgorithm
Return the name of the load balancing algorithm- Specified by:
getName
in interfaceLoadbalanceAlgorithm
- Returns:
- the name of the algorithm implemented
-
-