internal override async Task <ContainerProperties> GetCachedContainerPropertiesAsync(
            string containerUri,
            ITrace trace,
            CancellationToken cancellationToken)
        {
            using (ITrace childTrace = trace.StartChild("Get Container Properties", TraceComponent.Transport, Tracing.TraceLevel.Info))
            {
                this.ThrowIfDisposed();
                ClientCollectionCache collectionCache = await this.DocumentClient.GetCollectionCacheAsync(childTrace);

                try
                {
                    return(await collectionCache.ResolveByNameAsync(
                               HttpConstants.Versions.CurrentVersion,
                               containerUri,
                               forceRefesh : false,
                               trace : childTrace,
                               clientSideRequestStatistics : null,
                               cancellationToken : cancellationToken));
                }
                catch (DocumentClientException ex)
                {
                    throw CosmosExceptionFactory.Create(ex, childTrace);
                }
            }
        }
Example #2
0
        internal override async Task <ContainerProperties> GetCachedContainerPropertiesAsync(
            string containerUri,
            ITrace trace,
            CancellationToken cancellationToken)
        {
            using (ITrace childTrace = trace.StartChild("Get Container Properties", TraceComponent.Transport, Tracing.TraceLevel.Info))
            {
                this.ThrowIfDisposed();
                CosmosDiagnosticsContext diagnosticsContext = CosmosDiagnosticsContextCore.Create(requestOptions: null);
                using (diagnosticsContext.GetOverallScope())
                {
                    ClientCollectionCache collectionCache = await this.DocumentClient.GetCollectionCacheAsync();

                    try
                    {
                        using (diagnosticsContext.CreateScope("ContainerCache.ResolveByNameAsync"))
                        {
                            return(await collectionCache.ResolveByNameAsync(
                                       HttpConstants.Versions.CurrentVersion,
                                       containerUri,
                                       forceRefesh : false,
                                       cancellationToken));
                        }
                    }
                    catch (DocumentClientException ex)
                    {
                        throw CosmosExceptionFactory.Create(ex, diagnosticsContext);
                    }
                }
            }
        }
        internal override async Task <ContainerProperties> GetCachedContainerPropertiesAsync(
            string containerUri,
            CancellationToken cancellationToken)
        {
            this.ThrowIfDisposed();
            CosmosDiagnosticsContext diagnosticsContext = CosmosDiagnosticsContextCore.Create(requestOptions: null);

            using (diagnosticsContext.GetOverallScope())
            {
                ClientCollectionCache collectionCache = await this.DocumentClient.GetCollectionCacheAsync();

                try
                {
                    using (diagnosticsContext.CreateScope("ContainerCache.ResolveByNameAsync"))
                    {
                        return(await collectionCache.ResolveByNameAsync(
                                   HttpConstants.Versions.CurrentVersion,
                                   containerUri,
                                   cancellationToken));
                    }
                }
                catch (DocumentClientException ex)
                {
                    throw CosmosExceptionFactory.Create(ex, diagnosticsContext);
                }
            }
        }
Example #4
0
        /// <summary>
        /// Gets the container's Properties by using the internal cache.
        /// In case the cache does not have information about this container, it may end up making a server call to fetch the data.
        /// </summary>
        /// <param name="cancellationToken"><see cref="CancellationToken"/> representing request cancellation.</param>
        /// <returns>A <see cref="Task"/> containing the <see cref="ContainerProperties"/> for this container.</returns>
        internal async Task <ContainerProperties> GetCachedContainerPropertiesAsync(CancellationToken cancellationToken = default(CancellationToken))
        {
            ClientCollectionCache collectionCache = await this.ClientContext.DocumentClient.GetCollectionCacheAsync();

            try
            {
                return(await collectionCache.ResolveByNameAsync(HttpConstants.Versions.CurrentVersion, this.LinkUri.OriginalString, cancellationToken));
            }
            catch (DocumentClientException ex)
            {
                throw new CosmosException(ex.ToCosmosResponseMessage(null), ex.Message, ex.Error);
            }
        }
