private void pollQuotaExceedAllowedRequestsIfAny(List<RequestInfo> requestsToSend,
      Map<QuotaResource, LinkedList<RequestInfo>> requestQueue) {
    Timer.Context timer = routerMetrics.pollExceedAllowedRequestTime.time();
    List<QuotaResource> quotaResources = new ArrayList<>(requestQueue.keySet());
    Collections.shuffle(quotaResources);
    while (!requestQueue.isEmpty()) {
      Iterator<QuotaResource> iter = quotaResources.listIterator();
      while (iter.hasNext()) {
        QuotaResource quotaResource = iter.next();
        RequestInfo requestInfo = requestQueue.get(quotaResource).getFirst();
        QuotaAction quotaAction = requestInfo.getChargeable().checkAndCharge(true);
        switch (quotaAction) {
          case ALLOW:
            routerMetrics.exceedAllowedRequestRate.mark();
            requestsToSend.add(requestInfo);
            break;
          case DELAY:
            routerMetrics.delayedRequestRate.mark();
            return;
          case REJECT:
            routerMetrics.rejectedRequestRate.mark();
            nonCompliantRequests.add(requestInfo);
        }
        requestQueue.get(quotaResource).removeFirst();
        if (requestQueue.get(quotaResource).isEmpty()) {
          requestQueue.remove(quotaResource);
          iter.remove();
        }
      }
    }
    timer.stop();
  }
Poll for out of quota requests that are allowed to exceed quota.
@param requestsToSend {@link List} of {@link RequestInfo} to be sent.
@param requestQueue {@link Map} of {@link QuotaResource} to {@link List} of {@link RequestInfo} from which the requests to be sent will be polled.
ambry-router/src/main/java/com/github/ambry/router/QuotaAwareOperationController.java