Esempio n. 1
0
        private bool CheckForServices(SearchTestResult result)
        {
            bool flag = false;

            if (!SearchCommon.IsServiceRunning("MSExchangeIS", result.Server, out flag))
            {
                if (!flag)
                {
                    result.SetErrorTestResult(EventId.ServiceNotRunning, Strings.TestSearchServiceNotRunning("MSExchangeIS"));
                    return(true);
                }
            }
            else if (!SearchCommon.IsServiceRunning("MSExchangeFASTSearch", result.Server, out flag))
            {
                if (!flag)
                {
                    result.SetErrorTestResult(EventId.ServiceNotRunning, Strings.TestSearchServiceNotRunning("MSExchangeFASTSearch"));
                    return(true);
                }
            }
            else if (!SearchCommon.IsServiceRunning("HostControllerService", result.Server, out flag) && !flag)
            {
                result.SetErrorTestResult(EventId.ServiceNotRunning, Strings.TestSearchServiceNotRunning("HostControllerService"));
                return(true);
            }
            return(false);
        }
Esempio n. 2
0
        private MessageSearcher CreateMessageSearcher(SearchTestResult result)
        {
            if (result == null)
            {
                throw new ArgumentNullException("result");
            }
            Exception       ex      = null;
            MessageSearcher result2 = null;

            try
            {
                this.monitor.AddMonitoringEvent(result, Strings.TestSearchGetMapiStore(result.Mailbox));
                MapiStore mapiStore = MapiStore.OpenMailbox(result.Server, result.UserLegacyExchangeDN, result.MailboxGuid, result.DatabaseGuid, null, null, null, ConnectFlag.UseAdminPrivilege | ConnectFlag.UseSeparateConnection, OpenStoreFlag.UseAdminPrivilege | OpenStoreFlag.TakeOwnership | OpenStoreFlag.MailboxGuid, CultureInfo.InvariantCulture, null, "Client=Management;Action=Test-Search", null);
                if (mapiStore != null)
                {
                    result2 = new MessageSearcher(mapiStore, result, this.monitor, this.threadExit);
                }
                else
                {
                    result.SetErrorTestResult(EventId.MapiStoreError, Strings.TestSearchMapiStoreError(result.Mailbox, result.Database));
                }
            }
            catch (ADTransientException ex2)
            {
                ex = ex2;
            }
            catch (ADExternalException ex3)
            {
                ex = ex3;
            }
            catch (MapiExceptionNotFound mapiExceptionNotFound)
            {
                ex = mapiExceptionNotFound;
            }
            catch (MapiPermanentException ex4)
            {
                ex = ex4;
            }
            catch (MapiRetryableException ex5)
            {
                ex = ex5;
            }
            finally
            {
                if (ex is ADTransientException || ex is ADExternalException)
                {
                    result.SetErrorTestResult(EventId.ADError, Strings.TestSearchADError(ex.Message));
                }
                if (ex is MapiExceptionNotFound || ex is MapiPermanentException || ex is MapiRetryableException)
                {
                    this.HandleExceptionInTestThread(result.DatabaseGuid, EventId.MapiError, result, ex);
                }
            }
            return(result2);
        }
Esempio n. 3
0
        private void HandleExceptionInTestThread(Guid mdbGuid, EventId id, SearchTestResult result, Exception e)
        {
            if (this.CheckForServices(result))
            {
                return;
            }
            TestSearch.TestSearchTracer.TraceDebug <Exception>((long)this.GetHashCode(), "got exception {0}", e);
            string error = SearchCommon.DiagnoseException(result.Server, mdbGuid, e);

            if (id == EventId.MapiError)
            {
                result.SetErrorTestResult(id, Strings.TestSearchMapiError(result.Database, error));
                return;
            }
            result.SetErrorTestResult(id, Strings.TestSearchActiveManager(result.Database, error));
        }
Esempio n. 4
0
        internal void CheckForCatalogState(SearchTestResult result)
        {
            Guid         databaseGuid = result.DatabaseGuid;
            Guid         serverGuid   = result.ServerGuid;
            Guid         mailboxGuid  = result.MailboxGuid;
            AmServerName amServer     = new AmServerName(result.Server);

            this.monitor.AddMonitoringEvent(result, Strings.TestSearchGetMDBCatalogState(result.Database));
            base.WriteVerbose(Strings.TestSearchGetMDBCatalogState(result.Database));
            Exception ex;

            CopyStatusClientCachedEntry[] copyStatus = CopyStatusHelper.GetCopyStatus(amServer, RpcGetDatabaseCopyStatusFlags2.None, new Guid[]
            {
                databaseGuid
            }, 5000, null, out ex);
            if (ex != null || copyStatus == null || copyStatus.Length != 1)
            {
                this.monitor.AddMonitoringEvent(result, Strings.TestSearchGetCatalogStatusError(result.Database));
                return;
            }
            RpcDatabaseCopyStatus2 copyStatus2 = copyStatus[0].CopyStatus;

            base.WriteVerbose(Strings.TestSearchCatalogState(copyStatus2.ContentIndexStatus.ToString()));
            this.monitor.AddMonitoringEvent(result, Strings.TestSearchCatalogState(copyStatus2.ContentIndexStatus.ToString()));
            if (copyStatus2.ContentIndexStatus != ContentIndexStatusType.Healthy && copyStatus2.ContentIndexStatus != ContentIndexStatusType.HealthyAndUpgrading)
            {
                result.SetErrorTestResult(EventId.CatalogInUnhealthyState, Strings.TestSearchCatalogState(copyStatus2.ContentIndexStatus.ToString()));
                if (!string.IsNullOrWhiteSpace(copyStatus2.ContentIndexErrorMessage))
                {
                    this.monitor.AddMonitoringEvent(result, Strings.TestSearchCatalogErrorMessage(copyStatus2.ContentIndexErrorMessage));
                    return;
                }
            }
            else if (copyStatus2.ContentIndexBacklog != null)
            {
                int    value   = copyStatus2.ContentIndexBacklog.Value;
                string backlog = (value / 60).ToString();
                this.monitor.AddMonitoringEvent(result, Strings.TestSearchCatalogBacklog(backlog, copyStatus2.ContentIndexRetryQueueSize.ToString()));
                if (value > this.IndexingTimeoutInSeconds)
                {
                    result.SetErrorTestResult(EventId.CatalogBacklog, Strings.TestSearchCatalogBacklog(backlog, copyStatus2.ContentIndexRetryQueueSize.ToString()));
                }
            }
        }
