public override async Task <List <Documents.Routing.Range <string> > > GetEffectiveRangesAsync( IRoutingMapProvider routingMapProvider, string containerRid, Documents.PartitionKeyDefinition partitionKeyDefinition) { Documents.PartitionKeyRange pkRange = await routingMapProvider.TryGetPartitionKeyRangeByIdAsync( collectionResourceId : containerRid, partitionKeyRangeId : this.PartitionKeyRangeId, forceRefresh : false); if (pkRange == null) { // Try with a refresh pkRange = await routingMapProvider.TryGetPartitionKeyRangeByIdAsync( collectionResourceId : containerRid, partitionKeyRangeId : this.PartitionKeyRangeId, forceRefresh : true); } if (pkRange == null) { throw new InvalidOperationException($"The PartitionKeyRangeId: \"{this.PartitionKeyRangeId}\" is not valid for the current container {containerRid} ."); } return(new List <Documents.Routing.Range <string> > { pkRange.ToRange() }); }
public async Task <PartitionKeyRange> GetTargetPartitionKeyRangeByIdAsync(string collectionResourceId, string partitionKeyRangeId) { IRoutingMapProvider routingMapProvider = await this.Client.GetRoutingMapProviderAsync(); PartitionKeyRange range = await routingMapProvider.TryGetPartitionKeyRangeByIdAsync(collectionResourceId, partitionKeyRangeId); if (range == null && PathsHelper.IsNameBased(this.ResourceLink)) { // Refresh the cache and don't try to reresolve collection as it is not clear what already // happened based on previously resolved collection rid. // Return NotFoundException this time. Next query will succeed. // This can only happen if collection is deleted/created with same name and client was not restarted // inbetween. CollectionCache collectionCache = await this.Client.GetCollectionCacheAsync(); collectionCache.Refresh(this.ResourceLink); } if (range == null) { throw new NotFoundException($"{DateTime.UtcNow.ToString("o", CultureInfo.InvariantCulture)}: GetTargetPartitionKeyRangeById(collectionResourceId:{collectionResourceId}, partitionKeyRangeId: {partitionKeyRangeId}) failed due to stale cache"); } return(range); }
internal override async Task <List <Documents.Routing.Range <string> > > GetEffectiveRangesAsync( IRoutingMapProvider routingMapProvider, string containerRid, Documents.PartitionKeyDefinition partitionKeyDefinition, ITrace trace) { Documents.PartitionKeyRange pkRange = await routingMapProvider.TryGetPartitionKeyRangeByIdAsync( collectionResourceId : containerRid, partitionKeyRangeId : this.PartitionKeyRangeId, trace : trace, forceRefresh : false); if (pkRange == null) { // Try with a refresh pkRange = await routingMapProvider.TryGetPartitionKeyRangeByIdAsync( collectionResourceId : containerRid, partitionKeyRangeId : this.PartitionKeyRangeId, trace : trace, forceRefresh : true); } if (pkRange == null) { throw CosmosExceptionFactory.Create( statusCode: HttpStatusCode.Gone, message: $"The PartitionKeyRangeId: \"{this.PartitionKeyRangeId}\" is not valid for the current container {containerRid} .", stackTrace: string.Empty, headers: new Headers() { SubStatusCode = SubStatusCodes.PartitionKeyRangeGone, }, error: null, innerException: null, trace: NoOpTrace.Singleton); } return(new List <Documents.Routing.Range <string> > { pkRange.ToRange() }); }
public override async Task <List <Documents.Routing.Range <string> > > GetEffectiveRangesAsync( IRoutingMapProvider routingMapProvider, string containerRid, Documents.PartitionKeyDefinition partitionKeyDefinition) { Documents.PartitionKeyRange pkRange = await routingMapProvider.TryGetPartitionKeyRangeByIdAsync( collectionResourceId : containerRid, partitionKeyRangeId : this.PartitionKeyRangeId, forceRefresh : false); if (pkRange == null) { // Try with a refresh pkRange = await routingMapProvider.TryGetPartitionKeyRangeByIdAsync( collectionResourceId : containerRid, partitionKeyRangeId : this.PartitionKeyRangeId, forceRefresh : true); } if (pkRange == null) { throw CosmosExceptionFactory.Create( statusCode: HttpStatusCode.Gone, subStatusCode: (int)SubStatusCodes.PartitionKeyRangeGone, message: $"The PartitionKeyRangeId: \"{this.PartitionKeyRangeId}\" is not valid for the current container {containerRid} .", stackTrace: string.Empty, activityId: string.Empty, requestCharge: 0, retryAfter: null, headers: null, diagnosticsContext: null, error: null, innerException: null); } return(new List <Documents.Routing.Range <string> > { pkRange.ToRange() }); }
public override async Task <List <Documents.Routing.Range <string> > > GetEffectiveRangesAsync( IRoutingMapProvider routingMapProvider, string containerRid, Documents.PartitionKeyDefinition partitionKeyDefinition) { Documents.PartitionKeyRange pkRange = await routingMapProvider.TryGetPartitionKeyRangeByIdAsync(containerRid, this.PartitionKeyRangeId); if (pkRange == null) { throw new InvalidOperationException(); } return(new List <Documents.Routing.Range <string> > { pkRange.ToRange() }); }