Ejemplo n.º 1
0
        public static void Tickle(Guid mailboxGuid, Guid requestQueueMdbGuid, MoveRequestNotification operation)
        {
            MrsTracer.Service.Debug("Processing tickled mailbox: {0}, requestQueueMdbGuid: {1}, operation: {2}", new object[]
            {
                mailboxGuid,
                requestQueueMdbGuid,
                operation
            });
            if (MailboxSyncerJobs.ProcessJob(mailboxGuid, false, delegate(BaseJob job)
            {
                job.NeedToRefreshRequest = true;
            }))
            {
                return;
            }
            MRSQueue mrsqueue = MRSQueue.Get(requestQueueMdbGuid);

            switch (operation)
            {
            case MoveRequestNotification.Created:
            case MoveRequestNotification.Canceled:
                mrsqueue.Tickle(MRSQueue.ScanType.Heavy);
                return;

            case MoveRequestNotification.Updated:
            case MoveRequestNotification.SuspendResume:
                mrsqueue.Tickle(MRSQueue.ScanType.Light);
                mrsqueue.Tickle(MRSQueue.ScanType.Heavy);
                return;

            default:
                return;
            }
        }
Ejemplo n.º 2
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"));
 }
Ejemplo n.º 3
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"));
 }
Ejemplo n.º 4
0
        public static MRSQueue Get(Guid mdbGuid)
        {
            MRSQueue mrsqueue;

            lock (MRSQueue.locker)
            {
                if (!MRSQueue.queues.TryGetValue(mdbGuid, out mrsqueue))
                {
                    mrsqueue = new MRSQueue(mdbGuid);
                    MRSQueue.queues.TryInsertSliding(mdbGuid, mrsqueue, MRSQueue.CacheTimeout);
                }
            }
            return(mrsqueue);
        }
Ejemplo n.º 5
0
        public static XElement GetDiagnosticInfo(MRSDiagnosticArgument arguments)
        {
            XElement xelement = new XElement("Queues");

            lock (MRSQueue.locker)
            {
                using (List <MRSQueue> .Enumerator enumerator = MRSQueue.queues.Values.GetEnumerator())
                {
                    while (enumerator.MoveNext())
                    {
                        MRSQueue queue = enumerator.Current;
                        xelement.Add(arguments.RunDiagnosticOperation(() => queue.GetQueueDiagnosticInfo(arguments)));
                    }
                }
            }
            return(xelement);
        }
        MoveRequestInfo IMailboxReplicationService.GetMoveRequestInfo(Guid requestGuid)
        {
            MoveRequestInfo result = new MoveRequestInfo();

            this.ForwardKnownExceptions(delegate
            {
                if (!MailboxSyncerJobs.ProcessJob(requestGuid, false, delegate(BaseJob job)
                {
                    result = job.GetMoveRequestInfo();
                }))
                {
                    MrsTracer.Service.Debug("Request {0} is not active.", new object[]
                    {
                        requestGuid
                    });
                    result.Message = MRSQueue.GetJobPickupFailureMessageForRequest(requestGuid);
                }
            }, null);
            return(result);
        }
Ejemplo n.º 7
0
        public static LocalizedString GetJobPickupFailureMessageForRequest(Guid requestGuid)
        {
            LocalizedString result = LocalizedString.Empty;
            List <Guid>     list   = MRSQueue.GetQueues();

            if (!list.IsNullOrEmpty())
            {
                foreach (Guid mdbGuid in list)
                {
                    MRSQueue            mrsqueue        = MRSQueue.Get(mdbGuid);
                    List <JobPickupRec> lastScanResults = mrsqueue.LastScanResults;
                    if (!lastScanResults.IsNullOrEmpty())
                    {
                        JobPickupRec jobPickupRec = lastScanResults.Find((JobPickupRec x) => x.RequestGuid == requestGuid);
                        if (jobPickupRec != null)
                        {
                            result = jobPickupRec.GetPickupFailureMessage();
                            break;
                        }
                    }
                }
            }
            return(result);
        }
