Class ThrottleContext
java.lang.Object
org.apache.synapse.commons.throttle.core.ThrottleContext
- Direct Known Subclasses:
DomainBaseThrottleContext,IPBaseThrottleContext,RoleBaseThrottleContext
Holds the all runtime data corresponding to call remote callers.
In addition to that this hold clean list for callers.
-
Constructor Summary
ConstructorsConstructorDescriptionThrottleContext(ThrottleConfiguration throttleConfiguration, ThrottleReplicator throttleReplicator) default constructor – expects a throttle configuration. -
Method Summary
Modifier and TypeMethodDescriptionvoidaddAndFlushCallerContext(CallerContext callerContext, String id) To add the caller and replicates the states of the given callervoidaddCallerContext(CallerContext callerContext, String id) setting callerContext - put callersMap against time and put time against remote caller id (ip/domain)voidcleanupCallers(long time) This method will clean up callers which has next access time below from provided time This will first check the prohibited period and then it will check next access time lesser than unit time before a cleanup a callervoidflushCallerContext(CallerContext callerContext, String id) To replicates the states of the already exist callerTo get the runtime states of a remote callerorg.apache.axis2.context.ConfigurationContextTo get the ThrottleConfigurationabstract intgetType()voidprocessCleanList(long time) /** processing cleaning list- only process callerContexts which unit time already had overvoidRemoves the caller and destroy shared params of callervoidRemoves the caller and replicate the statesvoidremoving a caller with a given id - caller will remove from clean listvoidReplicate the time window of this callervoidsetConfigurationContext(org.apache.axis2.context.ConfigurationContext configurationContext) voidsetThrottleId(String throttleId)
-
Constructor Details
-
ThrottleContext
public ThrottleContext(ThrottleConfiguration throttleConfiguration, ThrottleReplicator throttleReplicator) default constructor – expects a throttle configuration.- Parameters:
throttleConfiguration- - configuration data according to the policy
-
-
Method Details
-
getThrottleConfiguration
To get the ThrottleConfiguration- Returns:
- ThrottleConfiguration returns the ThrottleConfiguration of this context
-
getCallerContext
To get the runtime states of a remote caller- Parameters:
id- the remote caller id ex: domain , ip- Returns:
- Returns the CallerContext which holds runtime state of a remote caller
-
addCallerContext
setting callerContext - put callersMap against time and put time against remote caller id (ip/domain)- Parameters:
callerContext- - The remote caller's runtime data.id- - The id of the remote caller
-
removeCallerContext
removing a caller with a given id - caller will remove from clean list- Parameters:
id- Caller ID
-
processCleanList
public void processCleanList(long time) /** processing cleaning list- only process callerContexts which unit time already had over- Parameters:
time- - the current System Time- Throws:
ThrottleException
-
setThrottleId
-
getThrottleId
-
getConfigurationContext
public org.apache.axis2.context.ConfigurationContext getConfigurationContext() -
setConfigurationContext
public void setConfigurationContext(org.apache.axis2.context.ConfigurationContext configurationContext) -
getType
public abstract int getType()- Returns:
- Returns the type of throttle ex : ip /domain
-
addAndFlushCallerContext
To add the caller and replicates the states of the given caller- Parameters:
callerContext- The states of the callerid- The id of the caller
-
flushCallerContext
To replicates the states of the already exist caller- Parameters:
callerContext- The states of the callerid- The id of the remote caller
-
removeAndFlushCaller
Removes the caller and replicate the states- Parameters:
id- The Id of the caller
-
replicateTimeWindow
Replicate the time window of this caller- Parameters:
id-
-
cleanupCallers
public void cleanupCallers(long time) This method will clean up callers which has next access time below from provided time This will first check the prohibited period and then it will check next access time lesser than unit time before a cleanup a caller- Parameters:
time- to clean up the caller contexts
-