Ejemplo 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);
        }
Ejemplo n.º 2
0
        private SearchTestResult GetTestResultFromMailbox(ADUser user)
        {
            if (user == null)
            {
                throw new ArgumentNullException("user");
            }
            SearchTestResult defaultSearchTestResult = SearchTestResult.DefaultSearchTestResult;

            if (this.Archive)
            {
                if (user.ArchiveGuid == Guid.Empty)
                {
                    throw new RecipientTaskException(Strings.TestSearchMailboxNotArchived(user.Name));
                }
                defaultSearchTestResult.Database             = user.Database.ToString();
                defaultSearchTestResult.MailboxGuid          = user.ArchiveGuid;
                defaultSearchTestResult.Mailbox              = user.ArchiveName[0];
                defaultSearchTestResult.DatabaseGuid         = user.Database.ObjectGuid;
                defaultSearchTestResult.UserLegacyExchangeDN = user.LegacyExchangeDN;
            }
            else
            {
                defaultSearchTestResult.Database             = user.Database.ToString();
                defaultSearchTestResult.MailboxGuid          = user.ExchangeGuid;
                defaultSearchTestResult.Mailbox              = user.DisplayName;
                defaultSearchTestResult.DatabaseGuid         = user.Database.ObjectGuid;
                defaultSearchTestResult.UserLegacyExchangeDN = user.LegacyExchangeDN;
            }
            Server activeServer = this.GetActiveServer(defaultSearchTestResult.DatabaseGuid);

            defaultSearchTestResult.Server     = activeServer.Name;
            defaultSearchTestResult.ServerGuid = activeServer.Guid;
            return(defaultSearchTestResult);
        }
Ejemplo n.º 3
0
        private SearchTestResult GetTestResultFromMailboxDatabase(MailboxDatabase mdb)
        {
            if (mdb == null)
            {
                throw new ArgumentNullException("mdb");
            }
            SearchTestResult defaultSearchTestResult = SearchTestResult.DefaultSearchTestResult;

            defaultSearchTestResult.Database     = mdb.ToString();
            defaultSearchTestResult.DatabaseGuid = mdb.Guid;
            Server activeServer = this.GetActiveServer(mdb.Guid);

            defaultSearchTestResult.Server     = activeServer.Name;
            defaultSearchTestResult.ServerGuid = activeServer.Guid;
            ADUser monitoringMailbox = this.GetMonitoringMailbox(mdb, activeServer);

            if (monitoringMailbox == null)
            {
                throw new ManagementObjectNotFoundException(Strings.TestSearchMdbMonitorMbxIsNull(mdb.ToString()));
            }
            defaultSearchTestResult.UserLegacyExchangeDN = monitoringMailbox.LegacyExchangeDN;
            defaultSearchTestResult.Mailbox     = monitoringMailbox.DisplayName;
            defaultSearchTestResult.MailboxGuid = monitoringMailbox.ExchangeGuid;
            return(defaultSearchTestResult);
        }
Ejemplo n.º 4
0
 private void AddMonitoringEvent(SearchTestResult result, LocalizedString msg)
 {
     if (this.monitor != null)
     {
         this.monitor.AddMonitoringEvent(result, msg);
     }
 }
Ejemplo n.º 5
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);
        }
Ejemplo n.º 6
0
 private void ProcessFailureResult(SearchTestResult result)
 {
     if (result == null)
     {
         throw new ArgumentNullException("result");
     }
     if (this.CheckForServices(result))
     {
         return;
     }
     this.CheckForCatalogState(result);
 }
Ejemplo n.º 7
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));
        }
Ejemplo n.º 8
0
 internal MessageSearcher(MapiStore store, SearchTestResult searchResult, MonitorHelper monitor, StopClass threadExit)
 {
     if (store == null)
     {
         throw new ArgumentNullException("store");
     }
     if (searchResult == null)
     {
         throw new ArgumentNullException("searchResult");
     }
     this.store        = store;
     this.searchResult = searchResult;
     this.databaseGuid = searchResult.DatabaseGuid;
     this.searchString = DateTime.UtcNow.Ticks.ToString();
     this.monitor      = monitor;
     this.threadExit   = threadExit;
     this.ReadSleepTestHook();
 }
Ejemplo n.º 9
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()));
                }
            }
        }
Ejemplo n.º 10
0
 private void WriteTestResult(SearchTestResult result)
 {
     if (result == null)
     {
         throw new ArgumentNullException("result");
     }
     base.WriteObject(result);
     if (this.MonitoringContext)
     {
         this.monitoringData.Events.Clear();
         foreach (MonitoringEvent monitoringEvent in result.DetailEvents)
         {
             if (monitoringEvent.EventIdentifier != 1002)
             {
                 this.monitoringData.Events.Add(monitoringEvent);
             }
         }
         base.WriteObject(this.monitoringData, true);
     }
 }
Ejemplo n.º 11
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));
            }
        }
Ejemplo n.º 12
0
        private void SearchForMessage(MessageSearcher messageSearcher, SearchTestResult result)
        {
            if (messageSearcher == null)
            {
                throw new ArgumentNullException("messageSearcher");
            }
            if (result == null)
            {
                throw new ArgumentNullException("result");
            }
            TimeSpan  timeout = new TimeSpan(0, 0, 1);
            DateTime  utcNow  = DateTime.UtcNow;
            Exception ex      = null;

            try
            {
                this.threadExit.CheckStop();
                messageSearcher.InitializeSearch();
                bool flag      = false;
                int  tickCount = Environment.TickCount;
                while (!flag)
                {
                    this.threadExit.CheckStop();
                    try
                    {
                        flag = messageSearcher.DoSearch();
                        int tickCount2 = Environment.TickCount;
                        if (flag)
                        {
                            result.SetTestResult(true, new TimeSpan((long)((tickCount2 - tickCount) * 10000)).TotalSeconds);
                        }
                    }
                    catch (MapiRetryableException exception)
                    {
                        this.monitor.PushMessage(SearchCommon.DiagnoseException(result.Server, result.DatabaseGuid, exception));
                    }
                    this.threadExit.CheckStop();
                    if (!flag)
                    {
                        Thread.Sleep(timeout);
                    }
                }
            }
            catch (MapiExceptionNotFound mapiExceptionNotFound)
            {
                ex = mapiExceptionNotFound;
            }
            catch (MapiRetryableException ex2)
            {
                ex = ex2;
            }
            catch (MapiPermanentException ex3)
            {
                ex = ex3;
            }
            catch (TestSearchOperationAbortedException)
            {
                TestSearch.TestSearchTracer.TraceDebug((long)this.GetHashCode(), "Thread terminated on TestSearchOperationAbortedException");
                this.monitor.PushMessage(Strings.TestSearchTestThreadTimeOut);
                result.SetErrorTestResultWithTestThreadTimeOut();
            }
            finally
            {
                if (ex != null)
                {
                    this.HandleExceptionInTestThread(result.DatabaseGuid, EventId.MapiError, result, ex);
                }
            }
        }
Ejemplo n.º 13
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);
                }
            }
        }
Ejemplo n.º 14
0
 internal void AddMonitoringEvent(SearchTestResult searchTestResult, LocalizedString localizedString)
 {
     searchTestResult.DetailEvents.Add(new MonitoringEvent(this.MOMEventSource, 1002, EventTypeEnumeration.Information, localizedString, searchTestResult.Database));
     this.PushMessage(localizedString);
 }