Package com.appslandia.plum.base
Class BasicRateLimitHandler
- java.lang.Object
-
- com.appslandia.common.base.InitializeObject
-
- com.appslandia.plum.base.RateLimitHandler
-
- com.appslandia.plum.base.BasicRateLimitHandler
-
- All Implemented Interfaces:
com.appslandia.common.base.InitializeSupport
public abstract class BasicRateLimitHandler extends RateLimitHandler
- Author:
- Loc Ha
-
-
Field Summary
Fields Modifier and Type Field Description protected com.appslandia.common.base.RateLimitaccessRate1protected com.appslandia.common.base.RateLimitaccessRate2protected AppConfigappConfigprotected com.appslandia.common.logging.AppLoggerappLoggerprotected ConcurrentMap<String,Long>bannedClientsprotected longbannedResetWindowprotected ConcurrentMap<String,com.appslandia.plum.base.BasicRateLimitHandler.Tracker>clientTrackersstatic StringCONFIG_ACCESS_RATE1static StringCONFIG_ACCESS_RATE2static StringCONFIG_BANNED_RESET_WINDOWstatic StringCONFIG_MAX_ACCESSESprotected longmaxAccesses-
Fields inherited from class com.appslandia.plum.base.RateLimitHandler
rateLimitSkipper
-
-
Constructor Summary
Constructors Constructor Description BasicRateLimitHandler()
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description protected voidcheckClient(String clientId)voidclearBannedClients()Map<String,Long>getBannedClients()Map<String,com.appslandia.plum.base.BasicRateLimitHandler.Tracker>getClientTrackers()protected abstract ScheduledExecutorServicegetScheduledExecutor()protected voidinit()-
Methods inherited from class com.appslandia.plum.base.RateLimitHandler
checkRequest
-
-
-
-
Field Detail
-
CONFIG_ACCESS_RATE1
public static final String CONFIG_ACCESS_RATE1
-
CONFIG_ACCESS_RATE2
public static final String CONFIG_ACCESS_RATE2
-
CONFIG_MAX_ACCESSES
public static final String CONFIG_MAX_ACCESSES
-
CONFIG_BANNED_RESET_WINDOW
public static final String CONFIG_BANNED_RESET_WINDOW
-
accessRate1
protected com.appslandia.common.base.RateLimit accessRate1
-
accessRate2
protected com.appslandia.common.base.RateLimit accessRate2
-
maxAccesses
protected long maxAccesses
-
bannedResetWindow
protected long bannedResetWindow
-
clientTrackers
protected final ConcurrentMap<String,com.appslandia.plum.base.BasicRateLimitHandler.Tracker> clientTrackers
-
bannedClients
protected final ConcurrentMap<String,Long> bannedClients
-
appConfig
@Inject protected AppConfig appConfig
-
appLogger
@Inject protected com.appslandia.common.logging.AppLogger appLogger
-
-
Method Detail
-
getScheduledExecutor
protected abstract ScheduledExecutorService getScheduledExecutor()
-
init
protected void init() throws Exception- Overrides:
initin classRateLimitHandler- Throws:
Exception
-
checkClient
protected void checkClient(String clientId) throws TooManyRequestsException
- Specified by:
checkClientin classRateLimitHandler- Throws:
TooManyRequestsException
-
clearBannedClients
public void clearBannedClients()
-
-