internal async Task <ThroughputResponse> ReadThroughputIfExistsAsync(
            RequestOptions requestOptions,
            CancellationToken cancellationToken = default(CancellationToken))
        {
            string rid = await this.GetRIDAsync(cancellationToken);

            CosmosOffers cosmosOffers = new CosmosOffers(this.ClientContext);

            return(await cosmosOffers.ReadThroughputIfExistsAsync(targetRID : rid, requestOptions : requestOptions, cancellationToken : cancellationToken));
        }
Beispiel #2
0
        public override async Task <ThroughputResponse> ReadThroughputAsync(
            RequestOptions requestOptions,
            CancellationToken cancellationToken = default(CancellationToken))
        {
            string rid = await this.GetRIDAsync(cancellationToken);

            CosmosOffers cosmosOffers = new CosmosOffers(this.ClientContext);

            return(await cosmosOffers.ReadThroughputAsync(rid, requestOptions, cancellationToken));
        }
Beispiel #3
0
        public async Task <ThroughputResponse> ReadThroughputIfExistsAsync(
            CosmosDiagnosticsContext diagnosticsContext,
            RequestOptions requestOptions,
            CancellationToken cancellationToken = default)
        {
            string rid = await this.GetRIDAsync(cancellationToken);

            CosmosOffers cosmosOffers = new CosmosOffers(this.ClientContext);

            return(await cosmosOffers.ReadThroughputIfExistsAsync(rid, requestOptions, cancellationToken));
        }
Beispiel #4
0
        public Task <ThroughputResponse> ReadThroughputIfExistsAsync(
            RequestOptions requestOptions,
            ITrace trace,
            CancellationToken cancellationToken = default)
        {
            CosmosOffers cosmosOffers = new CosmosOffers(this.ClientContext);

            return(this.OfferRetryHelperForStaleRidCacheAsync(
                       (rid) => cosmosOffers.ReadThroughputIfExistsAsync(rid, requestOptions, cancellationToken),
                       trace,
                       cancellationToken));
        }
Beispiel #5
0
        internal async Task <CosmosOfferResult> ReplaceThroughputIfExistsAsync(
            string targetRID,
            int targetThroughput,
            CancellationToken cancellationToken = default(CancellationToken))
        {
            try
            {
                Offer offer = await this.ReadOfferAsync(targetRID, cancellationToken);

                if (offer == null)
                {
                    throw new ArgumentOutOfRangeException("Throughput is not configured");
                }

                OfferV2 offerV2 = offer as OfferV2;
                if (offerV2 == null)
                {
                    throw new NotImplementedException();
                }

                OfferV2 newOffer      = new OfferV2(offerV2, targetThroughput);
                Offer   replacedOffer = await this.ReplaceOfferAsync(targetRID, newOffer, cancellationToken);

                offerV2 = replacedOffer as OfferV2;
                Debug.Assert(offerV2 != null);

                return(new CosmosOfferResult(offerV2.Content.OfferThroughput));
            }
            catch (DocumentClientException dce)
            {
                return(new CosmosOfferResult(
                           dce.StatusCode ?? HttpStatusCode.InternalServerError,
                           new CosmosException(
                               dce.Message?.Replace(Environment.NewLine, string.Empty),
                               dce.StatusCode ?? HttpStatusCode.InternalServerError,
                               (int)dce.GetSubStatus(),
                               dce.ActivityId,
                               dce.RequestCharge)));
            }
            catch (AggregateException ex)
            {
                CosmosOfferResult offerResult = CosmosOffers.TryToOfferResult(ex);
                if (offerResult != null)
                {
                    return(offerResult);
                }

                throw;
            }
        }
Beispiel #6
0
        public async Task <ThroughputResponse> ReadThroughputAsync(
            RequestOptions requestOptions,
            ITrace trace,
            CancellationToken cancellationToken)
        {
            string rid = await this.GetRIDAsync(cancellationToken);

            CosmosOffers cosmosOffers = new CosmosOffers(this.ClientContext);

            return(await cosmosOffers.ReadThroughputAsync(
                       targetRID : rid,
                       requestOptions : requestOptions,
                       cancellationToken : cancellationToken));
        }
        public async override Task <ThroughputResponse> ReplaceThroughputAsync(
            int throughput,
            RequestOptions requestOptions       = null,
            CancellationToken cancellationToken = default(CancellationToken))
        {
            string rid = await this.GetRIDAsync(cancellationToken);

            CosmosOffers cosmosOffers = new CosmosOffers(this.ClientContext);

            return(await cosmosOffers.ReplaceThroughputAsync(
                       targetRID : rid,
                       throughput : throughput,
                       requestOptions : requestOptions,
                       cancellationToken : cancellationToken));
        }