Esempio n. 5
0
        private void CheckDatabaseRecoveryAndIndexEnabled(MailboxDatabase database, SearchTestResult result)
        {
            if (database == null)
            {
                throw new ArgumentNullException("database");
            }
            string mdb = database.ServerName + "\\\\" + database.Name;

            if (database.Recovery)
            {
                base.WriteVerbose(Strings.TestSearchRecoveryMdb(mdb));
                result.SetErrorTestResult(EventId.RecoveryMailboxDatabaseNotTested, Strings.TestSearchRecoveryMdb(mdb));
                return;
            }
            if (!database.IndexEnabled)
            {
                base.WriteVerbose(Strings.TestSearchCIIsDisabled(mdb));
                result.SetErrorTestResult(EventId.CIIsDisabled, Strings.TestSearchCIIsDisabled(mdb));
            }
        }
Esempio n. 6
0
        protected override void InternalValidate()
        {
            this.ResetForParametersFromPipeline();
            SearchTestResult searchTestResult = SearchTestResult.DefaultSearchTestResult;
            Exception        ex = null;

            try
            {
                if (this.Identity != null)
                {
                    base.InternalValidate();
                    ADUser dataObject = this.DataObject;
                    searchTestResult = this.GetTestResultFromMailbox(dataObject);
                    this.CheckDatabaseRecoveryAndIndexEnabled(this.GetMailboxDatabase(DatabaseIdParameter.Parse(dataObject.Database.Name)), searchTestResult);
                    this.WriteProgress(Strings.TestSearchCurrentMailbox(dataObject.DisplayName));
                    this.monitor.AddMonitoringEvent(searchTestResult, Strings.TestSearchCurrentMailbox(dataObject.DisplayName));
                    this.searchTestResults.Add(searchTestResult);
                }
                else
                {
                    List <MailboxDatabase> list = new List <MailboxDatabase>(1);
                    if (this.MailboxDatabase != null)
                    {
                        MailboxDatabase mailboxDatabase = this.GetMailboxDatabase(this.MailboxDatabase);
                        list.Add(mailboxDatabase);
                    }
                    else
                    {
                        if (this.Server == null)
                        {
                            this.Server = ServerIdParameter.Parse(Environment.MachineName);
                        }
                        Server server = this.GetServer(this.Server);
                        foreach (MailboxDatabase item in server.GetMailboxDatabases())
                        {
                            list.Add(item);
                        }
                        if (list.Count == 0)
                        {
                            throw new RecipientTaskException(Strings.TestSearchServerNoMdbs(server.Name));
                        }
                    }
                    foreach (MailboxDatabase mailboxDatabase2 in list)
                    {
                        searchTestResult = this.GetTestResultFromMailboxDatabase(mailboxDatabase2);
                        this.CheckDatabaseRecoveryAndIndexEnabled(mailboxDatabase2, searchTestResult);
                        this.WriteProgress(Strings.TestSearchCurrentMDB(mailboxDatabase2.Name));
                        this.monitor.AddMonitoringEvent(searchTestResult, Strings.TestSearchCurrentMDB(mailboxDatabase2.Name));
                        this.searchTestResults.Add(searchTestResult);
                    }
                }
            }
            catch (ADTransientException ex2)
            {
                ex = ex2;
            }
            catch (ADExternalException ex3)
            {
                ex = ex3;
            }
            catch (DatabaseNotFoundException ex4)
            {
                ex = ex4;
            }
            catch (ServerNotFoundException ex5)
            {
                ex = ex5;
            }
            catch (ObjectNotFoundException ex6)
            {
                ex = ex6;
            }
            catch (StorageTransientException ex7)
            {
                ex = ex7;
            }
            catch (StoragePermanentException ex8)
            {
                ex = ex8;
            }
            catch (RecipientTaskException ex9)
            {
                ex = ex9;
            }
            finally
            {
                if (ex is StorageTransientException || ex is StoragePermanentException)
                {
                    searchTestResult.SetErrorTestResult(EventId.ActiveManagerError, new LocalizedString(ex.Message));
                    this.WriteTestResult(searchTestResult);
                    base.WriteError(ex, ErrorCategory.ResourceUnavailable, null);
                }
                else if (ex != null)
                {
                    searchTestResult.SetErrorTestResult(EventId.ADError, new LocalizedString(ex.Message));
                    this.WriteTestResult(searchTestResult);
                    base.WriteError(ex, ErrorCategory.ResourceUnavailable, null);
                }
            }
        }