@Override
  public QuotaAction checkAndCharge(boolean shouldCheckExceedAllowed) {
    QuotaAction quotaAction = QuotaAction.ALLOW;
    if (Objects.isNull(quotaChargeCallback) || isCharged) {
      return quotaAction;
    }
    try {
      quotaAction = checkAndChargeHelper(shouldCheckExceedAllowed);
      isCharged = quotaAction == QuotaAction.ALLOW;
    } catch (QuotaException quotaException) {
      numAttempts++;
      // When there is an exception, we let the request through, because we don't want to affect user's request due to
      // any issue with quota system. But we don't set isCharged flag to true when the exception is retryable, so that
      // if charging is attempted again (due to chunk request parallelism), the charge can be passed down.
      LOGGER.warn("Quota charging failed in {} for blob {} due to {}. Number of attempts {}", operationName,
          getBlobIdStr(), quotaException.toString(), numAttempts);
      if (!quotaException.isRetryable()) {
        isCharged = true;
      }
    } catch (Exception exception) {
      routerMetrics.unknownExceptionInChargeableRate.mark();
      LOGGER.warn("Quota charging failed in {} for blob {} due to {}. This should never happen.", operationName,
          getBlobIdStr(), exception.toString(), numAttempts);
      isCharged = true;
    }
    return quotaAction;
  }
Constructor for {@link OperationQuotaCharger}.

@param quotaChargeCallback {@link QuotaChargeCallback} object to charge and check quotas.
@param operationName Name of the operation.
ambry-router/src/main/java/com/github/ambry/router/OperationQuotaCharger.java