Beispiel #8
0
        public override async Task <ThroughputResponse> ReplaceThroughputAsync(
            ThroughputProperties throughputProperties,
            RequestOptions requestOptions       = null,
            CancellationToken cancellationToken = default)
        {
            string rid = await this.GetRIDAsync(cancellationToken);

            CosmosOffers cosmosOffers = new CosmosOffers(this.ClientContext);

            return(await cosmosOffers.ReplaceThroughputPropertiesAsync(
                       rid,
                       throughputProperties,
                       requestOptions,
                       cancellationToken));
        }
Beispiel #9
0
        internal override async Task <ThroughputResponse> ReplaceThroughputIfExistsAsync(
            ThroughputProperties throughput,
            RequestOptions requestOptions       = null,
            CancellationToken cancellationToken = default(CancellationToken))
        {
            string rid = await this.GetRIDAsync(cancellationToken);

            CosmosOffers cosmosOffers = new CosmosOffers(this.ClientContext);

            return(await cosmosOffers.ReplaceThroughputPropertiesIfExistsAsync(
                       targetRID : rid,
                       throughputProperties : throughput,
                       requestOptions : requestOptions,
                       cancellationToken : cancellationToken));
        }
        public async Task <ThroughputResponse> ReplaceThroughputAsync(
            CosmosDiagnosticsContext diagnosticsContext,
            ThroughputProperties throughputProperties,
            RequestOptions requestOptions,
            CancellationToken cancellationToken = default)
        {
            string rid = await this.GetRIDAsync(cancellationToken);

            CosmosOffers cosmosOffers = new CosmosOffers(this.ClientContext);

            return(await cosmosOffers.ReplaceThroughputPropertiesAsync(
                       targetRID : rid,
                       throughputProperties : throughputProperties,
                       requestOptions : requestOptions,
                       cancellationToken : cancellationToken));
        }
Beispiel #11
0
        public Task <ThroughputResponse> ReplaceThroughputIfExistsAsync(
            ThroughputProperties throughput,
            ITrace trace,
            RequestOptions requestOptions       = null,
            CancellationToken cancellationToken = default)
        {
            CosmosOffers cosmosOffers = new CosmosOffers(this.ClientContext);

            return(this.OfferRetryHelperForStaleRidCacheAsync(
                       (rid) => cosmosOffers.ReplaceThroughputPropertiesIfExistsAsync(
                           targetRID: rid,
                           throughputProperties: throughput,
                           requestOptions: requestOptions,
                           cancellationToken: cancellationToken),
                       trace,
                       cancellationToken));
        }
Beispiel #12
0
        internal async Task <CosmosOfferResult> ReadProvisionedThroughputIfExistsAsync(
            string targetRID,
            CancellationToken cancellationToken = default(CancellationToken))
        {
            if (string.IsNullOrWhiteSpace(targetRID))
            {
                throw new ArgumentNullException(targetRID);
            }

            try
            {
                Offer offer = await this.ReadOfferAsync(targetRID, cancellationToken);

                return(this.GetThroughputIfExists(offer));
            }
            catch (DocumentClientException dce)
            {
                return(new CosmosOfferResult(
                           dce.StatusCode ?? HttpStatusCode.InternalServerError,
                           new CosmosException(
                               dce.Message?.Replace(Environment.NewLine, string.Empty),
                               dce.StatusCode ?? HttpStatusCode.InternalServerError,
                               (int)dce.GetSubStatus(),
                               dce.ActivityId,
                               dce.RequestCharge)));
            }
            catch (AggregateException ex)
            {
                CosmosOfferResult offerResult = CosmosOffers.TryToOfferResult(ex);
                if (offerResult != null)
                {
                    return(offerResult);
                }

                throw;
            }
        }