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) {
// if the call was after the last collect and older than 1 second
// then we must count it
GatewayQueueRate gqr = gatewayRateValidator.getQueueRateForBucket(oldestCall.bucketID);
gqr.localApiCallsInLastPeriodSecond++;
}
this.gdm.releaseLockForBucket(oldestCall.bucketID, lock);
}
}