示例#1
0
 public AutoReseedContext(IVolumeManager volumeManager, IReplicaInstanceManager replicaInstanceManager, IADDatabaseAvailabilityGroup dag, IADDatabase database, IEnumerable <IADDatabase> databases, AmServerName targetServerName, IADServer targetServer, CopyStatusClientCachedEntry targetCopyStatus, IEnumerable <CopyStatusClientCachedEntry> dbCopyStatuses, IEnumerable <CopyStatusClientCachedEntry> serverCopyStatuses, Dictionary <AmServerName, IEnumerable <CopyStatusClientCachedEntry> > dagCopyStatuses, AutoReseedServerLimiter reseedLimiter, IMonitoringADConfig adConfig)
 {
     this.VolumeManager          = volumeManager;
     this.ReplicaInstanceManager = replicaInstanceManager;
     this.Dag              = dag;
     this.Database         = database;
     this.Databases        = databases;
     this.TargetServerName = targetServerName;
     this.TargetServer     = targetServer;
     this.TargetCopyStatus = targetCopyStatus;
     this.CopyStatusesForTargetDatabase = dbCopyStatuses;
     this.CopyStatusesForTargetServer   = serverCopyStatuses;
     this.CopyStatusesForDag            = dagCopyStatuses;
     this.ReseedLimiter = reseedLimiter;
     this.AdConfig      = adConfig;
 }
示例#2
0

        
示例#3
0
        public void ReportDbCopyStatusesFound(IMonitoringADConfig adConfig, AmServerName serverName, IEnumerable <CopyStatusClientCachedEntry> statuses)
        {
            DbCopyHealthInfoInternalTable dbCopyHealthInfoInternalTable = null;

            lock (this.m_locker)
            {
                dbCopyHealthInfoInternalTable = this.m_healthTable;
            }
            foreach (CopyStatusClientCachedEntry copyStatusClientCachedEntry in statuses)
            {
                IADDatabase iaddatabase;
                string      text = adConfig.DatabaseByGuidMap.TryGetValue(copyStatusClientCachedEntry.DbGuid, out iaddatabase) ? iaddatabase.Name : copyStatusClientCachedEntry.DbGuid.ToString();
                DbCopyHealthInfoTable.Tracer.TraceDebug <string, string>((long)this.GetHashCode(), "Reporting that a copy status for database copy '{0}\\{1}' was possibly retrieved.", text, serverName.NetbiosName);
                dbCopyHealthInfoInternalTable.ReportDbCopyStatusFound(copyStatusClientCachedEntry.DbGuid, text, serverName, copyStatusClientCachedEntry);
            }
        }
        private HashSet <Guid> GetServersToBeDeleted(IMonitoringADConfig adConfig, IClusterDB clusdb, out Dictionary <Guid, IADServer> validServers)
        {
            validServers = new Dictionary <Guid, IADServer>();
            HashSet <Guid> allServersInClusdb       = this.GetAllServersInClusdb(clusdb);
            Dictionary <Guid, IADServer> dictionary = adConfig.Servers.ToDictionary((IADServer s) => s.Guid);

            foreach (Guid key in allServersInClusdb)
            {
                IADServer value;
                if (dictionary.TryGetValue(key, out value))
                {
                    validServers.Add(key, value);
                }
            }
            allServersInClusdb.ExceptWith(validServers.Keys);
            return(allServersInClusdb);
        }
        private void CleanupStaleEntries(IClusterDB clusdb)
        {
            IMonitoringADConfig          config = Dependencies.MonitoringADConfigProvider.GetConfig(true);
            HashSet <Guid>               validDatabaseGuids;
            HashSet <Guid>               databasesToBeDeleted = this.GetDatabasesToBeDeleted(config, clusdb, out validDatabaseGuids);
            Dictionary <Guid, IADServer> validServers;
            HashSet <Guid>               serversToBeDeleted = this.GetServersToBeDeleted(config, clusdb, out validServers);

            if (databasesToBeDeleted.Count == 0 && serversToBeDeleted.Count == 0)
            {
                this.staleDatabases.Clear();
                this.staleServers.Clear();
                return;
            }
            IADToplogyConfigurationSession adSession = ADSessionFactory.CreateIgnoreInvalidRootOrgSession(true);

            this.CleanupDatabases(adSession, clusdb, databasesToBeDeleted, validDatabaseGuids);
            this.CleanupServers(adSession, clusdb, serversToBeDeleted, validServers);
        }
        private HashSet <Guid> GetDatabasesToBeDeleted(IMonitoringADConfig adConfig, IClusterDB clusdb, out HashSet <Guid> validDatabaseGuids)
        {
            validDatabaseGuids = new HashSet <Guid>();
            Dictionary <Guid, AmDbStateInfo> allDbStatesFromClusdb = this.GetAllDbStatesFromClusdb(clusdb);

            foreach (KeyValuePair <Guid, AmDbStateInfo> keyValuePair in allDbStatesFromClusdb)
            {
                Guid        key             = keyValuePair.Key;
                DateTime    lastMountedTime = keyValuePair.Value.LastMountedTime;
                IADDatabase iaddatabase;
                bool        flag  = adConfig.DatabaseByGuidMap.TryGetValue(key, out iaddatabase);
                bool        flag2 = lastMountedTime > DateTime.UtcNow.AddDays(-5.0);
                if (flag || flag2)
                {
                    validDatabaseGuids.Add(key);
                }
            }
            return(new HashSet <Guid>(allDbStatesFromClusdb.Keys.Except(validDatabaseGuids)));
        }
示例#7
0
        private void Run()
        {
            IMonitoringADConfig config = this.m_adConfigProvider.GetConfig(true);

            if (config.ServerRole == MonitoringServerRole.Standalone)
            {
                return;
            }
            if (!config.Dag.AutoDagAutoReseedEnabled)
            {
                return;
            }
            IEnumerable <IADDatabase> enumerable = config.DatabaseMap[config.TargetServerName];

            foreach (IADDatabase db in enumerable)
            {
                this.ProcessDatabase(db, config);
            }
        }
示例#8
0
        private void ProcessDatabase(IADDatabase db, IMonitoringADConfig adConfig)
        {
            Exception ex = null;

            try
            {
                this.ProcessDatabaseInternal(db, adConfig);
            }
            catch (ReplayLagManagerException ex2)
            {
                ex = ex2;
            }
            catch (DatabaseValidationException ex3)
            {
                ex = ex3;
            }
            catch (AmCommonTransientException ex4)
            {
                ex = ex4;
            }
            catch (AmServerException ex5)
            {
                ex = ex5;
            }
            catch (AmServerTransientException ex6)
            {
                ex = ex6;
            }
            catch (ADOperationException ex7)
            {
                ex = ex7;
            }
            catch (ADTransientException ex8)
            {
                ex = ex8;
            }
            if (ex != null)
            {
                ReplayLagManager.Tracer.TraceError <string>((long)this.GetHashCode(), "ReplayLagManager.ProcessDatabase: Got exception when processing database '{0}'. Skipping this database.", db.Name);
                ReplayCrimsonEvents.ReplayLagManagerDatabaseError.LogPeriodic <string, Guid, string, Exception>(db.Guid, DiagCore.DefaultEventSuppressionInterval, db.Name, db.Guid, ex.Message, ex);
            }
        }
