Package org.apache.synapse.endpoints
Class SALoadbalanceEndpoint
- java.lang.Object
-
- org.apache.synapse.FaultHandler
-
- org.apache.synapse.endpoints.AbstractEndpoint
-
- org.apache.synapse.endpoints.LoadbalanceEndpoint
-
- org.apache.synapse.endpoints.SALoadbalanceEndpoint
-
- All Implemented Interfaces:
Endpoint
,ManagedLifecycle
,Nameable
,PropertyInclude
,SynapseArtifact
public class SALoadbalanceEndpoint extends LoadbalanceEndpoint
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
-
Fields inherited from class org.apache.synapse.endpoints.AbstractEndpoint
anonymous, artifactContainerName, CHILDREN_JSON_ATT, errorHandler, fileName, initialized, isClusteringEnabled, log, NAME_JSON_ATT, trace, TYPE_JSON_ATT
-
-
Constructor Summary
Constructors Constructor Description SALoadbalanceEndpoint()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description Dispatcher
getDispatcher()
long
getSessionTimeout()
void
init(SynapseEnvironment synapseEnvironment)
This method should implement the initialization of the implemented parts of the configuration.void
onChildEndpointFail(Endpoint endpoint, MessageContext synCtx)
It is logically incorrect to failover a session affinity endpoint after the session has started.void
send(MessageContext synCtx)
Sends the message context according to an endpoint specific behavior.void
sendMessage(MessageContext synCtx)
void
setDispatcher(Dispatcher dispatcher)
void
setSessionTimeout(long sessionTimeout)
-
Methods inherited from class org.apache.synapse.endpoints.LoadbalanceEndpoint
createJsonRepresentation, destroy, getAlgorithm, getMembers, getNextChild, isBuildMessageAtt, isFailover, isInitialized, readyToSend, setAlgorithm, setBuildMessageAtt, setBuildMessageAttAvailable, setFailover, setMembers, startApplicationMembershipTimer
-
Methods inherited from class org.apache.synapse.endpoints.AbstractEndpoint
addProperties, addProperty, evaluateProperties, executeEpTypeSpecificFunctions, getArtifactContainerName, getChildren, getCommentsList, getContext, getDefinition, getDescription, getEndpointChildrenAsJson, getErrorHandler, getFileName, getIsEdited, getJsonRepresentation, getMetricsMBean, getName, getParentEndpoint, getProperties, getProperty, getReportingName, handleException, handleException, handleException, informFailure, isAnonymous, isLeafEndpoint, isRetry, isSuspendFault, isTimeout, isTraceOn, isTraceOrDebugOn, logOnChildEndpointFail, logSetter, onFault, onSuccess, prepareForEndpointStatistics, removeProperty, setAdvancedProperties, setAnonymous, setArtifactContainerName, setChildren, setCommentsList, setComponentStatisticsId, setContentAware, setDefinition, setDescription, setEnableMBeanStats, setErrorHandler, setErrorOnMessage, setFileName, setForceBuildMC, setIsEdited, setName, setParentEndpoint, toString, traceOrDebug
-
Methods inherited from class org.apache.synapse.FaultHandler
executeExtendedSynapseHandlerOnFault, getStackTrace, handleFault, handleFault
-
-
-
-
Method Detail
-
init
public void init(SynapseEnvironment synapseEnvironment)
Description copied from interface:ManagedLifecycle
This method should implement the initialization of the implemented parts of the configuration.- Specified by:
init
in interfaceManagedLifecycle
- Overrides:
init
in classLoadbalanceEndpoint
- Parameters:
synapseEnvironment
- SynapseEnvironment to be used for initialization
-
send
public void send(MessageContext synCtx)
Description copied from interface:Endpoint
Sends the message context according to an endpoint specific behavior.- Specified by:
send
in interfaceEndpoint
- Overrides:
send
in classLoadbalanceEndpoint
- Parameters:
synCtx
- MessageContext to be sent.
-
sendMessage
public void sendMessage(MessageContext synCtx)
-
getDispatcher
public Dispatcher getDispatcher()
-
setDispatcher
public void setDispatcher(Dispatcher dispatcher)
-
onChildEndpointFail
public void onChildEndpointFail(Endpoint endpoint, MessageContext synCtx)
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.- Specified by:
onChildEndpointFail
in interfaceEndpoint
- Overrides:
onChildEndpointFail
in classLoadbalanceEndpoint
- Parameters:
endpoint
- Failed endpoint.synCtx
- MessageContext of the failed message.
-
getSessionTimeout
public long getSessionTimeout()
-
setSessionTimeout
public void setSessionTimeout(long sessionTimeout)
-
-