public void ProcessJobsInBatches(Restriction restriction, bool applyManualSort, SortOrder sort, MapiTable contentsTable, MapiStore systemMbx, Func <MoveJob, bool> stoppingCondition)
        {
            List <MoveJob> allMoveJobs = SystemMailboxJobs.GetAllMoveJobs(restriction, sort, contentsTable, this.MdbGuid, stoppingCondition);

            if (allMoveJobs != null)
            {
                if (applyManualSort)
                {
                    allMoveJobs.Sort();
                }
                MrsTracer.Throttling.Debug("Sorted jobs for Mdb: {0}", new object[]
                {
                    this.MdbGuid
                });
                SystemMailboxJobs.TraceJobs(allMoveJobs);
                using (List <MoveJob> .Enumerator enumerator = allMoveJobs.GetEnumerator())
                {
                    while (enumerator.MoveNext())
                    {
                        MoveJob moveJob = enumerator.Current;
                        try
                        {
                            using (SettingsContextBase.ActivateContext(moveJob))
                            {
                                JobPickupRec pickupResult = null;
                                CommonUtils.CatchKnownExceptions(delegate
                                {
                                    pickupResult = moveJob.AttemptToPick(systemMbx);
                                    this.PerformPickupAccounting(moveJob.Status, pickupResult);
                                }, delegate(Exception failure)
                                {
                                    LocalizedString localizedString = CommonUtils.FullExceptionMessage(failure);
                                    pickupResult = new JobPickupRec(moveJob, JobPickupResult.PickupFailure, DateTime.UtcNow + MoveJob.JobPickupRetryInterval, localizedString, null);
                                    MrsTracer.Service.Error("Unexpected failure occurred trying to pick up MoveJob '{0}' from database '{1}', skipping it. {2}", new object[]
                                    {
                                        moveJob.RequestGuid,
                                        this.MdbGuid,
                                        localizedString
                                    });
                                    MailboxReplicationService.LogEvent(MRSEventLogConstants.Tuple_UnableToProcessRequest, new object[]
                                    {
                                        moveJob.RequestGuid.ToString(),
                                        this.MdbGuid.ToString(),
                                        localizedString
                                    });
                                });
                                this.ProcessPickupResults(pickupResult);
                            }
                        }
                        catch (Exception exception)
                        {
                            BaseJob.PerformCrashingFailureActions(moveJob.IdentifyingGuid, moveJob.RequestGuid, exception, RequestState.None, SyncStage.None);
                            throw;
                        }
                    }
                }
            }
        }
Exemple #2
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);
        }