示例#9
0
        private void Run()
        {
            IMonitoringADConfig config = this.m_adConfigProvider.GetConfig(true);

            if (config.ServerRole == MonitoringServerRole.Standalone)
            {
                ReplayLagManager.Tracer.TraceDebug((long)this.GetHashCode(), "ReplayLagManager: Skipping running ReplayLagManager because local server is not a member of a DAG.");
                return;
            }
            if (!config.Dag.ReplayLagManagerEnabled)
            {
                ReplayLagManager.Tracer.TraceDebug <string>((long)this.GetHashCode(), "ReplayLagManager: Skipping running ReplayLagManager because the local DAG '{0}' has ReplayLagManagerEnabled set to disabled.", config.Dag.Name);
                return;
            }
            IEnumerable <IADDatabase> enumerable = config.DatabaseMap[config.TargetServerName];

            foreach (IADDatabase db in enumerable)
            {
                this.ProcessDatabase(db, config);
            }
        }
示例#10
0
 private void LookupCachedCopyStatusesAcrossDag(IMonitoringADConfig adConfig)
 {
     if (this.m_dagStatusResults == null)
     {
         this.m_dagStatusResults = new Dictionary <AmServerName, IEnumerable <CopyStatusClientCachedEntry> >(16);
     }
     foreach (KeyValuePair <AmServerName, IEnumerable <IADDatabase> > keyValuePair in adConfig.DatabaseMap)
     {
         AmServerName key = keyValuePair.Key;
         if (!this.m_dagStatusResults.ContainsKey(key))
         {
             AutoReseedManager.Tracer.TraceDebug <AmServerName>((long)this.GetHashCode(), "AutoReseedManager: Retrieving cached copy status results for all copies on server '{0}'.", key);
             IEnumerable <CopyStatusClientCachedEntry> copyStatusesByServer = this.m_statusLookup.GetCopyStatusesByServer(key, keyValuePair.Value, CopyStatusClientLookupFlags.None);
             this.m_dagStatusResults.Add(key, copyStatusesByServer);
         }
     }
     if (this.m_serverStatusResults == null)
     {
         this.m_dagStatusResults.TryGetValue(adConfig.TargetServerName, out this.m_serverStatusResults);
         this.m_seedLimiter = new AutoReseedServerLimiter(this.m_serverStatusResults);
     }
 }
示例#11
0
        private void RaiseServerLevelAlertsIfNecessary(IMonitoringADConfig adConfig)
        {
            ServerValidationResult serverValidationResult = new ServerValidationResult(adConfig.TargetMiniServer.Name, adConfig.TargetMiniServer.Guid);

            if (this.m_serverRedundancyAlert == null)
            {
                this.m_serverRedundancyAlert = new ServerLevelDatabaseRedundancyAlert(serverValidationResult.Identity, serverValidationResult.IdentityGuid, this.m_dbAlerts.OneRedundantCopy);
            }
            this.m_serverRedundancyAlert.RaiseAppropriateAlertIfNecessary(serverValidationResult);
            serverValidationResult = new ServerValidationResult(adConfig.TargetMiniServer.Name, adConfig.TargetMiniServer.Guid);
            if (this.m_serverStaleStatusAlert == null)
            {
                this.m_serverStaleStatusAlert = new ServerLevelDatabaseStaleStatusAlert(serverValidationResult.Identity, serverValidationResult.IdentityGuid, this.m_dbAlerts.StaleStatus);
            }
            this.m_serverStaleStatusAlert.RaiseAppropriateAlertIfNecessary(serverValidationResult);
            serverValidationResult = new ServerValidationResult("", Guid.Empty);
            if (this.m_potentialRedundancyAlertByRemoteServer == null)
            {
                this.m_potentialRedundancyAlertByRemoteServer = new PotentialRedundancyAlertByRemoteServer(this.m_dbAlerts.PotentialOneRedundantCopy);
            }
            this.m_potentialRedundancyAlertByRemoteServer.RaiseAppropriateAlertIfNecessary(serverValidationResult);
        }
示例#12
0
        // Token: 0x06000857 RID: 2135 RVA: 0x000284E4 File Offset: 0x000266E4
        public IEnumerable <IADDatabase> HandleMissingServerDatabases(AmServerName serverName)
        {
            ADConfig.Tracer.TraceError <AmServerName>((long)this.GetHashCode(), "Databases for server {0} not found", serverName);
            IReplayAdObjectLookup replayAdObjectLookup = Dependencies.ReplayAdObjectLookup;
            IADServer             iadserver            = replayAdObjectLookup.ServerLookup.FindServerByFqdn(serverName.Fqdn);

            if (iadserver != null)
            {
                this.Refresh("HandleMissingServerDatabases");
                IMonitoringADConfig currentConfig = this.GetCurrentConfig();
                if (currentConfig == null)
                {
                    return(null);
                }
                IEnumerable <IADDatabase> result = null;
                if (currentConfig.DatabaseMap.TryGetValue(serverName, out result))
                {
                    return(result);
                }
            }
            return(null);
        }
示例#13
0
 // Token: 0x060006C2 RID: 1730 RVA: 0x000208BA File Offset: 0x0001EABA
 public AmBcsServerValidation(AmServerName serverToCheck, AmServerName sourceServer, IADDatabase database, AmConfig amConfig, IAmBcsErrorLogger errorLogger, IMonitoringADConfig dagConfig)
 {
     this.ServerToCheck = serverToCheck;
     this.SourceServer  = sourceServer;
     this.Database      = database;
     this.AmConfig      = amConfig;
     this.ErrorLogger   = errorLogger;
     this.DagConfig     = dagConfig;
 }
示例#14
0
 public AmMultiNodeCopyStatusFetcher_ForPoller(IMonitoringADConfig adConfig, ActiveManager activeManager, ConcurrentDictionary <AmServerName, bool> rpcThreadsInProgress) : base(adConfig.AmServerNames, adConfig.DatabaseMap, RpcGetDatabaseCopyStatusFlags2.None, activeManager, false)
 {
     this.m_rpcThreadsInProgress = rpcThreadsInProgress;
 }
