Exemplo n.º 1
0
        private void HandleSearchCompletion(ISearchMailboxTask task, ISearchTaskResult result)
        {
            AggregatedMailboxSearchTask aggregatedMailboxSearchTask = task as AggregatedMailboxSearchTask;

            lock (this.locker)
            {
                Factory.Current.LocalTaskTracer.TraceDebug((long)this.GetHashCode(), "Correlation Id:{0}. {1} Search completed on {2} mailboxes, with query of length {3} with {4} keywords.The result was {5}", new object[]
                {
                    base.ExecutingUser.QueryCorrelationId,
                    (task.Type == SearchType.Preview) ? "Preview" : "Statistics",
                    aggregatedMailboxSearchTask.MailboxInfoList.Count,
                    string.IsNullOrEmpty(aggregatedMailboxSearchTask.SearchCriteria.QueryString) ? 0 : aggregatedMailboxSearchTask.SearchCriteria.QueryString.Trim().Length,
                    (aggregatedMailboxSearchTask.SearchCriteria.SubFilters != null && aggregatedMailboxSearchTask.SearchCriteria.SubFilters.Keys.Count > 0) ? aggregatedMailboxSearchTask.SearchCriteria.SubFilters.Keys.Count : 0,
                    (result != null && result.Success) ? "Success" : "Failure"
                });
                this.tasksInProgress--;
                this.scheduledTasks.Remove(task);
                if (result != null && task.ShouldRetry(result))
                {
                    Factory.Current.LocalTaskTracer.TraceDebug((long)this.GetHashCode(), "Correlation Id:{0}. Retrying {1} Search completed on {2} mailboxes, with query of length {3} with {4} keywords.", new object[]
                    {
                        base.ExecutingUser.QueryCorrelationId,
                        (task.Type == SearchType.Preview) ? "Preview" : "Statistics",
                        aggregatedMailboxSearchTask.MailboxInfoList.Count,
                        string.IsNullOrEmpty(aggregatedMailboxSearchTask.SearchCriteria.QueryString) ? 0 : aggregatedMailboxSearchTask.SearchCriteria.QueryString.Trim().Length,
                        (aggregatedMailboxSearchTask.SearchCriteria.SubFilters != null && aggregatedMailboxSearchTask.SearchCriteria.SubFilters.Keys.Count > 0) ? aggregatedMailboxSearchTask.SearchCriteria.SubFilters.Keys.Count : 0
                    });
                    this.queue.Enqueue(task);
                }
                else
                {
                    this.completed++;
                    if (result != null)
                    {
                        base.ResultAggregator.MergeSearchResult(result);
                    }
                    aggregatedMailboxSearchTask.Dispose();
                    if (this.completed == this.totalTasks)
                    {
                        this.ReportCompletion();
                    }
                }
                if (!this.cancelled)
                {
                    this.Dispatch();
                }
            }
        }
Exemplo n.º 2
0
        public bool ShouldRetry(ISearchTaskResult taskResult)
        {
            AggregatedSearchTaskResult aggregatedSearchTaskResult = taskResult as AggregatedSearchTaskResult;

            if (aggregatedSearchTaskResult == null)
            {
                throw new ArgumentNullException("result");
            }
            if (this.type != aggregatedSearchTaskResult.ResultType)
            {
                throw new ArgumentException("result types don't match");
            }
            if (aggregatedSearchTaskResult.Success)
            {
                return(false);
            }
            Exception exception = aggregatedSearchTaskResult.Exception;

            return(this.attempts <= 3 && exception != null && (exception is DiscoverySearchMaxSearchesExceeded || exception is DiscoveryKeywordStatsSearchTimedOut || exception is DiscoverySearchTimedOut || exception is StorageTransientException || exception is ADTransientException || exception is SearchTransientException));
        }
Exemplo n.º 3
0
        private void SearchCompletedCallback(ISearchMailboxTask task, ISearchTaskResult result)
        {
            AggregatedMailboxSearchTask aggregatedMailboxSearchTask = task as AggregatedMailboxSearchTask;

            lock (this.locker)
            {
                if (!this.cancelled)
                {
                    this.HandleSearchCompletion(task, result);
                }
                else
                {
                    Factory.Current.LocalTaskTracer.TraceDebug((long)this.GetHashCode(), "Correlation Id:{0}. {1} Search completed on {2} mailboxes, with query of length {3} with {4} keywords. But not merging the results because search was cancelled.", new object[]
                    {
                        base.ExecutingUser.QueryCorrelationId,
                        (task.Type == SearchType.Preview) ? "Preview" : "Statistics",
                        aggregatedMailboxSearchTask.MailboxInfoList.Count,
                        string.IsNullOrEmpty(aggregatedMailboxSearchTask.SearchCriteria.QueryString) ? 0 : aggregatedMailboxSearchTask.SearchCriteria.QueryString.Trim().Length,
                        (aggregatedMailboxSearchTask.SearchCriteria.SubFilters != null && aggregatedMailboxSearchTask.SearchCriteria.SubFilters.Keys.Count > 0) ? aggregatedMailboxSearchTask.SearchCriteria.SubFilters.Keys.Count : 0
                    });
                }
            }
        }