Package org.atmosphere.interceptor
Class RateLimitingInterceptor
java.lang.Object
org.atmosphere.cpr.AtmosphereInterceptorAdapter
org.atmosphere.interceptor.RateLimitingInterceptor
- All Implemented Interfaces:
AtmosphereInterceptor,AtmosphereConfigAware,InvokationOrder
Per-client rate-limiting interceptor using a token-bucket algorithm.
Configurable via
org.atmosphere.rateLimit.maxMessages,
org.atmosphere.rateLimit.windowSeconds, and
org.atmosphere.rateLimit.policy (drop or disconnect).- Since:
- 4.0
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic enumRate limit exceeded policy.Nested classes/interfaces inherited from interface org.atmosphere.interceptor.InvokationOrder
InvokationOrder.PRIORITY -
Field Summary
Fields inherited from interface org.atmosphere.interceptor.InvokationOrder
AFTER_DEFAULT, BEFORE_DEFAULT, FIRST_BEFORE_DEFAULT -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidconfigure(AtmosphereConfig config) Configure an AtmosphereFramework object.voiddestroy()Clean the AtmosphereInterceptor when removed or when the Atmosphere is undeployed.Invoked before anAtmosphereResourcegets dispatched toAtmosphereHandler.intpolicy()voidInvoked after anAtmosphereResourcegets dispatched toAtmosphereHandler.priority()Return the priority an AtmosphereInterceptor must be executed.toString()longlongint
-
Constructor Details
-
RateLimitingInterceptor
public RateLimitingInterceptor()
-
-
Method Details
-
configure
Description copied from interface:AtmosphereConfigAwareConfigure an AtmosphereFramework object.- Specified by:
configurein interfaceAtmosphereConfigAware- Overrides:
configurein classAtmosphereInterceptorAdapter- Parameters:
config-AtmosphereConfig
-
inspect
Description copied from interface:AtmosphereInterceptorInvoked before anAtmosphereResourcegets dispatched toAtmosphereHandler.- Specified by:
inspectin interfaceAtmosphereInterceptor- Overrides:
inspectin classAtmosphereInterceptorAdapter- Parameters:
r- aAtmosphereResource- Returns:
Action.CONTINUEorAction.SUSPENDto dispatch theAtmosphereResourceto otherAtmosphereInterceptororAtmosphereHandler. ReturnAction.TYPE.CANCELLEDto stop the processing.
-
postInspect
Description copied from interface:AtmosphereInterceptorInvoked after anAtmosphereResourcegets dispatched toAtmosphereHandler.- Specified by:
postInspectin interfaceAtmosphereInterceptor- Overrides:
postInspectin classAtmosphereInterceptorAdapter- Parameters:
r- aAtmosphereResource
-
destroy
public void destroy()Description copied from interface:AtmosphereInterceptorClean the AtmosphereInterceptor when removed or when the Atmosphere is undeployed.- Specified by:
destroyin interfaceAtmosphereInterceptor- Overrides:
destroyin classAtmosphereInterceptorAdapter
-
totalDropped
public long totalDropped()- Returns:
- total messages dropped due to rate limiting
-
totalDisconnected
public long totalDisconnected()- Returns:
- total clients disconnected due to rate limiting
-
maxMessages
public int maxMessages()- Returns:
- the configured max messages per window
-
policy
- Returns:
- the configured policy
-
trackedClients
public int trackedClients()- Returns:
- the number of currently tracked clients
-
priority
Description copied from interface:InvokationOrderReturn the priority an AtmosphereInterceptor must be executed.- Specified by:
priorityin interfaceInvokationOrder- Overrides:
priorityin classAtmosphereInterceptorAdapter- Returns:
- PRIORITY
-
toString
- Overrides:
toStringin classAtmosphereInterceptorAdapter
-