示例#15
0
        private void RaiseDatabasePotentialRedundancyAlertIfNecessary(IADDatabase db, IMonitoringADConfig adConfig)
        {
            if (this.stopWatch.Elapsed.TotalSeconds < (double)RegistryParameters.DatabaseHealthCheckDelayInRaisingDatabasePotentialRedundancyAlertDueToServiceStartInSec)
            {
                DatabaseHealthMonitor.Tracer.TraceDebug <string>((long)this.GetHashCode(), "DatabaseHealthMonitor.RaiseDatabasePotentialRedundancyAlertIfNecessary: Service just started, skip DB-level checks.", db.Name);
                return;
            }
            DatabaseHealthMonitor.Tracer.TraceDebug <string>((long)this.GetHashCode(), "DatabaseHealthMonitor.RaiseDatabasePotentialRedundancyAlertIfNecessary: DB '{0}': Starting DB-level checks.", db.Name);
            DatabaseReplicationNotStalledValidator databaseReplicationNotStalledValidator = new DatabaseReplicationNotStalledValidator(db, this.m_statusLookup, adConfig, this.m_propertyUpdateTracker, false);
            IHealthValidationResult healthValidationResult = databaseReplicationNotStalledValidator.Run();
            int databaseHealthCheckPotentialOneCopyTotalPassiveCopiesRequiredMin = RegistryParameters.DatabaseHealthCheckPotentialOneCopyTotalPassiveCopiesRequiredMin;

            if (!healthValidationResult.IsValidationSuccessful && healthValidationResult.TotalPassiveCopiesCount < databaseHealthCheckPotentialOneCopyTotalPassiveCopiesRequiredMin)
            {
                DatabaseHealthMonitor.Tracer.TraceDebug <string>((long)this.GetHashCode(), "DatabaseHealthMonitor.RaiseDatabasePotentialRedundancyAlertIfNecessary: DB '{0}': Skipping raising potential redundancy alert because not enough passive copies are found", db.Name);
                string text = string.Format("{0}-NotEnoughTotalPassiveCopies", healthValidationResult.Identity);
                ReplayCrimsonEvents.DatabaseLevelPotentialRedundancyCheckFailedButNotEnoughTotalPassiveCopies.LogPeriodic <string, int, int, int, int, string, Guid>(text, TimeSpan.FromMinutes(60.0), healthValidationResult.Identity, healthValidationResult.HealthyCopiesCount, healthValidationResult.HealthyPassiveCopiesCount, healthValidationResult.TotalPassiveCopiesCount, databaseHealthCheckPotentialOneCopyTotalPassiveCopiesRequiredMin, "", healthValidationResult.IdentityGuid);
                return;
            }
            this.m_dbAlerts.PotentialOneRedundantCopy.RaiseAppropriateAlertIfNecessary(healthValidationResult);
        }
 protected DatabaseValidatorBase(IADDatabase database, int numHealthyCopiesMinimum, int numHealthyPassiveCopiesMinimum, ICopyStatusClientLookup statusLookup, IMonitoringADConfig adConfig, PropertyUpdateTracker propertyUpdateTracker = null, bool isCopyRemoval = false, bool ignoreActivationDisfavored = true, bool ignoreMaintenanceChecks = true, bool ignoreTooManyActivesCheck = true, bool shouldSkipEvents = true)
 {
     this.m_database              = database;
     this.m_statusLookup          = statusLookup;
     this.m_adConfig              = adConfig;
     this.m_propertyUpdateTracker = propertyUpdateTracker;
     if (this.m_propertyUpdateTracker == null)
     {
         this.m_propertyUpdateTracker = new PropertyUpdateTracker();
     }
     this.m_isCopyRemoval = isCopyRemoval;
     this.m_ignoreActivationDisfavored = ignoreActivationDisfavored;
     this.m_ignoreMaintenanceChecks    = ignoreMaintenanceChecks;
     this.m_ignoreTooManyActivesCheck  = ignoreTooManyActivesCheck;
     this.m_skipEvents        = shouldSkipEvents;
     this.m_replayStateRegKey = string.Format("SOFTWARE\\Microsoft\\ExchangeServer\\v15\\Replay\\State\\{0}", database.Guid.ToString());
     this.m_result            = new DatabaseValidationResult(database.Name, database.Guid, adConfig.TargetServerName, numHealthyCopiesMinimum, numHealthyPassiveCopiesMinimum);
     this.m_errors            = new Dictionary <AmServerName, string>(5);
 }
示例#17
0
        private bool GetLatestHealthInfoAcrossDag(IMonitoringADConfig adConfig, out bool allFailed, out bool isNewPublish)
        {
            DatabaseHealthTracker.Tracer.TraceDebug((long)this.GetHashCode(), "GetLatestHealthInfoAcrossDag() called.");
            allFailed    = false;
            isNewPublish = false;
            Task <Tuple <string, DateTime> >[] array = this.ExecuteRemoteCallAcrossDagExcludingPAM <DateTime>("GetDagHealthInfoUpdateTimeUtcAsync", adConfig, (MonitoringServiceClient client) => client.WGetDagHealthInfoUpdateTimeUtcAsync());
            if (array == null)
            {
                DatabaseHealthTracker.Tracer.TraceDebug((long)this.GetHashCode(), "GetLatestHealthInfoAcrossDag(): There are no other servers in the DAG to contact. Proceed as Primary role.");
                return(true);
            }
            IEnumerable <Task <Tuple <string, DateTime> > > successful = array.GetSuccessful <Task <Tuple <string, DateTime> > >();

            if (successful.Count <Task <Tuple <string, DateTime> > >() == 0)
            {
                allFailed = true;
                DatabaseHealthTracker.Tracer.TraceError((long)this.GetHashCode(), "GetLatestHealthInfoAcrossDag(): All GetDagHealthInfoUpdateTimeUtcAsync() calls failed!");
                ReplayCrimsonEvents.DHTPrimaryStartupFailedNoResponses.LogPeriodic <string>("GetDagHealthInfoUpdateTimeUtcAsync", DateTimeHelper.OneHour, "GetDagHealthInfoUpdateTimeUtcAsync");
                return(false);
            }
            IOrderedEnumerable <Task <Tuple <string, DateTime> > > source = from task in successful
                                                                            orderby task.Result.Item2 descending
                                                                            select task;
            Task <Tuple <string, DateTime> > task2 = source.First <Task <Tuple <string, DateTime> > >();
            DateTime item  = task2.Result.Item2;
            string   item2 = task2.Result.Item1;

            DatabaseHealthTracker.Tracer.TraceDebug <string, DateTime>((long)this.GetHashCode(), "GetLatestHealthInfoAcrossDag(): Found server '{0}' with latest update time of '{1}'", item2, item);
            if (item == DateTime.MinValue)
            {
                isNewPublish = true;
                DatabaseHealthTracker.Tracer.TraceDebug((long)this.GetHashCode(), "GetLatestHealthInfoAcrossDag(): Setting isNewPublish to 'true'.");
                DatabaseHealthTracker.Tracer.TraceDebug((long)this.GetHashCode(), "GetLatestHealthInfoAcrossDag(): Skipping pulling health table from other nodes.");
                ReplayCrimsonEvents.DHTPrimaryStartupNewTable.Log();
                return(true);
            }
            DateTime localUpdateTime = this.m_healthTable.GetLastUpdateTime();
            string   text            = DateTimeHelper.ToStringInvariantCulture(localUpdateTime);

            if (localUpdateTime >= item)
            {
                DatabaseHealthTracker.Tracer.TraceDebug <string>((long)this.GetHashCode(), "GetLatestHealthInfoAcrossDag(): Local server has newer health table. Skipping pulling health table from other nodes. Local update time: {0}", text);
                return(true);
            }
            TimeSpan timeSpan = DateTimeHelper.SafeSubtract(DateTime.UtcNow, item);

            if (timeSpan > DatabaseHealthTracker.LastUpdateTimeDiffThreshold)
            {
                DatabaseHealthTracker.Tracer.TraceError <DateTime, TimeSpan, TimeSpan>((long)this.GetHashCode(), "GetLatestHealthInfoAcrossDag(): The newest health table was only modified too long ago at '{0}'! updateTimeDiff = '{1}', Threshold = '{2}'", item, timeSpan, DatabaseHealthTracker.LastUpdateTimeDiffThreshold);
                ReplayCrimsonEvents.DHTPrimaryStartupFromFileTooOld.LogPeriodic <DateTime, TimeSpan, TimeSpan>(Environment.MachineName, DateTimeHelper.OneHour, item, timeSpan, DatabaseHealthTracker.LastUpdateTimeDiffThreshold);
            }
            DatabaseHealthTracker.Tracer.TraceDebug <string>((long)this.GetHashCode(), "GetLatestHealthInfoAcrossDag(): Another server has newer health table. Will attempt to pull in an existing table. Local update time: {0}", text);
            IEnumerable <string> enumerable = from task in source
                                              let updateTime = task.Result.Item2
                                                               let serverName = task.Result.Item1
                                                                                where updateTime > localUpdateTime
                                                                                select serverName;

            Task <Tuple <string, HealthInfoPersisted> >[] tasks = this.ExecuteRemoteCallForServers <HealthInfoPersisted>("GetDagHealthInfoAsync", enumerable, (MonitoringServiceClient client) => client.WGetDagHealthInfoAsync());
            IEnumerable <Task <Tuple <string, HealthInfoPersisted> > > successful2 = tasks.GetSuccessful <Task <Tuple <string, HealthInfoPersisted> > >();

            if (successful2.Count <Task <Tuple <string, HealthInfoPersisted> > >() == 0)
            {
                allFailed = true;
                DatabaseHealthTracker.Tracer.TraceError((long)this.GetHashCode(), "GetLatestHealthInfoAcrossDag(): All GetDagHealthInfoAsync() calls failed!");
                ReplayCrimsonEvents.DHTPrimaryStartupFailedNoResponses.LogPeriodic <string>("GetDagHealthInfoAsync", DateTimeHelper.OneHour, "GetDagHealthInfoAsync");
                return(false);
            }
            Dictionary <string, HealthInfoPersisted> dictionary = successful2.ToDictionary((Task <Tuple <string, HealthInfoPersisted> > task) => task.Result.Item1, (Task <Tuple <string, HealthInfoPersisted> > task) => task.Result.Item2, StringComparer.OrdinalIgnoreCase);

            foreach (string text2 in enumerable)
            {
                DatabaseHealthTracker.Tracer.TraceDebug <string>((long)this.GetHashCode(), "UpdateHealthInfo() called with table from server '{0}'.", text2);
                HealthInfoPersisted healthInfoPersisted = dictionary[text2];
                if (this.m_healthTable.UpdateHealthInfo(healthInfoPersisted, true))
                {
                    ReplayCrimsonEvents.DHTPrimaryStartupReplacingTable.Log <string, string, string, string>(text2, healthInfoPersisted.LastUpdateTimeUtcStr, healthInfoPersisted.CreateTimeUtcStr, text);
                    break;
                }
            }
            return(true);
        }
