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)); }
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)); }
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)); }
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)); }
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; } }
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)); }
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)); }
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)); }
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)); }
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; } }