public async override Task <int?> ReadThroughputAsync( CancellationToken cancellationToken = default(CancellationToken)) { ThroughputResponse response = await this.ReadThroughputIfExistsAsync(null, cancellationToken); return(response.Resource?.Throughput); }
public async Task <int?> ReadThroughputAsync( CosmosDiagnosticsContext diagnosticsContext, CancellationToken cancellationToken = default) { ThroughputResponse response = await this.ReadThroughputIfExistsAsync(null, cancellationToken); return(response.Resource?.Throughput); }
public async Task <int?> ReadThroughputAsync( ITrace trace, CancellationToken cancellationToken) { ThroughputResponse response = await this.ReadThroughputIfExistsAsync(null, cancellationToken); return(response.Resource?.Throughput); }
private async Task <ThroughputResponse> OfferRetryHelperForStaleRidCacheAsync( Func <string, Task <ThroughputResponse> > executeOfferOperation, CosmosDiagnosticsContext diagnosticsContext, ITrace trace, CancellationToken cancellationToken) { string rid = await this.GetCachedRIDAsync( forceRefresh : false, cancellationToken : cancellationToken); ThroughputResponse throughputResponse = await executeOfferOperation(rid); if (throughputResponse.StatusCode != HttpStatusCode.NotFound) { return(throughputResponse); } // Check if RID cache is stale ResponseMessage responseMessage = await this.ReadContainerStreamAsync( diagnosticsContext : diagnosticsContext, requestOptions : null, trace : trace, cancellationToken : cancellationToken); // Container does not exist if (responseMessage.StatusCode == HttpStatusCode.NotFound) { return(new ThroughputResponse( responseMessage.StatusCode, responseMessage.Headers, null, diagnosticsContext.Diagnostics)); } responseMessage.EnsureSuccessStatusCode(); ContainerProperties containerProperties = this.ClientContext.SerializerCore.FromStream <ContainerProperties>(responseMessage.Content); // The RIDs match so return the original response. if (string.Equals(rid, containerProperties.ResourceId)) { return(throughputResponse); } // Get the offer with the new rid value return(await executeOfferOperation(containerProperties.ResourceId)); }
public async Task <ThroughputResponse> ReadThroughputAsync( RequestOptions requestOptions, ITrace trace, CancellationToken cancellationToken = default) { ThroughputResponse throughputResponse = await this.ReadThroughputIfExistsAsync( requestOptions, trace, cancellationToken); if (throughputResponse.StatusCode == HttpStatusCode.NotFound) { throw CosmosExceptionFactory.CreateNotFoundException( message: $"Throughput is not configured for {this.Id}", headers: throughputResponse.Headers, trace: trace); } return(throughputResponse); }
public async Task <ThroughputResponse> ReplaceThroughputAsync( CosmosDiagnosticsContext diagnosticsContext, ThroughputProperties throughputProperties, RequestOptions requestOptions = null, CancellationToken cancellationToken = default) { ThroughputResponse throughputResponse = await this.ReplaceThroughputIfExistsAsync( diagnosticsContext, throughputProperties, requestOptions, cancellationToken); if (throughputResponse.StatusCode == HttpStatusCode.NotFound) { throw CosmosExceptionFactory.CreateNotFoundException( message: $"Throughput is not configured for {this.Id}", headers: throughputResponse.Headers, diagnosticsContext: diagnosticsContext); } return(throughputResponse); }