Esempio n. 1
0
 private static TimeSpan PickLightJobs()
 {
     TestIntegration.Instance.Barrier("DontPickupJobs", null);
     CommonUtils.CatchKnownExceptions(delegate
     {
         DateTime utcNow = DateTime.UtcNow;
         if (utcNow > MRSService.nextLightJobsFullScanTime)
         {
             double num = CommonUtils.Randomize(ConfigBase <MRSConfigSchema> .GetConfig <TimeSpan>("FullScanLightJobsPollingPeriod").TotalSeconds, 0.2);
             MRSService.nextLightJobsFullScanTime = utcNow + TimeSpan.FromSeconds(num);
             MrsTracer.Service.Debug("Next light job full scan in {0} seconds, at {1}", new object[]
             {
                 (int)num,
                 MRSService.nextLightJobsFullScanTime
             });
             foreach (Guid mdbGuid in MapiUtils.GetDatabasesOnThisServer())
             {
                 MRSQueue.Get(mdbGuid).Tickle(MRSQueue.ScanType.Light);
             }
         }
         List <Guid> queuesToScan = MRSQueue.GetQueuesToScan(MRSQueue.ScanType.Light);
         if (queuesToScan != null)
         {
             foreach (Guid mdbGuid2 in queuesToScan)
             {
                 CommonUtils.CheckForServiceStopping();
                 MRSQueue.Get(mdbGuid2).PickupLightJobs();
             }
         }
     }, null);
     return(ConfigBase <MRSConfigSchema> .GetConfig <TimeSpan>("LightJobPickupPeriod"));
 }
Esempio n. 2
0
 private static TimeSpan PickHeavyJobs()
 {
     TestIntegration.Instance.Barrier("DontPickupJobs", null);
     CommonUtils.CatchKnownExceptions(delegate
     {
         DateTime utcNow = DateTime.UtcNow;
         bool flag       = false;
         TimeSpan config = ConfigBase <MRSConfigSchema> .GetConfig <TimeSpan>("ADInconsistencyCleanUpPeriod");
         if (config != TimeSpan.Zero && MRSService.lastADCleanUpScanFinishTime != null)
         {
             DateTime t = utcNow;
             if (t >= MRSService.lastADCleanUpScanFinishTime + config)
             {
                 ThreadPool.QueueUserWorkItem(new WaitCallback(MRSService.CleanADOprhanAndInconsistency));
             }
         }
         ReservationManager.UpdateHealthState();
         if (utcNow >= MRSService.NextFullScanTime)
         {
             MailboxReplicationServicePerformanceCounters.LastScanTime.RawValue = CommonUtils.TimestampToPerfcounterLong(utcNow);
             MRSService.lastFullScanTime = utcNow;
             flag         = true;
             double value = CommonUtils.Randomize(ConfigBase <MRSConfigSchema> .GetConfig <TimeSpan>("FullScanMoveJobsPollingPeriod").TotalSeconds, 0.2);
             MRSService.NextFullScanTime = utcNow + TimeSpan.FromSeconds(value);
             MrsTracer.Service.Debug("Next full scan at {0}", new object[]
             {
                 MRSService.NextFullScanTime
             });
             foreach (Guid mdbGuid in MapiUtils.GetDatabasesOnThisServer())
             {
                 MRSQueue.Get(mdbGuid).Tickle(MRSQueue.ScanType.Heavy);
             }
         }
         int num = 0;
         List <Guid> queuesToScan = MRSQueue.GetQueuesToScan(MRSQueue.ScanType.Heavy);
         if (queuesToScan != null)
         {
             foreach (Guid mdbGuid2 in queuesToScan)
             {
                 CommonUtils.CheckForServiceStopping();
                 bool flag2;
                 MRSQueue.Get(mdbGuid2).PickupHeavyJobs(out flag2);
                 if (flag2)
                 {
                     num++;
                 }
             }
         }
         if (flag)
         {
             MRSService.lastFullScanDuration = (long)(DateTime.UtcNow - utcNow).TotalMilliseconds;
             MailboxReplicationServicePerformanceCounters.LastScanDuration.RawValue     = MRSService.lastFullScanDuration;
             MailboxReplicationServicePerformanceCounters.UnreachableDatabases.RawValue = (long)num;
         }
     }, null);
     return(ConfigBase <MRSConfigSchema> .GetConfig <TimeSpan>("HeavyJobPickupPeriod"));
 }
 public static void CleanADOrphanAndInconsistency()
 {
     PartitionId[] allAccountPartitionIds = ADAccountPartitionLocator.GetAllAccountPartitionIds();
     for (int i = 0; i < allAccountPartitionIds.Length; i++)
     {
         PartitionId partitionId = allAccountPartitionIds[i];
         CommonUtils.CheckForServiceStopping();
         ADSessionSettings adsessionSettings = ADSessionSettings.FromAllTenantsPartitionId(partitionId);
         adsessionSettings.IncludeSoftDeletedObjects = true;
         adsessionSettings.IncludeInactiveMailbox    = true;
         IRecipientSession     recipientSession = DirectorySessionFactory.Default.GetTenantOrRootOrgRecipientSession(null, false, ConsistencyMode.PartiallyConsistent, null, adsessionSettings, 45, "CleanADOrphanAndInconsistency", "f:\\15.00.1497\\sources\\dev\\mrs\\src\\Service\\ADInconsistencyCheck.cs");
         IConfigurationSession configSession    = DirectorySessionFactory.Default.GetTenantOrTopologyConfigurationSession(null, false, ConsistencyMode.PartiallyConsistent, null, adsessionSettings, 52, "CleanADOrphanAndInconsistency", "f:\\15.00.1497\\sources\\dev\\mrs\\src\\Service\\ADInconsistencyCheck.cs");
         using (List <Guid> .Enumerator enumerator = MapiUtils.GetDatabasesOnThisServer().GetEnumerator())
         {
             while (enumerator.MoveNext())
             {
                 Guid dbGuid = enumerator.Current;
                 CommonUtils.CheckForServiceStopping();
                 DatabaseInformation databaseInformation = MapiUtils.FindServerForMdb(dbGuid, null, null, FindServerFlags.AllowMissing);
                 if (databaseInformation.IsMissing)
                 {
                     MrsTracer.Service.Debug("CleanADOrphanAndInconsistency Database {0} in Forest {1} is missing, skip it", new object[]
                     {
                         dbGuid,
                         databaseInformation.ForestFqdn
                     });
                 }
                 else
                 {
                     CommonUtils.CatchKnownExceptions(delegate
                     {
                         ADInconsistencyCheck.CleanADOrphanAndInconsistencyForRequests(recipientSession, configSession, dbGuid);
                     }, delegate(Exception f)
                     {
                         MrsTracer.Service.Error("CleanADOrphanAndInconsistency() failed for DB {0}. Error: {1}", new object[]
                         {
                             dbGuid,
                             CommonUtils.FullExceptionMessage(f, true)
                         });
                         MRSService.LogEvent(MRSEventLogConstants.Tuple_ScanADInconsistencyRequestFailEvent, new object[]
                         {
                             dbGuid,
                             string.Empty,
                             string.Empty,
                             CommonUtils.FullExceptionMessage(f, true)
                         });
                     });
                 }
             }
         }
     }
 }
