protected void InvokeMethodAndHandleExceptions(Util.MethodDelegate method) { Util.HandleExceptions(delegate { Exception ex = null; try { method(); } catch (DiscoverySearchPermanentException ex2) { Factory.Current.LocalTaskTracer.TraceError <Guid, string>((long)this.GetHashCode(), "Correlation Id:{0}. Aggregated Search task failed. DiscoverySearchPermanentException: {1}", this.ExecutingUserIdentity.QueryCorrelationId, ex2.ToString()); ex = ex2; } catch (MultiMailboxSearchException ex3) { Factory.Current.LocalTaskTracer.TraceError <Guid, string>((long)this.GetHashCode(), "Correlation Id:{0}. Aggregated Search task failed. MultiMailboxSearchException: {1}", this.ExecutingUserIdentity.QueryCorrelationId, ex3.ToString()); ex = ex3; } catch (StoragePermanentException ex4) { Factory.Current.LocalTaskTracer.TraceError <Guid, string>((long)this.GetHashCode(), "Correlation Id:{0}. Aggregated Search task failed. StorageTransientException: {1}", this.ExecutingUserIdentity.QueryCorrelationId, ex4.ToString()); ex = ex4; } catch (StorageTransientException ex5) { Factory.Current.LocalTaskTracer.TraceError <Guid, string>((long)this.GetHashCode(), "Correlation Id:{0}. Aggregated Search task failed. StoragePermanentException: {1}", this.ExecutingUserIdentity.QueryCorrelationId, ex5.ToString()); ex = ex5; } catch (ADTransientException ex6) { Factory.Current.LocalTaskTracer.TraceError <Guid, string>((long)this.GetHashCode(), "Correlation Id:{0}. Aggregated Search task failed. ADTransientException: {1}", this.ExecutingUserIdentity.QueryCorrelationId, ex6.ToString()); ex = ex6; } finally { if (ex != null) { AggregatedSearchTaskResult result = (AggregatedSearchTaskResult)this.GetErrorResult(ex); this.callback(this, result); } } }, delegate(GrayException ex) { AggregatedSearchTaskResult result = (AggregatedSearchTaskResult)this.GetErrorResult((ex.InnerException != null) ? ex.InnerException : ex); this.callback(this, result); }); }
public void Execute(SearchCompletedCallback searchCallback) { if (searchCallback == null) { throw new ArgumentNullException("searchCallback"); } this.InvokeMethodAndHandleExceptions(delegate { this.attempts++; this.callback = searchCallback; AggregatedSearchTaskResult result = null; this.InitRpcSearchClient(); Factory.Current.LocalTaskTracer.TraceInformation(this.GetHashCode(), 0L, "Correlation Id:{0}. Executing {1} search for the queryFilter:{2} on {3} mailboxes in database:{4}", new object[] { this.ExecutingUserIdentity.QueryCorrelationId, (this.RpcClient.Criteria.SearchType == SearchType.Preview) ? "preview" : "keyword stats", this.RpcClient.Criteria.QueryString, this.MailboxInfoList.Count, this.RpcClient.MailboxDatabaseGuid }); if ((this.type & SearchType.Preview) == SearchType.Preview) { result = this.RpcClient.Search(Factory.Current.GetMaxRefinerResults(this.SearchCriteria.RecipientSession)); } else if ((this.type & SearchType.Statistics) == SearchType.Statistics) { List <IKeywordHit> keywordHits = this.RpcClient.GetKeywordHits(this.keywordList); IKeywordHit keywordHit; if (keywordHits == null) { keywordHit = null; } else { keywordHit = keywordHits.Find((IKeywordHit x) => x.Phrase.Equals(this.SearchCriteria.QueryString, StringComparison.OrdinalIgnoreCase)); } IKeywordHit keywordHit2 = keywordHit; result = new AggregatedSearchTaskResult(this.MailboxInfoList, keywordHits, (keywordHit2 != null) ? keywordHit2.Count : 0UL, (keywordHit2 != null) ? keywordHit2.Size : ByteQuantifiedSize.Zero); } this.UpdateSearchStatistics(); this.callback(this, result); }); }
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)); }