public override SearchErrorInfo Remove(SearchId searchId, bool removeLogs) { MailboxSearchServer.Tracer.TraceFunction <string>((long)this.GetHashCode(), "MailboxSearchServer.Remove on {0}", searchId.SearchName); SearchErrorInfo errorInfo = null; SearchUtils.ExWatsonWrappedCall(delegate() { lock (this) { if (this.IsShutDown) { errorInfo = new SearchErrorInfo(-2147220983, Strings.SearchServerShutdown); } else if (this.searchWorkItemMap.ContainsKey(searchId)) { MailboxSearchServer.Tracer.TraceWarning <string>((long)this.GetHashCode(), "The search {0} is already started", searchId.SearchName); errorInfo = new SearchErrorInfo(-2147220980, Strings.ErrorRemoveOngoingSearch); } else if (this.pendingSearchIdMap.ContainsKey(searchId)) { this.pendingSearchIdMap.Remove(searchId); SearchEventLogger.Instance.LogDiscoverySearchPendingWorkItemsChangedEvent("RemovedFromPendingWorkItemsOnRemove", searchId.SearchName, searchId.MailboxDsName, this.pendingSearchIdMap.Count); } else { this.QueueSearchForDeletion(searchId, removeLogs, ref errorInfo); } } }); if (errorInfo != null && errorInfo.Failed) { MailboxSearchServer.LogErrorInfo("Error occured when trying to remove the search workitem", searchId, errorInfo); } return(errorInfo); }
public override SearchErrorInfo GetStatus(SearchId searchId, out SearchStatus searchStatus) { MailboxSearchServer.Tracer.TraceFunction <string>((long)this.GetHashCode(), "MailboxSearchServer.GetStatus {0}", searchId.SearchName); SearchErrorInfo errorInfo = null; searchStatus = null; SearchStatus theSearchStatus = null; SearchUtils.ExWatsonWrappedCall(delegate() { MailboxSearchWorkItem mailboxSearchWorkItem = null; if (!this.searchWorkItemMap.TryGetValue(searchId, out mailboxSearchWorkItem)) { MailboxSearchServer.Tracer.TraceWarning <string>((long)this.GetHashCode(), "The search {0} is not started", searchId.SearchName); errorInfo = new SearchErrorInfo(262658, Strings.SearchNotStarted); return; } try { theSearchStatus = mailboxSearchWorkItem.GetStatus(); } catch (ExportException ex) { MailboxSearchServer.Tracer.TraceError <ExportException>((long)this.GetHashCode(), "MailboxSearchServer.GetStatus error {0}", ex); errorInfo = new SearchErrorInfo(-2147220991, ex); } }); searchStatus = theSearchStatus; if (errorInfo != null && errorInfo.Failed) { MailboxSearchServer.LogErrorInfo("Error occured when trying to get the status of the search workitem", searchId, errorInfo); } return(errorInfo); }
private static void LogErrorInfo(string description, SearchId searchId, SearchErrorInfo errorInfo) { if (errorInfo.Exception == null) { SearchEventLogger.Instance.LogDiscoverySearchServerErrorEvent(description, searchId.SearchName, searchId.MailboxDsName, errorInfo.Message); return; } SearchEventLogger.Instance.LogDiscoverySearchServerErrorEvent(description, searchId.SearchName, searchId.MailboxDsName, errorInfo.Exception); }
internal void UpdateStatus(SearchId searchId) { SearchErrorInfo searchErrorInfo = null; base.UpdateStatus(searchId, out searchErrorInfo); this.lastErrorCode = searchErrorInfo.ErrorCode; if (searchErrorInfo.Failed) { throw new SearchServerException(searchErrorInfo.ErrorCode, searchErrorInfo.Message); } }
internal void Remove(SearchId searchId, bool removeLogs) { SearchErrorInfo searchErrorInfo = null; base.Remove(searchId, removeLogs, out searchErrorInfo); this.lastErrorCode = searchErrorInfo.ErrorCode; if (searchErrorInfo.Failed) { throw new SearchServerException(searchErrorInfo.ErrorCode, searchErrorInfo.Message); } }
internal void AbortEx(SearchId searchId, string userId) { SearchErrorInfo searchErrorInfo = null; base.AbortEx(searchId, userId, out searchErrorInfo); this.lastErrorCode = searchErrorInfo.ErrorCode; if (searchErrorInfo.Failed) { throw new SearchServerException(searchErrorInfo.ErrorCode, searchErrorInfo.Message); } }
internal void Start(SearchId searchId, Guid ownerGuid) { SearchErrorInfo searchErrorInfo = null; base.Start(searchId, ownerGuid, out searchErrorInfo); this.lastErrorCode = searchErrorInfo.ErrorCode; if (searchErrorInfo.Failed) { throw new SearchServerException(searchErrorInfo.ErrorCode, searchErrorInfo.Message); } }
public override SearchErrorInfo UpdateStatus(SearchId searchId) { MailboxSearchServer.Tracer.TraceFunction <string>((long)this.GetHashCode(), "MailboxSearchServer.UpdateStatus on {0}", searchId.SearchName); SearchErrorInfo errorInfo = null; SearchUtils.ExWatsonWrappedCall(delegate() { lock (this) { if (this.searchWorkItemMap.ContainsKey(searchId) || this.pendingSearchIdMap.ContainsKey(searchId)) { MailboxSearchServer.Tracer.TraceDebug <string>((long)this.GetHashCode(), "The search {0} is still in the queue. Not updating status", searchId.SearchName); } else { try { ADObjectId discoverySystemMailboxId = new ADObjectId(searchId.MailboxDsName, searchId.MailboxGuid); IMailboxSearchConfigurationProvider mailboxSearchConfigurationProvider = new MailboxSearchConfigurationProvider(discoverySystemMailboxId, searchId.SearchName); if (MailboxDiscoverySearch.IsInProgressState(mailboxSearchConfigurationProvider.SearchObject.Status)) { mailboxSearchConfigurationProvider.SearchObject.UpdateState(SearchStateTransition.Fail); mailboxSearchConfigurationProvider.UpdateSearchObject("UpdateStatus", 452); } else if (MailboxDiscoverySearch.IsInDeletionState(mailboxSearchConfigurationProvider.SearchObject.Status)) { this.QueueSearchForDeletion(searchId, true, ref errorInfo); } } catch (FormatException exception) { errorInfo = new SearchErrorInfo(-2147220990, exception); } catch (SearchObjectNotFoundException exception2) { errorInfo = new SearchErrorInfo(-2147220990, exception2); } catch (DataSourceOperationException exception3) { errorInfo = new SearchErrorInfo(-2147220990, exception3); } catch (NoInternalEwsAvailableException exception4) { errorInfo = new SearchErrorInfo(-2147220990, exception4); } } } }); if (errorInfo != null && errorInfo.Failed) { MailboxSearchServer.LogErrorInfo("Error occured when trying to update the status of the search workitem", searchId, errorInfo); } return(errorInfo); }
internal SearchStatus GetStatus(SearchId searchId) { SearchErrorInfo searchErrorInfo = null; SearchStatus status = base.GetStatus(searchId, out searchErrorInfo); this.lastErrorCode = searchErrorInfo.ErrorCode; if (searchErrorInfo.Failed) { throw new SearchServerException(searchErrorInfo.ErrorCode, searchErrorInfo.Message); } if (searchErrorInfo.ErrorCode == 262658) { return(null); } return(status); }
internal void RemoveWorkItem(SearchId searchId, bool releaseSemaphore, bool isEstimateOnly) { lock (this) { MailboxSearchWorkItem mailboxSearchWorkItem; if (this.searchWorkItemMap.TryGetValue(searchId, out mailboxSearchWorkItem)) { this.searchWorkItemMap.Remove(searchId); int num = -1; if (releaseSemaphore) { num = this.workItemSemaphore.Release(); } if (!isEstimateOnly && mailboxSearchWorkItem.Action == WorkItemAction.Start) { this.copySearchesInProgress--; } MailboxSearchServer.Tracer.TraceDebug <int, int>((long)this.GetHashCode(), "A search job is removed, Queue Length {0} and semaphore {1}", this.workItemQueue.Count, num + 1); SearchEventLogger.Instance.LogDiscoverySearchWorkItemQueueChangedEvent("RemovedFromRunningWorkItems", searchId.SearchName, searchId.MailboxDsName, mailboxSearchWorkItem.Action.ToString(), mailboxSearchWorkItem.IsEstimateOnly, this.workItemQueue.Count, this.searchWorkItemMap.Count, this.copySearchesInProgress, num + 1); SearchUtils.ExWatsonWrappedCall(delegate() { string ownerId = null; if (this.pendingSearchIdMap.TryGetValue(searchId, out ownerId)) { SearchErrorInfo searchErrorInfo = this.AddSearchToWorkItemQueue(searchId, ownerId); if (searchErrorInfo != null && searchErrorInfo.Failed) { MailboxSearchServer.LogErrorInfo("Error occured when try to Add a pending workitem to workitem queue", searchId, searchErrorInfo); } this.pendingSearchIdMap.Remove(searchId); MailboxSearchServer.Tracer.TraceDebug <int>((long)this.GetHashCode(), "Add pending search to the Queue, length = {0}", this.workItemQueue.Count); SearchEventLogger.Instance.LogDiscoverySearchPendingWorkItemsChangedEvent("RemovedFromPendingWorkItems", searchId.SearchName, searchId.MailboxDsName, this.pendingSearchIdMap.Count); } }); } else { MailboxSearchServer.Tracer.TraceError <string>((long)this.GetHashCode(), "Removing search {0} failed becasue it is not in the work item map.", searchId.SearchName); } } }
private void QueueSearchForDeletion(SearchId searchId, bool removeLogs, ref SearchErrorInfo errorInfo) { try { MailboxSearchWorkItem mailboxSearchWorkItem = new MailboxSearchWorkItem(this, searchId); mailboxSearchWorkItem.PreRemove(removeLogs); if (!mailboxSearchWorkItem.IsCompleted) { this.searchWorkItemMap[mailboxSearchWorkItem.SearchId] = mailboxSearchWorkItem; lock (this.workItemQueue) { this.workItemQueue.Insert(0, mailboxSearchWorkItem); int num = this.queueSemaphore.Release(); MailboxSearchServer.Tracer.TraceDebug <SearchId, int, int>((long)this.GetHashCode(), "WorkItem '{0}' is enqueued for remove, Queue length is {1}, Semaphore signals {2}", searchId, this.workItemQueue.Count, num + 1); SearchEventLogger.Instance.LogDiscoverySearchWorkItemQueueChangedEvent("EnqueuedAndAddedToRunningWorkItems", searchId.SearchName, searchId.MailboxDsName, mailboxSearchWorkItem.Action.ToString(), mailboxSearchWorkItem.IsEstimateOnly, this.workItemQueue.Count, this.searchWorkItemMap.Count, this.copySearchesInProgress, num + 1); } } } catch (FormatException ex) { MailboxSearchServer.Tracer.TraceError <FormatException>((long)this.GetHashCode(), "MailboxSearchServer.Remove error {0}", ex); errorInfo = new SearchErrorInfo(-2147220988, ex); } catch (ArgumentException ex2) { MailboxSearchServer.Tracer.TraceError <ArgumentException>((long)this.GetHashCode(), "MailboxSearchServer.Remove error {0}", ex2); errorInfo = new SearchErrorInfo(-2147220988, ex2); } catch (SearchObjectNotFoundException ex3) { MailboxSearchServer.Tracer.TraceError <SearchObjectNotFoundException>((long)this.GetHashCode(), "MailboxSearchServer.Remove error {0}", ex3); errorInfo = new SearchErrorInfo(-2147220990, ex3); } catch (ObjectNotFoundException ex4) { MailboxSearchServer.Tracer.TraceError <ObjectNotFoundException>((long)this.GetHashCode(), "MailboxSearchServer.Remove error {0}", ex4); errorInfo = new SearchErrorInfo(-2147220987, ex4); } catch (UnauthorizedAccessException ex5) { MailboxSearchServer.Tracer.TraceError <UnauthorizedAccessException>((long)this.GetHashCode(), "MailboxSearchServer.Remove error {0}", ex5); errorInfo = new SearchErrorInfo(-2147220982, ex5); } catch (StoragePermanentException ex6) { MailboxSearchServer.Tracer.TraceError <StoragePermanentException>((long)this.GetHashCode(), "MailboxSearchServer.Remove error {0}", ex6); errorInfo = new SearchErrorInfo(-2147220986, ex6); } catch (StorageTransientException ex7) { MailboxSearchServer.Tracer.TraceError <StorageTransientException>((long)this.GetHashCode(), "MailboxSearchServer.Remove error {0}", ex7); errorInfo = new SearchErrorInfo(-2147220985, ex7); } catch (ExportException ex8) { MailboxSearchServer.Tracer.TraceError <ExportException>((long)this.GetHashCode(), "MailboxSearchServer.Remove error {0}", ex8); errorInfo = new SearchErrorInfo(-2147220991, ex8); } catch (LocalizedException ex9) { MailboxSearchServer.Tracer.TraceError <LocalizedException>((long)this.GetHashCode(), "MailboxSearchServer.Remove error {0}", ex9); errorInfo = new SearchErrorInfo(-2147220991, ex9); } if (errorInfo != null && errorInfo.Failed) { MailboxSearchServer.LogErrorInfo("Error occured when trying to queue the search for deletion", searchId, errorInfo); } }
private SearchErrorInfo AddSearchToWorkItemQueue(SearchId searchId, string ownerId) { SearchErrorInfo result = null; try { MailboxSearchWorkItem mailboxSearchWorkItem = new MailboxSearchWorkItem(this, searchId); mailboxSearchWorkItem.PreStart(ownerId, null); this.searchWorkItemMap[searchId] = mailboxSearchWorkItem; lock (this.workItemQueue) { this.workItemQueue.Add(mailboxSearchWorkItem); int num = this.queueSemaphore.Release(); MailboxSearchServer.Tracer.TraceDebug <SearchId, int, int>((long)this.GetHashCode(), "WorkItem '{0}' is enqueued, Queue length is {1}, Semaphore signals {2}", searchId, this.workItemQueue.Count, num + 1); SearchEventLogger.Instance.LogDiscoverySearchWorkItemQueueChangedEvent("EnqueuedAndAddedToRunningWorkItems", searchId.SearchName, searchId.MailboxDsName, mailboxSearchWorkItem.Action.ToString(), mailboxSearchWorkItem.IsEstimateOnly, this.workItemQueue.Count, this.searchWorkItemMap.Count, this.copySearchesInProgress, num + 1); } } catch (FormatException ex) { MailboxSearchServer.Tracer.TraceError <FormatException>((long)this.GetHashCode(), "MailboxSearchServer.Start error {0}", ex); result = new SearchErrorInfo(-2147220988, ex); } catch (ArgumentException ex2) { MailboxSearchServer.Tracer.TraceError <ArgumentException>((long)this.GetHashCode(), "MailboxSearchServer.Start error {0}", ex2); result = new SearchErrorInfo(-2147220988, ex2); } catch (ParserException ex3) { MailboxSearchServer.Tracer.TraceError <ParserException>((long)this.GetHashCode(), "MailboxSearchServer.Start error {0}", ex3); result = new SearchErrorInfo(-2147220984, ex3); } catch (SearchQueryEmptyException ex4) { MailboxSearchServer.Tracer.TraceError <SearchQueryEmptyException>((long)this.GetHashCode(), "MailboxSearchServer.Start error {0}", ex4); result = new SearchErrorInfo(-2147220981, ex4); } catch (SearchObjectNotFoundException ex5) { MailboxSearchServer.Tracer.TraceError <SearchObjectNotFoundException>((long)this.GetHashCode(), "MailboxSearchServer.Start error {0}", ex5); result = new SearchErrorInfo(-2147220990, ex5); } catch (SearchDisabledException ex6) { MailboxSearchServer.Tracer.TraceError <SearchDisabledException>((long)this.GetHashCode(), "MailboxSearchServer.Start error {0}", ex6); result = new SearchErrorInfo(-2147220978, ex6); } catch (SearchOverBudgetException ex7) { MailboxSearchServer.Tracer.TraceError <SearchOverBudgetException>((long)this.GetHashCode(), "MailboxSearchServer.Start error {0}", ex7); result = new SearchErrorInfo(-2147220979, ex7); } catch (ObjectNotFoundException ex8) { MailboxSearchServer.Tracer.TraceError <ObjectNotFoundException>((long)this.GetHashCode(), "MailboxSearchServer.Start error {0}", ex8); result = new SearchErrorInfo(-2147220987, ex8); } catch (UnauthorizedAccessException ex9) { MailboxSearchServer.Tracer.TraceError <UnauthorizedAccessException>((long)this.GetHashCode(), "MailboxSearchServer.Start error {0}", ex9); result = new SearchErrorInfo(-2147220982, ex9); } catch (AuthzException ex10) { MailboxSearchServer.Tracer.TraceError <AuthzException>((long)this.GetHashCode(), "MailboxSearchServer.Start error {0}", ex10); result = new SearchErrorInfo(-2147220982, ex10); } catch (StoragePermanentException ex11) { MailboxSearchServer.Tracer.TraceError <StoragePermanentException>((long)this.GetHashCode(), "MailboxSearchServer.Start error {0}", ex11); result = new SearchErrorInfo(-2147220986, ex11); } catch (StorageTransientException ex12) { MailboxSearchServer.Tracer.TraceError <StorageTransientException>((long)this.GetHashCode(), "MailboxSearchServer.Start error {0}", ex12); result = new SearchErrorInfo(-2147220985, ex12); } catch (ExportException ex13) { MailboxSearchServer.Tracer.TraceError <ExportException>((long)this.GetHashCode(), "MailboxSearchServer.Start error {0}", ex13); result = new SearchErrorInfo(-2147220991, ex13); } catch (DataSourceOperationException ex14) { MailboxSearchServer.Tracer.TraceError <DataSourceOperationException>((long)this.GetHashCode(), "MailboxSearchServer.Start error {0}", ex14); result = new SearchErrorInfo(-2147220991, ex14); } catch (LocalizedException ex15) { MailboxSearchServer.Tracer.TraceError <LocalizedException>((long)this.GetHashCode(), "MailboxSearchServer.Start error {0}", ex15); result = new SearchErrorInfo(-2147220991, ex15); } return(result); }
public override SearchErrorInfo StartEx(SearchId searchId, string ownerId) { MailboxSearchServer.Tracer.TraceFunction <string, string>((long)this.GetHashCode(), "MailboxSearchServer.Start {0}, {1}", searchId.SearchName, ownerId); SearchErrorInfo errorInfo = null; SearchUtils.ExWatsonWrappedCall(delegate() { lock (this) { if (this.IsShutDown) { errorInfo = new SearchErrorInfo(-2147220983, Strings.SearchServerShutdown); } else { bool flag2 = false; bool flag3 = this.searchWorkItemMap.ContainsKey(searchId); bool flag4 = this.pendingSearchIdMap.ContainsKey(searchId); if (flag3 || flag4) { bool flag5 = false; if (flag3) { MailboxSearchWorkItem mailboxSearchWorkItem = this.searchWorkItemMap[searchId]; if (mailboxSearchWorkItem.Action != WorkItemAction.Remove) { flag5 = true; } } if (flag4) { flag5 = true; } if (flag5) { MailboxSearchServer.Tracer.TraceWarning <string>((long)this.GetHashCode(), "Search {0} is already started", searchId.SearchName); errorInfo = new SearchErrorInfo(262657, Strings.SearchAlreadStarted); } else { flag2 = true; } } if (errorInfo == null) { if (flag2) { this.pendingSearchIdMap.Add(searchId, ownerId); SearchEventLogger.Instance.LogDiscoverySearchPendingWorkItemsChangedEvent("AddedToPendingWorkItems", searchId.SearchName, searchId.MailboxDsName, this.pendingSearchIdMap.Count); } else { errorInfo = this.AddSearchToWorkItemQueue(searchId, ownerId); } } } } }); if (errorInfo != null && errorInfo.Failed) { MailboxSearchServer.LogErrorInfo("Error occured when trying to start the search by adding it to queue", searchId, errorInfo); } return(errorInfo); }
public override SearchErrorInfo AbortEx(SearchId searchId, string userId) { MailboxSearchServer.Tracer.TraceFunction <string>((long)this.GetHashCode(), "MailboxSearchServer.Abort on {0}", searchId.SearchName); SearchErrorInfo errorInfo = null; SearchUtils.ExWatsonWrappedCall(delegate() { lock (this) { if (!this.searchWorkItemMap.ContainsKey(searchId) && !this.pendingSearchIdMap.ContainsKey(searchId)) { MailboxSearchServer.Tracer.TraceWarning <string>((long)this.GetHashCode(), "The search {0} is not started", searchId.SearchName); try { ADObjectId discoverySystemMailboxId = new ADObjectId(searchId.MailboxDsName, searchId.MailboxGuid); IMailboxSearchConfigurationProvider mailboxSearchConfigurationProvider = new MailboxSearchConfigurationProvider(discoverySystemMailboxId, searchId.SearchName); if (MailboxDiscoverySearch.IsInProgressState(mailboxSearchConfigurationProvider.SearchObject.Status)) { mailboxSearchConfigurationProvider.SearchObject.UpdateState(SearchStateTransition.Fail); mailboxSearchConfigurationProvider.UpdateSearchObject("AbortEx", 317); } errorInfo = new SearchErrorInfo(262658, Strings.SearchNotStarted); goto IL_3A4; } catch (FormatException exception) { errorInfo = new SearchErrorInfo(-2147220990, exception); goto IL_3A4; } catch (SearchObjectNotFoundException exception2) { errorInfo = new SearchErrorInfo(-2147220990, exception2); goto IL_3A4; } catch (DataSourceOperationException exception3) { errorInfo = new SearchErrorInfo(-2147220990, exception3); goto IL_3A4; } } if (this.searchWorkItemMap.ContainsKey(searchId)) { MailboxSearchWorkItem searchWorkItem = this.searchWorkItemMap[searchId]; if (searchWorkItem.IsCompleted) { goto IL_3A4; } try { searchWorkItem.Abort(userId); } catch (ExportException ex) { MailboxSearchServer.Tracer.TraceError <ExportException>((long)this.GetHashCode(), "MailboxSearchServer.Abort error {0}", ex); errorInfo = new SearchErrorInfo(-2147220991, ex); } catch (DataSourceOperationException ex2) { MailboxSearchServer.Tracer.TraceError <DataSourceOperationException>((long)this.GetHashCode(), "MailboxSearchServer.Abort error {0}", ex2); errorInfo = new SearchErrorInfo(-2147220991, ex2); } lock (this.workItemQueue) { int num = this.workItemQueue.FindIndex((MailboxSearchWorkItem x) => x == searchWorkItem); if (num != -1) { if (num != 0) { this.workItemQueue.RemoveAt(num); this.workItemQueue.Insert(0, searchWorkItem); } int num2 = this.workItemSemaphore.Release(); MailboxSearchServer.Tracer.TraceDebug <int, int>((long)this.GetHashCode(), "MailboxSearch is aborted with Queue Length {0} and semaphore {1}", this.workItemQueue.Count, num2 + 1); SearchEventLogger.Instance.LogDiscoverySearchWorkItemQueueChangedEvent("MovedToFrontOfQueueOnAbort", searchId.SearchName, searchId.MailboxDsName, searchWorkItem.Action.ToString(), searchWorkItem.IsEstimateOnly, this.workItemQueue.Count, this.searchWorkItemMap.Count, this.copySearchesInProgress, num2 + 1); } goto IL_3A4; } } if (this.pendingSearchIdMap.ContainsKey(searchId)) { this.pendingSearchIdMap.Remove(searchId); SearchEventLogger.Instance.LogDiscoverySearchPendingWorkItemsChangedEvent("RemovedFromPendingWorkItemsOnAbort", searchId.SearchName, searchId.MailboxDsName, this.pendingSearchIdMap.Count); } IL_3A4:; } }); if (errorInfo != null && errorInfo.Failed) { MailboxSearchServer.LogErrorInfo("Error occured when trying to abort the search workitem", searchId, errorInfo); } return(errorInfo); }