示例#18
0
 // Token: 0x06001436 RID: 5174 RVA: 0x00051960 File Offset: 0x0004FB60
 public DatabaseRedundancyValidator(IADDatabase database, int numHealthyCopiesMinimum, ICopyStatusClientLookup statusLookup, IMonitoringADConfig adConfig, PropertyUpdateTracker propertyUpdateTracker, bool isCopyRemoval, bool ignoreActivationDisfavored, bool ignoreMaintenanceChecks, bool ignoreTooManyActivesCheck, bool shouldSkipEvents = true) : base(database, numHealthyCopiesMinimum, statusLookup, adConfig, propertyUpdateTracker, isCopyRemoval, ignoreActivationDisfavored, ignoreMaintenanceChecks, ignoreTooManyActivesCheck, shouldSkipEvents)
 {
 }
示例#19
0
 // Token: 0x06001447 RID: 5191 RVA: 0x00051B88 File Offset: 0x0004FD88
 public Arguments(AmServerName targetServer, AmServerName activeServer, IADDatabase database, CopyStatusClientCachedEntry copyStatus, CopyStatusClientCachedEntry activeCopyStatus, ICopyStatusClientLookup statusLookup, IMonitoringADConfig adConfig, PropertyUpdateTracker propertyUpdateTracker = null, bool ignoreActivationDisfavored = true, bool isCopyRemoval = false, bool ignoreMaintenanceChecks = true, bool ignoreTooManyActivesCheck = true)
 {
     this.m_targetServer               = targetServer;
     this.m_activeServer               = activeServer;
     this.m_database                   = database;
     this.m_copyStatus                 = copyStatus;
     this.m_activeCopyStatus           = activeCopyStatus;
     this.m_statusLookup               = statusLookup;
     this.m_adConfig                   = adConfig;
     this.m_propertyUpdateTracker      = propertyUpdateTracker;
     this.m_ignoreActivationDisfavored = ignoreActivationDisfavored;
     this.m_isCopyRemoval              = isCopyRemoval;
     this.m_ignoreMaintenanceChecks    = ignoreMaintenanceChecks;
     this.m_ignoreTooManyActivesCheck  = ignoreTooManyActivesCheck;
     if (this.m_activeServer == null)
     {
         this.m_activeServer = AmServerName.Empty;
     }
     this.m_dbName     = database.Name;
     this.m_dbCopyName = string.Format("{0}\\{1}", database.Name, targetServer.NetbiosName);
 }
