예제 #1
0
        public TermsQueryResultServerSide ExecuteGetTermsQuery(string indexName, string field, string fromValue, long?existingResultEtag, int pageSize, DocumentsOperationContext context, OperationCancelToken token, out Index index)
        {
            ObjectDisposedException lastException = null;

            for (var i = 0; i < NumberOfRetries; i++)
            {
                try
                {
                    index = GetIndex(indexName);

                    var etag = index.GetIndexEtag(null);
                    if (etag == existingResultEtag)
                    {
                        return(TermsQueryResultServerSide.NotModifiedResult);
                    }

                    return(index.GetTerms(field, fromValue, pageSize, context, token));
                }
                catch (ObjectDisposedException e)
                {
                    if (Database.DatabaseShutdown.IsCancellationRequested)
                    {
                        throw;
                    }

                    lastException = e;
                }
            }

            throw CreateRetriesFailedException(lastException);
        }
예제 #2
0
        public TermsQueryResultServerSide ExecuteGetTermsQuery(string indexName, string field, string fromValue, long?existingResultEtag, int pageSize, QueryOperationContext queryContext, OperationCancelToken token, out Index index)
        {
            Exception lastException = null;

            for (var i = 0; i < NumberOfRetries; i++)
            {
                try
                {
                    index = GetIndex(indexName);

                    queryContext.WithIndex(index);

                    var etag = index.GetIndexEtag(queryContext, null);
                    if (etag == existingResultEtag)
                    {
                        return(TermsQueryResultServerSide.NotModifiedResult);
                    }

                    return(index.GetTerms(field, fromValue, pageSize, queryContext, token));
                }
                catch (ObjectDisposedException e)
                {
                    if (Database.DatabaseShutdown.IsCancellationRequested)
                    {
                        throw;
                    }

                    lastException = e;

                    WaitForIndexBeingLikelyReplacedDuringQuery().GetAwaiter().GetResult();
                }
                catch (OperationCanceledException e)
                {
                    if (Database.DatabaseShutdown.IsCancellationRequested)
                    {
                        throw;
                    }

                    if (token.Token.IsCancellationRequested)
                    {
                        throw;
                    }

                    lastException = e;

                    WaitForIndexBeingLikelyReplacedDuringQuery().GetAwaiter().GetResult();
                }
            }

            throw CreateRetriesFailedException(lastException);
        }