org.apache.synapse.endpoints.algorithms
Class RoundRobin

java.lang.Object
  extended by 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
RoundRobin()
           
RoundRobin(List endpoints)
           
 
Method Summary
 LoadbalanceAlgorithm clone()
           
 String getName()
          Return the name of the load balancing algorithm
 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<Member> members)
          Set the application members
 void setEndpoints(List<Endpoint> endpoints)
          Set the endpoints
 void setLoadBalanceEndpoint(Endpoint endpoint)
          Set the loadbalance endpoint
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

RoundRobin

public RoundRobin()

RoundRobin

public RoundRobin(List endpoints)
Method Detail

setApplicationMembers

public void setApplicationMembers(List<Member> members)
Description copied from interface: LoadbalanceAlgorithm
Set the application members

Specified by:
setApplicationMembers in interface LoadbalanceAlgorithm
Parameters:
members - The application members

setEndpoints

public void setEndpoints(List<Endpoint> endpoints)
Description copied from interface: LoadbalanceAlgorithm
Set the endpoints

Specified by:
setEndpoints in interface LoadbalanceAlgorithm
Parameters:
endpoints - The endpoints

setLoadBalanceEndpoint

public void setLoadBalanceEndpoint(Endpoint endpoint)
Description copied from interface: LoadbalanceAlgorithm
Set the loadbalance endpoint

Specified by:
setLoadBalanceEndpoint in interface LoadbalanceAlgorithm
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 interface LoadbalanceAlgorithm
Parameters:
synCtx - MessageContext instance which holds all per-message properties
algorithmContext - The context in which holds run time states related to the algorithm
Returns:
endpoint to send the next message

getNextApplicationMember

public 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 interface LoadbalanceAlgorithm
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 interface LoadbalanceAlgorithm
Overrides:
clone in class Object

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 interface LoadbalanceAlgorithm
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 interface LoadbalanceAlgorithm
Returns:
the name of the algorithm implemented


Copyright © 2005-2012 Apache Software Foundation. All Rights Reserved.