Example #5
0
        /// <summary>
        /// Gets the container's Properties by using the internal cache.
        /// In case the cache does not have information about this container, it may end up making a server call to fetch the data.
        /// </summary>
        /// <param name="cancellationToken"><see cref="CancellationToken"/> representing request cancellation.</param>
        /// <returns>A <see cref="Task"/> containing the <see cref="ContainerProperties"/> for this container.</returns>
        internal override async Task <ContainerProperties> GetCachedContainerPropertiesAsync(CancellationToken cancellationToken = default(CancellationToken))
        {
            ClientCollectionCache collectionCache = await this.ClientContext.DocumentClient.GetCollectionCacheAsync();

            try
            {
                return(await collectionCache.ResolveByNameAsync(HttpConstants.Versions.CurrentVersion, this.LinkUri.OriginalString, cancellationToken));
            }
            catch (DocumentClientException ex)
            {
                throw CosmosExceptionFactory.Create(
                          dce: ex,
                          diagnosticsContext: null);
            }
        }
        /// <summary>
        /// Gets the container's Properties by using the internal cache.
        /// In case the cache does not have information about this container, it may end up making a server call to fetch the data.
        /// </summary>
        /// <param name="forceRefresh">Forces the cache to refresh</param>
        /// <param name="cancellationToken"><see cref="CancellationToken"/> representing request cancellation.</param>
        /// <returns>A <see cref="Task"/> containing the <see cref="ContainerProperties"/> for this container.</returns>
        public override async Task <ContainerProperties> GetCachedContainerPropertiesAsync(
            bool forceRefresh = false,
            CancellationToken cancellationToken = default)
        {
            try
            {
                ClientCollectionCache collectionCache = await this.ClientContext.DocumentClient.GetCollectionCacheAsync();

                return(await collectionCache.ResolveByNameAsync(
                           HttpConstants.Versions.CurrentVersion,
                           this.LinkUri,
                           forceRefresh,
                           cancellationToken));
            }
            catch (DocumentClientException ex)
            {
                throw CosmosExceptionFactory.Create(
                          dce: ex,
                          diagnosticsContext: null);
            }
        }
Example #7
0
        /// <summary>
        /// Gets the container's Properties by using the internal cache.
        /// In case the cache does not have information about this container, it may end up making a server call to fetch the data.
        /// </summary>
        /// <param name="forceRefresh">Forces the cache to refresh</param>
        /// <param name="trace">The trace.</param>
        /// <param name="cancellationToken"><see cref="CancellationToken"/> representing request cancellation.</param>
        /// <returns>A <see cref="Task"/> containing the <see cref="ContainerProperties"/> for this container.</returns>
        public override async Task <ContainerProperties> GetCachedContainerPropertiesAsync(
            bool forceRefresh,
            ITrace trace,
            CancellationToken cancellationToken)
        {
            try
            {
                ClientCollectionCache collectionCache = await this.ClientContext.DocumentClient.GetCollectionCacheAsync(trace);

                return(await collectionCache.ResolveByNameAsync(
                           HttpConstants.Versions.CurrentVersion,
                           this.LinkUri,
                           forceRefresh,
                           trace : trace,
                           clientSideRequestStatistics : null,
                           cancellationToken : cancellationToken));
            }
            catch (DocumentClientException ex)
            {
                throw CosmosExceptionFactory.Create(
                          dce: ex,
                          trace: trace);
            }
        }
Example #8
0
        /// <summary>
        /// Gets the container's Properties by using the internal cache.
        /// In case the cache does not have information about this container, it may end up making a server call to fetch the data.
        /// </summary>
        /// <param name="cancellationToken"><see cref="CancellationToken"/> representing request cancellation.</param>
        /// <returns>A <see cref="Task"/> containing the <see cref="ContainerProperties"/> for this container.</returns>
        internal async Task <ContainerProperties> GetCachedContainerPropertiesAsync(CancellationToken cancellationToken = default(CancellationToken))
        {
            ClientCollectionCache collectionCache = await this.ClientContext.DocumentClient.GetCollectionCacheAsync();

            return(await collectionCache.ResolveByNameAsync(HttpConstants.Versions.CurrentVersion, this.LinkUri.OriginalString, cancellationToken));
        }