public boolean tryAcquire(int sizeInByte, ProcessResult procResult) {
        if (this.disabled) {
            return procResult.setSuccess();
        }
        if (this.pkgCntQuota == null) {
            if (this.pkgSizeKbQuota.tryAcquire(
                    getSizeKbPermitsByBytes(sizeInByte))) {
                return procResult.setSuccess();
            }
            return procResult.setFailResult(factoryLevel
                    ? ErrorCode.INF_REQ_SIZE_REACH_FACTORY_LIMIT
                    : ErrorCode.INF_REQ_SIZE_REACH_SDK_LIMIT);
        } else {
            if (this.pkgCntQuota.tryAcquire(1)) {
                if (this.pkgSizeKbQuota == null) {
                    return procResult.setSuccess();
                } else {
                    if (this.pkgSizeKbQuota.tryAcquire(
                            getSizeKbPermitsByBytes(sizeInByte))) {
                        return procResult.setSuccess();
                    } else {
                        this.pkgCntQuota.release();
                        return procResult.setFailResult(factoryLevel
                                ? ErrorCode.INF_REQ_SIZE_REACH_FACTORY_LIMIT
                                : ErrorCode.INF_REQ_SIZE_REACH_SDK_LIMIT);
                    }
                }
            } else {
                return procResult.setFailResult(factoryLevel
                        ? ErrorCode.INF_REQ_COUNT_REACH_FACTORY_LIMIT
                        : ErrorCode.INF_REQ_COUNT_REACH_SDK_LIMIT);
            }
        }
    }
Package Cache Quota class

Used to manage the total number and byte size of ongoing requests.
inlong-sdk/dataproxy-sdk/src/main/java/org/apache/inlong/sdk/dataproxy/network/PkgCacheQuota.java