示例#20
0
        private void Run()
        {
            IMonitoringADConfig config = this.m_adConfigProvider.GetConfig(true);

            if (config.ServerRole == MonitoringServerRole.Standalone)
            {
                DatabaseHealthTracker.Tracer.TraceDebug((long)this.GetHashCode(), "DatabaseHealthTracker: Skipping running health checks because local server is not a member of a DAG.");
                return;
            }
            if (config.Dag.ThirdPartyReplication == ThirdPartyReplicationMode.Enabled)
            {
                DatabaseHealthTracker.Tracer.TraceDebug <string>((long)this.GetHashCode(), "DatabaseHealthTracker: Dag '{0}' is in ThirdPartyReplication mode. Shutting down the DatabaseHealthTracker component.", config.Dag.Name);
                base.ChangeTimer(InvokeWithTimeout.InfiniteTimeSpan, InvokeWithTimeout.InfiniteTimeSpan);
                ThreadPool.QueueUserWorkItem(delegate(object stateNotUsed)
                {
                    base.Stop();
                });
                return;
            }
            IEnumerable <IADDatabase> expectedDatabases = config.DatabaseMap[config.TargetServerName];
            IEnumerable <CopyStatusClientCachedEntry> copyStatusesByServer = this.m_statusLookup.GetCopyStatusesByServer(config.TargetServerName, expectedDatabases, CopyStatusClientLookupFlags.None);

            this.m_pamTracker.ReportPAMStatus(copyStatusesByServer);
            bool isAMRoleChanged = this.m_pamTracker.IsAMRoleChanged;

            if (isAMRoleChanged)
            {
                DatabaseHealthTracker.Tracer.TraceDebug <string>((long)this.GetHashCode(), "ActiveManager role changed: Local node {0} the PAM!", this.m_pamTracker.IsPAM ? "*IS*" : "is *NOT*");
            }
            this.m_healthTable.Initialize();
            this.m_initCompleted.Set();
            if (this.m_pamTracker.ShouldTryToBecomePrimary())
            {
                bool flag;
                bool flag2;
                bool latestHealthInfoAcrossDag = this.GetLatestHealthInfoAcrossDag(config, out flag, out flag2);
                if (latestHealthInfoAcrossDag)
                {
                    DatabaseHealthTracker.Tracer.TraceDebug((long)this.GetHashCode(), "Local node is becoming the Primary role.");
                    if (flag2)
                    {
                        this.m_healthTable.SetCreateTimeIfNecessary(DateTime.UtcNow);
                    }
                    this.m_pamTracker.BecomePrimary();
                    ReplayCrimsonEvents.DHTBecomingPrimaryRole.Log();
                }
            }
            if (this.m_pamTracker.IsPAM && this.m_pamTracker.HasBecomePrimary)
            {
                ReplayCrimsonEvents.DHTRunningAsRole.LogPeriodic <string>(Environment.MachineName, DateTimeHelper.OneDay, "Primary");
            }
            else if (!this.m_pamTracker.IsPAM)
            {
                ReplayCrimsonEvents.DHTRunningAsRole.LogPeriodic <string>(Environment.MachineName, DateTimeHelper.OneDay, "Secondary");
            }
            if (!this.m_pamTracker.IsPAM)
            {
                DatabaseHealthTracker.Tracer.TraceDebug((long)this.GetHashCode(), "Timer thread exiting because the local node is *NOT* the PAM!");
                return;
            }
            if (!this.m_pamTracker.HasBecomePrimary)
            {
                DatabaseHealthTracker.Tracer.TraceError((long)this.GetHashCode(), "Timer thread exiting because the local node has not yet become the Primary role!");
                return;
            }
            foreach (AmServerName amServerName in config.AmServerNames)
            {
                DatabaseHealthTracker.Tracer.TraceDebug <string>((long)this.GetHashCode(), "Running for server '{0}'", amServerName.NetbiosName);
                this.m_healthTable.ReportServerFoundInAD(amServerName);
                IEnumerable <IADDatabase> enumerable = config.DatabaseMap[amServerName];
                this.m_healthTable.ReportDbCopiesFoundInAD(enumerable, amServerName);
                IEnumerable <CopyStatusClientCachedEntry> copyStatusesByServer2 = this.m_statusLookup.GetCopyStatusesByServer(amServerName, enumerable, CopyStatusClientLookupFlags.None);
                this.m_healthTable.ReportDbCopyStatusesFound(config, amServerName, copyStatusesByServer2);
            }
            this.m_healthTable.PossiblyReportObjectsNotFoundInAD(config);
            this.m_healthTable.UpdateAvailabilityRedundancyStates(config);
            this.m_healthTable.SetLastUpdateTime(DateTime.UtcNow);
            TransientErrorInfo.ErrorType errorType;
            if (this.m_publishTableSuppression.ReportSuccessPeriodic(out errorType))
            {
                this.PublishHealthInfoAcrossDag(config);
                Exception ex = this.m_healthTable.PersistHealthInfoToXml();
                if (ex != null)
                {
                    DatabaseHealthTracker.Tracer.TraceError <Exception>((long)this.GetHashCode(), "Failed to persist health info to XML file. Error: {0}", ex);
                    ReplayCrimsonEvents.DHTPrimaryPersistFailed.LogPeriodic <string, Exception>(Environment.MachineName, DateTimeHelper.OneHour, ex.Message, ex);
                    return;
                }
            }
            else
            {
                DatabaseHealthTracker.Tracer.TraceDebug((long)this.GetHashCode(), "Skipping to publish and persist health info locally and to other nodes due to periodic suppression.");
            }
        }
 // Token: 0x060011CA RID: 4554 RVA: 0x00049F40 File Offset: 0x00048140
 public void PossiblyReportObjectsNotFoundInAD(IMonitoringADConfig adConfig)
 {
     base.WriterLockedOperation(delegate
     {
         List <AmServerName> list = new List <AmServerName>();
         List <Guid> list2        = new List <Guid>();
         List <Tuple <DbHealthInfo, DbCopyHealthInfo> > list3 = new List <Tuple <DbHealthInfo, DbCopyHealthInfo> >();
         foreach (ServerHealthInfo serverHealthInfo in this.m_serverInfos.Values)
         {
             if (adConfig.LookupMiniServerByName(serverHealthInfo.ServerName) == null)
             {
                 this.ReportTransition(serverHealthInfo.ServerFoundInAD, false);
                 if (this.IsADObjectMissingTooLong(serverHealthInfo.ServerFoundInAD.FailedDuration))
                 {
                     list.Add(serverHealthInfo.ServerName);
                 }
             }
         }
         foreach (KeyValuePair <Guid, DbHealthInfo> keyValuePair in this.m_dbServerInfos)
         {
             Guid key                = keyValuePair.Key;
             DbHealthInfo value      = keyValuePair.Value;
             IADDatabase iaddatabase = null;
             bool flag               = true;
             if (adConfig.DatabaseByGuidMap.TryGetValue(key, out iaddatabase))
             {
                 flag = false;
             }
             foreach (DbCopyHealthInfo dbCopyHealthInfo in value.DbServerInfos.Values)
             {
                 bool flag2 = true;
                 if (!flag)
                 {
                     IADDatabaseCopy databaseCopy = iaddatabase.GetDatabaseCopy(dbCopyHealthInfo.ServerName.NetbiosName);
                     if (databaseCopy != null)
                     {
                         flag2 = false;
                     }
                 }
                 if (flag2)
                 {
                     this.ReportTransition(dbCopyHealthInfo.CopyFoundInAD, false);
                     if (this.IsADObjectMissingTooLong(dbCopyHealthInfo.CopyFoundInAD.FailedDuration))
                     {
                         list3.Add(new Tuple <DbHealthInfo, DbCopyHealthInfo>(value, dbCopyHealthInfo));
                     }
                 }
             }
             if (flag)
             {
                 this.ReportTransition(value.DbFoundInAD, false);
                 if (this.IsADObjectMissingTooLong(value.DbFoundInAD.FailedDuration))
                 {
                     list2.Add(key);
                 }
             }
         }
         if (list.Count > 0)
         {
             foreach (AmServerName key2 in list)
             {
                 this.m_serverInfos.Remove(key2);
             }
         }
         if (list3.Count > 0)
         {
             foreach (Tuple <DbHealthInfo, DbCopyHealthInfo> tuple in list3)
             {
                 tuple.Item1.RemoveDbCopy(tuple.Item2.ServerName);
             }
         }
         if (list2.Count > 0)
         {
             foreach (Guid key3 in list2)
             {
                 this.m_dbServerInfos.Remove(key3);
             }
         }
     });
 }
示例#22
0
        internal bool DetectLowSpace(IADDatabase db, IMonitoringADConfig adConfig)
        {
            if (db.ReplicationType != ReplicationType.Remote)
            {
                return(false);
            }
            if (!FailedSuspendedCopyAutoReseedWorkflow.IsAutoReseedEnabled(db))
            {
                return(false);
            }
            int num = RegistryParameters.SpaceMonitorMinHealthyCount;
            DatabaseRedundancyValidator databaseRedundancyValidator = new DatabaseRedundancyValidator(db, num, this.m_statusLookup, adConfig, null, true);
            IHealthValidationResult     healthValidationResult      = databaseRedundancyValidator.Run();
            CopyStatusClientCachedEntry targetCopyStatus            = healthValidationResult.TargetCopyStatus;

            if (targetCopyStatus == null || targetCopyStatus.CopyStatus == null || targetCopyStatus.Result != CopyStatusRpcResult.Success || targetCopyStatus.CopyStatus.CopyStatus != CopyStatusEnum.Healthy || targetCopyStatus.CopyStatus.DiskTotalSpaceBytes == 0UL)
            {
                return(false);
            }
            if (targetCopyStatus.CopyStatus.LastLogInfoIsStale || (targetCopyStatus.CopyStatus.GetCopyQueueLength() < (long)RegistryParameters.SpaceMonitorCopyQueueThreshold && targetCopyStatus.CopyStatus.GetReplayQueueLength() < (long)RegistryParameters.SpaceMonitorReplayQueueThreshold))
            {
                return(false);
            }
            if (healthValidationResult.IsTargetCopyHealthy)
            {
                num++;
            }
            long num2 = (long)(targetCopyStatus.CopyStatus.DiskFreeSpaceBytes / 1048576UL);
            long num3 = (long)(targetCopyStatus.CopyStatus.DiskTotalSpaceBytes / 1048576UL);
            long num4 = 0L;
            bool flag = false;

            if (num2 <= targetCopyStatus.CopyStatus.GetCopyQueueLength() || num3 <= 0L)
            {
                flag = true;
            }
            else
            {
                num4 = (num2 - targetCopyStatus.CopyStatus.GetCopyQueueLength()) * 1048576L / 1048576L;
                if (num4 <= (long)RegistryParameters.SpaceMonitorLowSpaceThresholdInMB)
                {
                    flag = true;
                }
            }
            SpaceMonitor.Tracer.TraceDebug((long)this.GetHashCode(), "SpaceMonitor.ProcessDatabase: Database '{0}' has {1}MB remaining = {2}MB effective. MinHealthy={3} ReportedHealthy={4}", new object[]
            {
                db.Name,
                num2,
                num4,
                num,
                healthValidationResult.HealthyCopiesCount
            });
            if (!flag)
            {
                this.m_actionSuppression.ReportSuccess(db.Guid);
                return(false);
            }
            bool flag2 = !this.m_actionSuppression.ReportFailure(db.Guid, this.SuppressionWindow);

            SpaceMonitor.Tracer.TraceError <string, bool>((long)this.GetHashCode(), "SpaceMonitor.ProcessDatabase: Local copy of Database '{0}' is low on space. Action suppressed = {1}", db.Name, flag2);
            if (flag2)
            {
                return(false);
            }
            ReplayCrimsonEvents.SpaceMonitorLowSpaceDetected.LogPeriodic <string, Guid, long, long, string, long, long, long, long, int, int>(db.Guid, this.m_lowSpaceLoggingPeriod, db.Name, db.Guid, num3, num2, string.Format("{0:0.000}", (double)num2 / (double)num3 * 100.0), targetCopyStatus.CopyStatus.GetCopyQueueLength(), targetCopyStatus.CopyStatus.GetReplayQueueLength(), targetCopyStatus.CopyStatus.LowestLogPresent, targetCopyStatus.CopyStatus.LastLogCopied, healthValidationResult.HealthyCopiesCount, num);
            return(healthValidationResult.HealthyCopiesCount >= num);
        }
