private void Run()
        {
            AutoReseedManager.Tracer.TraceDebug((long)this.GetHashCode(), "AutoReseedManager: Entering Run()...");
            this.ResetState();
            IMonitoringADConfig config = this.m_adConfigProvider.GetConfig(true);

            if (MountPointUtil.IsConfigureMountPointsEnabled())
            {
                AutoReseedManager.Tracer.TraceDebug((long)this.GetHashCode(), "AutoReseedManager: Skipping running AutoReseedManager because regkey '{0}' is enabled.");
                return;
            }
            if (config.ServerRole == MonitoringServerRole.Standalone)
            {
                AutoReseedManager.Tracer.TraceDebug((long)this.GetHashCode(), "AutoReseedManager: Skipping running AutoReseedManager because local server is not a member of a DAG.");
                return;
            }
            if (!config.Dag.AutoDagAutoReseedEnabled)
            {
                AutoReseedManager.Tracer.TraceDebug <string>((long)this.GetHashCode(), "AutoReseedManager: Skipping running AutoReseedManager because the local DAG '{0}' has AutoDagAutoReseedEnabled set to disabled.", config.Dag.Name);
                return;
            }
            if (DiskReclaimerManager.ShouldSkipDueToServerNotConfigured(config.TargetMiniServer))
            {
                AutoReseedManager.Tracer.TraceDebug <AmServerName>((long)this.GetHashCode(), "AutoReseedManager: Skipping running AutoReseedManager because the local server '{0}' is not yet fully configured in the AD.", config.TargetServerName);
                return;
            }
            this.m_volumeManager.Refresh(config);
            IEnumerable <IADDatabase> enumerable = config.DatabaseMap[config.TargetServerName];

            foreach (IADDatabase db in enumerable)
            {
                this.ProcessDatabase(db, enumerable, config);
            }
        }
Esempio n. 2
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);
        }