/** * To add the caller and replicates the states of the given caller * * @param callerContext The states of the caller * @param id The id of the caller */ public void addAndFlushCallerContext(CallerContext callerContext, String id) { if (callerContext != null && id != null) { addCaller(callerContext, id); replicateCaller(id); } }
/** * Init the access for a particular caller , caller will registered with context * * @param configuration -The Configuration for this caller * @param throttleContext -The Throttle Context * @param currentTime -The system current time in milliseconds */ private void initAccess(CallerConfiguration configuration, ThrottleContext throttleContext, long currentTime) { this.unitTime = configuration.getUnitTime(); this.firstAccessTime = currentTime; this.nextTimeWindow = this.firstAccessTime + this.unitTime; this.roleId = configuration.getID(); //Also we need to pick counter value associated with time window. throttleContext.addCallerContext(this, this.id); throttleContext.replicateTimeWindow(this.id); }
public void run() { if(log.isDebugEnabled()) { log.debug("Running the cleanup task"); } for(ThrottleContext throttleContext : throttleContexts) { throttleContext.cleanupCallers(System.currentTimeMillis()); } } }
if (context != null) { ThrottleConfiguration config = context.getThrottleConfiguration(); if (config != null) { context.setConfigurationContext(cc); context.setThrottleId(id); if (context != null) { ThrottleConfiguration config = context.getThrottleConfiguration(); if (config != null) { context.setConfigurationContext(cc); context.setThrottleId(id);
if (context != null) { ThrottleConfiguration config = context.getThrottleConfiguration(); if (config != null) { context.setThrottleId(id); if (context != null) { ThrottleConfiguration config = context.getThrottleConfiguration(); if (config != null) { context.setThrottleId(id);
AccessInformation info = null; if (isClusteringEnabled()) { hardThrottleContext.setConfigurationContext(cc); hardThrottleContext.setThrottleId(id + APIThrottleConstants.PRODUCTION_HARD_LIMIT); info = getAccessInformation(hardThrottleContext, throttleKey, APIThrottleConstants.PRODUCTION_HARD_LIMIT); } else if (APIConstants.API_KEY_TYPE_SANDBOX.equals(authContext.getKeyType())) { hardThrottleContext.setThrottleId(id + APIThrottleConstants.SANDBOX_HARD_LIMIT); info = getAccessInformation(hardThrottleContext, throttleKey, APIThrottleConstants.SANDBOX_HARD_LIMIT);
throttleContext.getThrottleConfiguration(); AccessInformation accessInformation = new AccessInformation(); } else if (configuration.getAccessState() == ThrottleConstants.ACCESS_CONTROLLED) { synchronized (consumerKey.intern()) { CallerContext caller = throttleContext.getCallerContext(consumerKey); if (caller == null) { log.debug("Caller for " + consumerKey + " is not present , Thread : " + Thread.currentThread().getName()); caller = throttleContext.getCallerContext(consumerKey); if (caller == null) { log.debug("Caller for " + consumerKey + " is not present for a second time , Thread : " + Thread.currentThread().getName()); throttleContext.processCleanList(currentTime); accessInformation.setAccessAllowed(false); accessInformation.setFaultReason(ACCESS_DENIED_TEMPORALLY);
this.localCount.incrementAndGet(); throttleContext.flushCallerContext(this, id); throttleContext.flushCallerContext(this, id); } else { throttleContext.removeCallerContext(id); this.firstAccessTime = currentTime; this.nextTimeWindow = currentTime + configuration.getUnitTime(); throttleContext.replicateTimeWindow(this.id); throttleContext.addAndFlushCallerContext(this, this.id);
ThrottleConfiguration throttleConfiguration = throttleContext.getThrottleConfiguration(); ThrottleContext resourceContext = createThrottleContext(throttleConfiguration);
throttleContext.removeCallerContext(id); this.globalCount.set(0);// can access the system and this is same as first access this.localCount.set(1); this.firstAccessTime = currentTime; this.nextTimeWindow = currentTime + configuration.getUnitTime(); throttleContext.replicateTimeWindow(this.id); throttleContext.addAndFlushCallerContext(this, id); throttleContext.removeCallerContext(id); this.nextTimeWindow = currentTime + configuration.getUnitTime(); throttleContext.replicateTimeWindow(this.id); throttleContext.addAndFlushCallerContext(this, id);
/** * setting callerContext - put callersMap against time and * put time against remote caller id (ip/domain) * * @param callerContext - The remote caller's runtime data. * @param id - The id of the remote caller */ public void addCallerContext(CallerContext callerContext, String id) { if (callerContext != null && id != null) { addCaller(callerContext, id); } }
ThrottleConfiguration config = resourceContext.getThrottleConfiguration(); if (config != null) { String applicationRoleId = null; ThrottleContext applicationThrottleContext = getApplicationThrottleContext(synCtx, dataHolder, applicationId); if (isClusteringEnable) { applicationThrottleContext.setConfigurationContext(cc); applicationThrottleContext.setThrottleId(id); resourceContext.setConfigurationContext(cc); resourceContext.setConfigurationContext(cc); resourceContext.setThrottleId(id + "resource"); config = context.getThrottleConfiguration(); String consumerRoleID = config.getConfigurationKeyOfCaller(roleID); if (isClusteringEnable) { context.setConfigurationContext(cc); context.setThrottleId(id); AccessInformation info = null; if (isClusteringEnable) { hardThrottleContext.setConfigurationContext(cc); hardThrottleContext.setThrottleId(id + APIThrottleConstants.PRODUCTION_HARD_LIMIT); info = roleBasedAccessController.canAccess(hardThrottleContext, throttleKey, APIThrottleConstants.PRODUCTION_HARD_LIMIT); } else if (APIConstants.API_KEY_TYPE_SANDBOX.equals(authContext.getKeyType())) { hardThrottleContext.setThrottleId(id + APIThrottleConstants.SANDBOX_HARD_LIMIT);
ThrottleConfiguration config = resourceContext.getThrottleConfiguration(); resourceContext.setThrottleId(id + "resource");
getAxis2MessageContext(); ConfigurationContext cc = axis2MC.getConfigurationContext(); subscriptionLevelSpikeArrestThrottleContext.setConfigurationContext(cc); subscriptionLevelSpikeArrestThrottleContext.setThrottleId(id + APIThrottleConstants.SUBSCRIPTION_BURST_LIMIT); info = getAccessInformation(subscriptionLevelSpikeArrestThrottleContext, throttleKey, throttleKey); if (log.isDebugEnabled()) {
throttleContext.getThrottleConfiguration(); AccessInformation accessInformation = new AccessInformation(); } else if (configuration.getAccessState() == ThrottleConstants.ACCESS_CONTROLLED) { synchronized (lock) { CallerContext caller = throttleContext.getCallerContext(callerID); if (caller == null) { throttleContext.processCleanList(currentTime); accessInformation.setAccessAllowed(false); accessInformation.setFaultReason(ACCESS_DENIED_TEMPORALLY);
if (context != null) { ThrottleConfiguration config = context.getThrottleConfiguration(); if (config != null) { context.setConfigurationContext(cc); context.setThrottleId(id); if (context != null) { ThrottleConfiguration config = context.getThrottleConfiguration(); if (config != null) { context.setConfigurationContext(cc); context.setThrottleId(id);
if (throttleCtxt != null) { ThrottleConfiguration throttleConfig = throttleCtxt.getThrottleConfiguration(); if (throttleConfig != null) { if (callerId != null) { throttleCtxt.setThrottleId(throttleId); AccessInformation infor = accessRateController.canAccess(throttleCtxt, callerId, if (context != null) { ThrottleConfiguration config = context.getThrottleConfiguration(); if (config != null) { context.setThrottleId(throttleId); AccessInformation infor = accessRateController.canAccess(context, callerId,
if (context != null) { ThrottleConfiguration config = context.getThrottleConfiguration(); if (config != null) { context.setThrottleId(throttleId); AccessInformation infor = roleBasedAccessController.canAccess(context, consumerKey,