示例#23
0
        internal NotificationAction NotifyLowDiskSpace(IADDatabase db, IMonitoringADConfig adConfig)
        {
            DatabaseRedundancyValidator databaseRedundancyValidator = new DatabaseRedundancyValidator(db, 1, this.m_statusLookup, adConfig, null, true);
            IHealthValidationResult     healthValidationResult      = databaseRedundancyValidator.Run();
            CopyStatusClientCachedEntry targetCopyStatus            = healthValidationResult.TargetCopyStatus;

            if (targetCopyStatus == null || targetCopyStatus.CopyStatus == null || targetCopyStatus.Result != CopyStatusRpcResult.Success || targetCopyStatus.CopyStatus.DiskTotalSpaceBytes == 0UL)
            {
                return(NotificationAction.None);
            }
            double num   = (double)RegistryParameters.SpaceMonitorLowSpaceThresholdInMB / 1024.0;
            double num2  = targetCopyStatus.CopyStatus.DiskFreeSpaceBytes / 1024.0 / 1024.0 / 1024.0;
            double num3  = 0.0;
            double num4  = 0.0;
            string text  = SpaceMonitor.FindVolume(new DirectoryInfo(db.EdbFilePath.PathName));
            string text2 = SpaceMonitor.FindVolume(new DirectoryInfo(db.LogFolderPath.PathName));

            if (!string.IsNullOrEmpty(text) && !string.IsNullOrEmpty(text2) && !text.Equals(text2, StringComparison.OrdinalIgnoreCase) && db.EdbFilePath.IsLocalFull)
            {
                ulong num5 = 0UL;
                ulong num6 = 0UL;
                DiskHelper.GetFreeSpace(db.EdbFilePath.PathName, out num5, out num6);
                num3 = num5 / 1024UL / 1024UL / 1024UL;
                num4 = num6 / 1024UL / 1024UL / 1024UL;
            }
            bool   flag  = false;
            string text3 = string.Empty;

            if (num2 <= num)
            {
                text3 = string.Format("'{0}' is low on log volume space [{1}]. Current={2:0.##} GB, Threshold={3:0.##} GB", new object[]
                {
                    db.Name,
                    text2,
                    num2,
                    num
                });
                flag = true;
            }
            if (num3 != 0.0 && num4 <= num)
            {
                text3 += string.Format("{0}'{1}' is low on EDB volume space [{2}]. Current={3:0.##} GB, Threshold={4:0.##} GB", new object[]
                {
                    Environment.NewLine,
                    db.Name,
                    text,
                    num4,
                    num
                });
                flag = true;
            }
            if (flag)
            {
                if (SpaceMonitor.LastNotificationHistory.ContainsKey(db.Name) && DateTime.UtcNow - SpaceMonitor.LastNotificationHistory[db.Name] < SpaceMonitor.NotificationFrequency)
                {
                    SpaceMonitor.Tracer.TraceDebug((long)this.GetHashCode(), "SpaceMonitor.ProcessDatabase: Database '{0}' is low on space but notification throttling is hit. LastNotify={1}, Throttling={2}mins, Message={3}", new object[]
                    {
                        db.Name,
                        SpaceMonitor.LastNotificationHistory.ContainsKey(db.Name) ? "Never" : SpaceMonitor.LastNotificationHistory[db.Name].ToString(),
                        SpaceMonitor.NotificationFrequency.TotalMinutes,
                        text3
                    });
                    return(NotificationAction.None);
                }
                Exception ex;
                if (BitlockerUtil.IsFilePathOnEncryptingVolume(db.LogFolderPath.PathName, out ex))
                {
                    SpaceMonitor.Tracer.TraceDebug <string>((long)this.GetHashCode(), "SpaceMonitor.ProcessDatabase: Database '{0}' is currently encrypting. Do not raise alert.", db.Name);
                    return(NotificationAction.None);
                }
                if (ex != null)
                {
                    string text4 = string.Format("IsFilePathOnEncryptingVolume({0}) failed: {1}", db.LogFolderPath.PathName, ex.Message);
                    ReplayCrimsonEvents.BitlockerQueryFailed.LogPeriodic <string, Exception>(Environment.MachineName, DiagCore.DefaultEventSuppressionInterval, text4, ex);
                }
                EventNotificationItem eventNotificationItem = new EventNotificationItem("MSExchangeDagMgmt", "EdbAndLogVolSpace", db.Name.ToUpper(), text3, text3, ResultSeverityLevel.Critical);
                eventNotificationItem.Publish(false);
                if (SpaceMonitor.LastNotificationHistory.ContainsKey(db.Name))
                {
                    SpaceMonitor.LastNotificationHistory[db.Name] = DateTime.UtcNow;
                }
                else
                {
                    SpaceMonitor.LastNotificationHistory.Add(db.Name, DateTime.UtcNow);
                }
                return(NotificationAction.RedRaised);
            }
            else
            {
                text3 = string.Format("{0} Status is OK - EdbFreeSpace={1:0.##} GB [{2}], LogFreeSpace={3:0.##} GB [{4}], Threshold={5:0.##} GB", new object[]
                {
                    db.Name,
                    num4,
                    text,
                    num2,
                    text2,
                    num
                });
                if (SpaceMonitor.LastNotificationHistory.ContainsKey(db.Name) && SpaceMonitor.LastNotificationHistory[db.Name] != DateTime.MinValue)
                {
                    EventNotificationItem eventNotificationItem2 = new EventNotificationItem("MSExchangeDagMgmt", "EdbAndLogVolSpace", db.Name.ToUpper(), text3, text3, ResultSeverityLevel.Informational);
                    eventNotificationItem2.Publish(false);
                    SpaceMonitor.LastNotificationHistory[db.Name] = DateTime.MinValue;
                    return(NotificationAction.GreenRaised);
                }
                SpaceMonitor.Tracer.TraceDebug((long)this.GetHashCode(), "SpaceMonitor.ProcessDatabase: Database '{0}' has enough space but red notification was never raised. LastNotify={1}, Throttling={2}mins, Message={3}", new object[]
                {
                    db.Name,
                    SpaceMonitor.LastNotificationHistory.ContainsKey(db.Name) ? SpaceMonitor.LastNotificationHistory[db.Name].ToString() : "Never",
                    SpaceMonitor.NotificationFrequency.TotalMinutes,
                    text3
                });
                return(NotificationAction.None);
            }
        }
