Examples of LockCounter


Examples of com.alu.e3.rate.manager.GatewayDataManager.LockCounter

        }
      }
     
      // if the call was failed then it was not counted so no need to decrease the counter
      if (removed && oldestCall.callSuccess) {
        LockCounter lock = this.gdm.getLockForBucket(oldestCall.bucketID);

        synchronized (lock) {
          GatewayRate gr =  gatewayRateValidator.getRateForBucket(oldestCall.bucketID);
          gr.localApiCallsSinceOneMinute--;
          if (!oldestCall.countedInLastPeriodMinute) {
            // if the call was after the last collect and older than 1 minute
            // then we must count it
            GatewayQueueRate gqr = gatewayRateValidator.getQueueRateForBucket(oldestCall.bucketID);
            gqr.localApiCallsInLastPeriodMinute++;
          }
          this.gdm.releaseLockForBucket(oldestCall.bucketID, lock);
        }
      }
    } 

    // update this.apiCallsPerSecondQueue to remove call older than 1s
    removed = true;
    while (removed) { 
      removed = false;
      synchronized(lockUpdateSecondQueues) {
        oldestCall = this.gdm.peekCallFromSecondQueue();
        if  ((oldestCall!=null) && (currentTime - oldestCall.callTime > 1000)) {
          removed = this.gdm.removeCallFromSecondQueue(oldestCall);
        }
      }
      if (removed && oldestCall.callSuccess) {
        LockCounter lock = this.gdm.getLockForBucket(oldestCall.bucketID);

        synchronized (lock) {
          GatewayRate gr =  gatewayRateValidator.getRateForBucket(oldestCall.bucketID);
          gr.localApiCallsSinceOneSecond--;
          if (!oldestCall.countedInLastPeriodSecond) {
View Full Code Here

Examples of com.alu.e3.rate.manager.GatewayDataManager.LockCounter

        this.dataManager.fillLimitsById(contextId, limit);

        if ((limit.getQuotaPerDay()!=null) || (limit.getQuotaPerWeek()!=null) || (limit.getQuotaPerMonth()!=null)
            || (limit.getRateLimitPerMinute()!=null) || (limit.getRateLimitPerSecond()!=null)) {     
         
          LockCounter lock = this.gdm.getLockForBucket(bucketID);
         
          synchronized (lock) {
         
            lockedSet.add(bucketID);

            GatewayRate gr = gatewayRateValidator.getRateForBucket(bucketID, limit, mustResetRateLimit);
           
            gatewayRateValidator.updateRateLimitAndQuotaValues(gr, limit, currentTime);
           
            params.gr = gr;
            params.limit = limit;
            params.callDescriptor = callDescriptor;
           
            gatewayRateValidator.checkRateLimitAndQuota(apiCallStatus, params);
           
            this.gdm.releaseLockForBucket(bucketID, lock);
            lockedSet.remove(bucketID);
          }
        }
      }
     
      // TODO: maybe increment always in previous loop and decrement all gr only if call was failed
      // step2: save data for call success or fail
      it = authIdentity.getCallDescriptors().iterator();
      while (it.hasNext())
      {
        CallDescriptor callDescriptor = it.next();
        Integer bucketID = callDescriptor.getBucketId();
        Integer contextId = callDescriptor.getContextId();
        this.dataManager.fillLimitsById(contextId, limit);

        if ((limit.getQuotaPerDay()!=null) || (limit.getQuotaPerWeek()!=null) || (limit.getQuotaPerMonth()!=null)
            || (limit.getRateLimitPerMinute()!=null) || (limit.getRateLimitPerSecond()!=null))
        { 
          LockCounter lock = this.gdm.getLockForBucket(bucketID);

          synchronized (lock) {
           
            GatewayRate gr = gatewayRateValidator.getRateForBucket(bucketID);
            GatewayQueueRate gqr = gatewayRateValidator.getQueueRateForBucket(bucketID);     
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.