Ejemplo n.º 8
0
        public void PickupJobs(out string failure)
        {
            string dbName      = null;
            string scanFailure = null;

            failure = null;
            using (new DatabaseSettingsContext(this.MdbGuid, null).Activate())
            {
                CommonUtils.CatchKnownExceptions(delegate
                {
                    DatabaseInformation databaseInformation = MapiUtils.FindServerForMdb(this.MdbGuid, null, null, FindServerFlags.None);
                    dbName = databaseInformation.DatabaseName;
                    if (!databaseInformation.IsOnThisServer)
                    {
                        scanFailure = string.Format("MDB is mounted on remote server {0}", databaseInformation.ServerFqdn);
                        MRSQueue.RemoveQueue(this.MdbGuid);
                        return;
                    }
                    MrsTracer.Service.Debug("Picking up jobs from '{0}' ({1})", new object[]
                    {
                        dbName,
                        this.MdbGuid
                    });
                    using (MapiStore systemMailbox = MapiUtils.GetSystemMailbox(this.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);
                                    this.ProcessJobs(systemMailbox, contentsTable, requestJobNamedPropertySet);
                                }
                            }
                        }
                    }
                    MrsTracer.Service.Debug("Pick up jobs from Mdb: '{0}' - complete.", new object[]
                    {
                        dbName
                    });
                }, delegate(Exception f)
                {
                    if (dbName == null)
                    {
                        dbName = MrsStrings.MissingDatabaseName(this.MdbGuid).ToString();
                    }
                    MrsTracer.Service.Debug("PickupJobs() failed for mdb '{0}'. Error: {1}", new object[]
                    {
                        dbName,
                        CommonUtils.FullExceptionMessage(f)
                    });
                    scanFailure = CommonUtils.FullExceptionMessage(f, true);
                    MRSService.LogEvent(MRSEventLogConstants.Tuple_UnableToProcessJobsInDatabase, new object[]
                    {
                        dbName,
                        CommonUtils.FullExceptionMessage(f)
                    });
                });
            }
            failure = scanFailure;
        }
Ejemplo n.º 9
0
        XElement IDiagnosable.GetDiagnosticInfo(DiagnosableParameters parameters)
        {
            XElement xelement = new XElement(MRSService.DiagnosticsComponentName);
            MRSDiagnosticArgument arguments;

            try
            {
                arguments = new MRSDiagnosticArgument(parameters.Argument);
            }
            catch (DiagnosticArgumentException ex)
            {
                xelement.Add(new XElement("Error", "Encountered exception: " + ex.Message));
                return(xelement);
            }
            xelement.Add(new object[]
            {
                new XElement("ServiceStartTime", MRSService.serviceStartTime),
                new XElement("LastScanDuration", MRSService.lastFullScanDuration),
                new XElement("LastScanTime", MRSService.lastFullScanTime.ToString()),
                new XElement("DurationSinceLastScan", (long)(DateTime.UtcNow - MRSService.lastFullScanTime).TotalMilliseconds),
                new XElement("NextFullScanTime", MRSService.NextFullScanTime.ToString()),
                new XElement("NextLightJobsFullScanTime", MRSService.nextLightJobsFullScanTime.ToString())
            });
            if (arguments.ArgumentCount == 0)
            {
                xelement.Add(new XElement("Help", "Supported arguments: " + arguments.GetSupportedArguments()));
            }
            if (arguments.HasArgument("binaryversions"))
            {
                string assemblyNamePattern = arguments.GetArgument <string>("binaryversions");
                xelement.Add(arguments.RunDiagnosticOperation(() => CommonUtils.GetBinaryVersions(assemblyNamePattern)));
            }
            if (arguments.HasArgument("job"))
            {
                xelement.Add(arguments.RunDiagnosticOperation(() => MailboxSyncerJobs.GetJobsDiagnosticInfo(arguments)));
            }
            if (arguments.HasArgument("reservations"))
            {
                xelement.Add(arguments.RunDiagnosticOperation(() => ReservationManager.GetReservationsDiagnosticInfo(arguments)));
            }
            if (arguments.HasArgument("resources"))
            {
                xelement.Add(arguments.RunDiagnosticOperation(() => ReservationManager.GetResourcesDiagnosticInfo(arguments)));
            }
            if (arguments.HasArgument("queues"))
            {
                xelement.Add(arguments.RunDiagnosticOperation(() => MRSQueue.GetDiagnosticInfo(arguments)));
            }
            if (arguments.HasArgument("workloads"))
            {
                XElement xelement2 = new XElement("Workloads");
                foreach (object obj in Enum.GetValues(typeof(RequestWorkloadType)))
                {
                    RequestWorkloadType requestWorkloadType = (RequestWorkloadType)obj;
                    if (requestWorkloadType != RequestWorkloadType.None)
                    {
                        GenericSettingsContext genericSettingsContext = new GenericSettingsContext("RequestWorkloadType", requestWorkloadType.ToString(), null);
                        using (genericSettingsContext.Activate())
                        {
                            bool config = ConfigBase <MRSConfigSchema> .GetConfig <bool>("IsJobPickupEnabled");

                            xelement2.Add(new XElement("Workload", new object[]
                            {
                                new XAttribute("Name", requestWorkloadType.ToString()),
                                new XAttribute("IsJobPickupEnabled", config)
                            }));
                        }
                    }
                }
                xelement.Add(xelement2);
            }
            return(xelement);
        }