示例#24
0
        private void ProcessDatabaseInternal(IADDatabase db, IEnumerable <IADDatabase> databases, IMonitoringADConfig adConfig)
        {
            AutoReseedManager.Tracer.TraceDebug <string>((long)this.GetHashCode(), "AutoReseedManager.ProcessDatabase: Processing Database '{0}'...", db.Name);
            if (db.ReplicationType != ReplicationType.Remote)
            {
                AutoReseedManager.Tracer.TraceDebug <string>((long)this.GetHashCode(), "AutoReseedManager.ProcessDatabase: Database '{0}' is not a replicated database.", db.Name);
            }
            IEnumerable <CopyStatusClientCachedEntry> enumerable = this.LookupCachedCopyStatuses(db);
            IEnumerable <IADDatabase>   databases2       = adConfig.DatabaseMap[adConfig.TargetServerName];
            CopyStatusClientCachedEntry targetCopyStatus = enumerable.FirstOrDefault((CopyStatusClientCachedEntry status) => status.ServerContacted.Equals(adConfig.TargetServerName));

            this.LookupCachedCopyStatusesAcrossDag(adConfig);
            AutoReseedContext context = new AutoReseedContext(this.m_volumeManager, this.m_replicaInstanceManager, adConfig.Dag, db, databases2, adConfig.TargetServerName, adConfig.TargetMiniServer, targetCopyStatus, enumerable, this.m_serverStatusResults, this.m_dagStatusResults, this.m_seedLimiter, adConfig);

            this.m_launcher.BeginAutoReseedIfNecessary(context);
        }
示例#25
0
        private void ProcessDatabase(IADDatabase db, IEnumerable <IADDatabase> databases, IMonitoringADConfig adConfig)
        {
            Exception ex = null;

            try
            {
                this.ProcessDatabaseInternal(db, databases, adConfig);
            }
            catch (AutoReseedException ex2)
            {
                ex = ex2;
            }
            catch (TaskServerException ex3)
            {
                ex = ex3;
            }
            catch (TaskServerTransientException ex4)
            {
                ex = ex4;
            }
            catch (AmServerException ex5)
            {
                ex = ex5;
            }
            catch (AmServerTransientException ex6)
            {
                ex = ex6;
            }
            catch (ADOperationException ex7)
            {
                ex = ex7;
            }
            catch (ADTransientException ex8)
            {
                ex = ex8;
            }
            if (ex != null)
            {
                AutoReseedManager.Tracer.TraceError <string>((long)this.GetHashCode(), "AutoReseedManager.ProcessDatabase: Got exception when processing database '{0}'. Skipping this database.", db.Name);
                string text = ex.Message;
                if (ex is AutoReseedException)
                {
                    text = ((AutoReseedException)ex).ErrorMsg;
                }
                ReplayCrimsonEvents.AutoReseedManagerDatabaseError.LogPeriodic <string, Guid, string, Exception>(db.Guid, DiagCore.DefaultEventSuppressionInterval, db.Name, db.Guid, text, ex);
            }
        }
 // Token: 0x0600143B RID: 5179 RVA: 0x000519C4 File Offset: 0x0004FBC4
 public DatabaseReplicationNotStalledValidator(IADDatabase database, ICopyStatusClientLookup statusLookup, IMonitoringADConfig adConfig, PropertyUpdateTracker propertyUpdateTracker, bool shouldSkipEvents = true) : base(database, 0, 1, statusLookup, adConfig, propertyUpdateTracker, false, true, true, true, shouldSkipEvents)
 {
     if (propertyUpdateTracker == null)
     {
         throw new ArgumentNullException("propertyUpdateTracker shouldn't be null for DatabaseReplicationNotStalledValidator");
     }
 }
示例#27
0
        private Task <Tuple <string, T> >[] ExecuteRemoteCallAcrossDagExcludingPAM <T>(string operationTraceName, IMonitoringADConfig adConfig, Func <MonitoringServiceClient, Task <Tuple <string, T> > > remoteOperation)
        {
            IEnumerable <AmServerName> source = from serverName in adConfig.AmServerNames
                                                where !serverName.IsLocalComputerName
                                                select serverName;

            return(this.ExecuteRemoteCallForServers <T>(operationTraceName, from server in source
                                                        select server.Fqdn, remoteOperation));
        }
 protected DatabaseValidatorBase(IADDatabase database, int numHealthyCopiesMinimum, ICopyStatusClientLookup statusLookup, IMonitoringADConfig adConfig, PropertyUpdateTracker propertyUpdateTracker = null, bool isCopyRemoval = false, bool ignoreActivationDisfavored = true, bool ignoreMaintenanceChecks = true, bool ignoreTooManyActivesCheck = true, bool shouldSkipEvents = true) : this(database, numHealthyCopiesMinimum, 0, statusLookup, adConfig, propertyUpdateTracker, isCopyRemoval, ignoreActivationDisfavored, ignoreMaintenanceChecks, ignoreTooManyActivesCheck, shouldSkipEvents)
 {
 }