Esempio n. 4
0
        protected override ICollection <ServiceIssue> RunFullIssueScan()
        {
            ICollection <ServiceIssue> collection = new List <ServiceIssue>();

            foreach (Guid mdbGuid in MapiUtils.GetDatabasesOnThisServer())
            {
                using (new DatabaseSettingsContext(mdbGuid, null).Activate())
                {
                    try
                    {
                        DatabaseInformation databaseInformation = MapiUtils.FindServerForMdb(mdbGuid, null, null, FindServerFlags.None);
                        string databaseName = databaseInformation.DatabaseName;
                        if (!databaseInformation.IsOnThisServer)
                        {
                            return(null);
                        }
                        using (MapiStore systemMailbox = MapiUtils.GetSystemMailbox(mdbGuid, false))
                        {
                            using (MapiFolder requestJobsFolder = RequestJobXML.GetRequestJobsFolder(systemMailbox))
                            {
                                using (MapiTable contentsTable = requestJobsFolder.GetContentsTable(ContentsTableFlags.DeferredErrors))
                                {
                                    if (contentsTable.GetRowCount() > 0)
                                    {
                                        RequestJobNamedPropertySet requestJobNamedPropertySet = RequestJobNamedPropertySet.Get(systemMailbox);
                                        contentsTable.SetColumns(requestJobNamedPropertySet.PropTags);
                                        Restriction    restriction = Restriction.GT(requestJobNamedPropertySet.PropTags[23], ConfigBase <MRSConfigSchema> .GetConfig <int>("PoisonLimit"));
                                        List <MoveJob> allMoveJobs = SystemMailboxJobs.GetAllMoveJobs(restriction, null, contentsTable, mdbGuid, null);
                                        if (allMoveJobs != null)
                                        {
                                            foreach (MoveJob job in allMoveJobs)
                                            {
                                                collection.Add(new MRSPoisonedJobIssue(job));
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }
                    catch (LocalizedException lastScanError)
                    {
                        base.LastScanError = lastScanError;
                    }
                }
            }
            return(collection);
        }
Esempio n. 5
0
        public static void UpdateHealthState()
        {
            foreach (WorkloadType workloadType in ReservationManager.interestingWorkloadTypes)
            {
                MRSResource.Cache.GetInstance(MRSResource.Id.ObjectGuid, workloadType);
                LocalServerReadResource.Cache.GetInstance(LocalServerResource.ResourceId, workloadType);
                LocalServerWriteResource.Cache.GetInstance(LocalServerResource.ResourceId, workloadType);
            }
            foreach (Guid resourceID in MapiUtils.GetDatabasesOnThisServer())
            {
                foreach (WorkloadType workloadType2 in ReservationManager.interestingWorkloadTypes)
                {
                    DatabaseReadResource.Cache.GetInstance(resourceID, workloadType2);
                    DatabaseWriteResource.Cache.GetInstance(resourceID, workloadType2);
                }
            }
            bool     logHealthState = false;
            TimeSpan t = DateTime.UtcNow - ReservationManager.wlmResourceStatsLastLoggingTimeUtc;

            if (ReservationManager.WLMResourceStatsLogEnabled && t >= ReservationManager.WLMResourceStatsLoggingPeriod)
            {
                logHealthState = true;
                ReservationManager.wlmResourceStatsLastLoggingTimeUtc = DateTime.UtcNow;
            }
            MRSResource.Cache.ForEach(delegate(MRSResource m)
            {
                m.UpdateHealthState(logHealthState);
            });
            LocalServerReadResource.Cache.ForEach(delegate(LocalServerReadResource m)
            {
                m.UpdateHealthState(logHealthState);
            });
            LocalServerWriteResource.Cache.ForEach(delegate(LocalServerWriteResource m)
            {
                m.UpdateHealthState(logHealthState);
            });
            DatabaseReadResource.Cache.ForEach(delegate(DatabaseReadResource m)
            {
                m.UpdateHealthState(logHealthState);
            });
            DatabaseWriteResource.Cache.ForEach(delegate(DatabaseWriteResource m)
            {
                m.UpdateHealthState(logHealthState);
            });
        }