Home » synapse-1.2-src » org.apache.synapse.endpoints » [javadoc | source]
org.apache.synapse.endpoints
public class: SALoadbalanceEndpoint [javadoc | source]
java.lang.Object
   org.apache.synapse.endpoints.SALoadbalanceEndpoint

All Implemented Interfaces:
    Endpoint

SALoadbalanceEndpoint supports session affinity based load balancing. Each of this endpoint maintains a list of dispatchers. These dispatchers will be updated for both request (for client initiated sessions) and response (for server initiated sessions). Once updated, each dispatcher will check if has already encountered that session. If not, it will update the session -> endpoint map. To update sessions for response messages, all SALoadbalanceEndpoint objects are kept in a global property. When a message passes through SALoadbalanceEndpoints, each endpoint appends its "Synapse unique ID" to the operation context. Once the response for that message arrives, response sender checks first endpoint of the endpoint sequence from the operation context and get that endpoint from the above mentioned global property. Then it will invoke updateSession(...) method of that endpoint. After that, each endpoint will call updateSession(...) method of their appropriate child endpoint, so that all the sending endpoints for the session will be updated.

This endpoint gets the target endpoint first from the dispatch manager, which will ask all listed dispatchers for a matching session. If a matching session is found it will just invoke the send(...) method of that endpoint. If not it will find an endpoint using the load balancing policy and send to that endpoint.
Field Summary
public static final  String ENDPOINT_LIST     
public static final  String ROOT_ENDPOINT     
public static final  String ENDPOINT_NAME_LIST     
public static final  String WARN_MESSAGE     
Method from org.apache.synapse.endpoints.SALoadbalanceEndpoint Summary:
getAlgorithm,   getDispatcher,   getEndpoints,   getName,   isActive,   onChildEndpointFail,   send,   setActive,   setAlgorithm,   setDispatcher,   setEndpoints,   setName,   setParentEndpoint,   updateSession
Methods from java.lang.Object:
clone,   equals,   finalize,   getClass,   hashCode,   notify,   notifyAll,   toString,   wait,   wait,   wait
Method from org.apache.synapse.endpoints.SALoadbalanceEndpoint Detail:
 public LoadbalanceAlgorithm getAlgorithm() 
 public Dispatcher getDispatcher() 
 public List<Endpoint> getEndpoints() 
 public String getName() 
 public boolean isActive(MessageContext synMessageContext) 
    This is active in below conditions: If a session is not started AND at least one child endpoint is active. If a session is started AND the binding endpoint is active.

    This is not active for all other conditions.

 public  void onChildEndpointFail(Endpoint endpoint,
    MessageContext synMessageContext) 
    It is logically incorrect to failover a session affinity endpoint after the session has started. If we redirect a message belonging to a particular session, new endpoint is not aware of the session. So we can't handle anything more at the endpoint level. Therefore, this method just deactivate the failed endpoint and give the fault to the next fault handler.

    But if the session has not started (i.e. first message), the message will be resend by binding it to a different endpoint.

 public  void send(MessageContext synMessageContext) 
 public  void setActive(boolean active,
    MessageContext synMessageContext) 
 public  void setAlgorithm(LoadbalanceAlgorithm algorithm) 
 public  void setDispatcher(Dispatcher dispatcher) 
 public  void setEndpoints(List<Endpoint> endpoints) 
 public  void setName(String name) 
 public  void setParentEndpoint(Endpoint parentEndpoint) 
 public  void updateSession(MessageContext responseMsgCtx,
    List endpointList,
    boolean isClusteringEnable) 
    This will be called for the response of the first message of each server initiated session.