示例#29
0
        private void Run()
        {
            DiskReclaimerManager.Tracer.TraceDebug((long)this.GetHashCode(), "DiskReclaimer: Entering Run()...");
            IMonitoringADConfig config = this.m_adConfigProvider.GetConfig(true);

            if (config.ServerRole == MonitoringServerRole.Standalone)
            {
                DiskReclaimerManager.Tracer.TraceDebug((long)this.GetHashCode(), "DiskReclaimer: Skipping running DiskReclaimerManager because local server is not a member of a DAG.");
                return;
            }
            if (!config.Dag.AutoDagDiskReclaimerEnabled)
            {
                DiskReclaimerManager.Tracer.TraceDebug <string>((long)this.GetHashCode(), "DiskReclaimer: Skipping running DiskReclaimerManager because the local DAG '{0}' has AutoDagDiskReclaimerEnabled set to disabled.", config.Dag.Name);
                return;
            }
            if (DiskReclaimerManager.ShouldSkipDueToServerNotConfigured(config.TargetMiniServer))
            {
                DiskReclaimerManager.Tracer.TraceDebug <AmServerName>((long)this.GetHashCode(), "DiskReclaimer: Skipping running DiskReclaimerManager because the local server '{0}' is not yet fully configured in the AD.", config.TargetServerName);
                return;
            }
            this.m_volumeManager.Refresh(config);
            if (MountPointUtil.IsConfigureMountPointsEnabled())
            {
                bool flag = false;
                DiskReclaimerManager.Tracer.TraceDebug((long)this.GetHashCode(), "DiskReclaimer: Regkey ConfigureMountPointsPostReInstall is set. Starting mountpoint configuration on all Exchange volumes.");
                ReplayCrimsonEvents.DiskReclaimerPostInstallConfigStarted.LogPeriodic <string>(Environment.MachineName, DiagCore.DefaultEventSuppressionInterval, "ConfigureMountPointsPostReInstall");
                this.ConfigureVolumesPostReInstall(config, out flag);
                this.m_volumeManager.Refresh(config);
                if (flag)
                {
                    DiskReclaimerManager.Tracer.TraceDebug((long)this.GetHashCode(), "DiskReclaimer: Database copies might be missing in AD. ConfigureMountPointsPostReInstall will not be disabled to allow DiskReclaimer to run again.");
                    return;
                }
                this.UpdateVolumeForNeverMountedActives(config);
                ReplayCrimsonEvents.DiskReclaimerPostInstallConfigCompleted.LogPeriodic <string>(Environment.MachineName, DiagCore.DefaultEventSuppressionInterval, "ConfigureMountPointsPostReInstall");
                DiskReclaimerManager.m_lastVolumeScanTime = DateTime.MinValue;
                Exception ex;
                if ((ex = MountPointUtil.DisableConfigureMountPoints()) != null)
                {
                    DiskReclaimerManager.Tracer.TraceError <Exception>((long)this.GetHashCode(), "DiskReclaimer: Failed to reset regkey ConfigureMountPointsPostReInstall after configuring mountpoints. Error: {0}", ex);
                    ReplayCrimsonEvents.DiskReclaimerError.LogPeriodic <Exception>(Environment.MachineName, DiagCore.DefaultEventSuppressionInterval, ex);
                }
            }
            this.m_volumeManager.DetermineMisconfiguredVolumes(config);
            if (!this.IsSafeToLookForQuarantinedDisks())
            {
                DiskReclaimerManager.Tracer.TraceDebug((long)this.GetHashCode(), "DiskReclaimer: Skip scanning for quarantined volumes...");
                return;
            }
            DiskReclaimerManager.m_lastVolumeScanTime = DateTime.UtcNow;
            ReplayCrimsonEvents.DiskReclaimerInitiated.Log();
            List <ExchangeVolume>[] array = this.m_volumeManager.DetermineVolumeSpareStatuses();
            List <ExchangeVolume>   list  = array[4];

            if (list == null || list.Count == 0)
            {
                DiskReclaimerManager.Tracer.TraceDebug((long)this.GetHashCode(), "Run(): No volumes that need to be reclaimed found. Exiting.");
            }
            else
            {
                DiskReclaimerManager.Tracer.TraceDebug <int>((long)this.GetHashCode(), "DiskReclaimer: Found {0} volumes that can potentially be reclaimed.", list.Count);
                DatabaseHealthValidationRunner databaseHealthValidationRunner = new DatabaseHealthValidationRunner(config.TargetServerName.NetbiosName);
                databaseHealthValidationRunner.Initialize();
                List <string> list2 = new List <string>();
                foreach (IHealthValidationResultMinimal healthValidationResultMinimal in databaseHealthValidationRunner.RunDatabaseRedundancyChecksForCopyRemoval(true, null, true, true, -1))
                {
                    if (!healthValidationResultMinimal.IsValidationSuccessful)
                    {
                        list2.Add(healthValidationResultMinimal.ErrorMessageWithoutFullStatus);
                    }
                }
                if (list2.Count == 0)
                {
                    DiskReclaimerManager.Tracer.TraceDebug((long)this.GetHashCode(), "DiskReclaimer: Passed copy removal redundancy check for this server. Trying to reclaim one quarantined volume...");
                    IEnumerable <IADDatabase> enumerable = config.DatabaseMap[config.TargetServerName];
                    IEnumerable <CopyStatusClientCachedEntry> copyStatusesByServer = this.m_statusLookup.GetCopyStatusesByServer(config.TargetServerName, enumerable, CopyStatusClientLookupFlags.None);
                    using (List <ExchangeVolume> .Enumerator enumerator2 = list.GetEnumerator())
                    {
                        while (enumerator2.MoveNext())
                        {
                            ExchangeVolume             exchangeVolume             = enumerator2.Current;
                            ExchangeVolumeDbStatusInfo filesInformationFromVolume = this.m_volumeManager.GetFilesInformationFromVolume(exchangeVolume, enumerable, copyStatusesByServer);
                            bool      flag2;
                            Exception ex2;
                            if (this.m_volumeManager.TryReclaimVolume(exchangeVolume, filesInformationFromVolume, out flag2, out ex2))
                            {
                                DiskReclaimerManager.Tracer.TraceDebug <MountedFolderPath, MountedFolderPath>((long)this.GetHashCode(), "DiskReclaimer: Successfully reclaimed volume '{0}' mounted at '{1}' as a spare.", exchangeVolume.VolumeName, exchangeVolume.ExchangeVolumeMountPoint);
                                ReplayCrimsonEvents.DiskReclaimerSucceeded.Log <string, string>(exchangeVolume.VolumeName.Path, exchangeVolume.ExchangeVolumeMountPoint.Path);
                                this.m_volumeManager.DetermineVolumeSpareStatuses();
                                break;
                            }
                            if (flag2)
                            {
                                DiskReclaimerManager.Tracer.TraceError <MountedFolderPath, MountedFolderPath, Exception>((long)this.GetHashCode(), "DiskReclaimer: Failed to reclaim volume '{0}' mounted at '{1}' as a spare. However, formatting the volume apparently succeeded. Error: {2}", exchangeVolume.VolumeName, exchangeVolume.ExchangeVolumeMountPoint, ex2);
                                ReplayCrimsonEvents.DiskReclaimerSparingFailed.Log <string, string, bool, string>(exchangeVolume.VolumeName.Path, exchangeVolume.ExchangeVolumeMountPoint.Path, flag2, ex2.Message);
                                this.m_volumeManager.DetermineVolumeSpareStatuses();
                                break;
                            }
                            DiskReclaimerManager.Tracer.TraceError <MountedFolderPath, MountedFolderPath, Exception>((long)this.GetHashCode(), "DiskReclaimer: Failed to format and reclaim volume '{0}' mounted at '{1}' as a spare. Error: {2}", exchangeVolume.VolumeName, exchangeVolume.ExchangeVolumeMountPoint, ex2);
                            ReplayCrimsonEvents.DiskReclaimerSparingFailed.Log <string, string, bool, string>(exchangeVolume.VolumeName.Path, exchangeVolume.ExchangeVolumeMountPoint.Path, flag2, ex2.Message);
                        }
                        goto IL_477;
                    }
                }
                string text = string.Join("\n\n", list2);
                DiskReclaimerManager.Tracer.TraceError <string>((long)this.GetHashCode(), "DiskReclaimer: Skip sparing. One or more databases on this server failed copy removal redundancy check. Reason: {0}", text);
                ReplayCrimsonEvents.DiskReclaimerRedundancyPrereqFailed.LogPeriodic <string>(text.GetHashCode(), DiagCore.DefaultEventSuppressionInterval, text);
            }
IL_477:
            this.RunBitlockerMaintenance(config);
        }
示例#30
0
 // Token: 0x06001435 RID: 5173 RVA: 0x00051940 File Offset: 0x0004FB40
 public DatabaseRedundancyValidator(IADDatabase database, int numHealthyCopiesMinimum, ICopyStatusClientLookup statusLookup, IMonitoringADConfig adConfig, PropertyUpdateTracker propertyUpdateTracker = null, bool shouldSkipEvents = true) : base(database, numHealthyCopiesMinimum, statusLookup, adConfig, propertyUpdateTracker, false, true, true, true, shouldSkipEvents)
 {
 }