Beispiel #1
0
        private void CleanupCompletedJob(TransactionalRequestJob requestJob, RequestJobProvider rjProvider)
        {
            DateTime t = requestJob.TimeTracker.GetTimestamp(RequestJobTimestamp.DoNotPickUntil) ?? DateTime.MaxValue;

            if (DateTime.UtcNow < t)
            {
                return;
            }
            MrsTracer.Service.Debug("Cleaning up expired completed job '{0}' on queue '{1}'", new object[]
            {
                requestJob,
                this.RequestQueueGuid
            });
            rjProvider.Delete(requestJob);
            CommonUtils.CatchKnownExceptions(delegate
            {
                ReportData reportData = new ReportData(requestJob.IdentifyingGuid, requestJob.ReportVersion);
                reportData.Delete(rjProvider.SystemMailbox);
            }, null);
            CommonUtils.CatchKnownExceptions(delegate
            {
                rjProvider.DeleteIndexEntries(requestJob);
            }, null);
            requestJob.RemoveAsyncNotification();
            MailboxReplicationService.LogEvent(MRSEventLogConstants.Tuple_RemovedCompletedRequest, new object[]
            {
                requestJob.ToString(),
                this.RequestGuid.ToString(),
                requestJob.WorkItemQueueMdbName
            });
        }
Beispiel #2
0
        private void FinalSync()
        {
            base.RefreshRequestIfNeeded();
            base.CheckServersHealth();
            base.SyncStage = SyncStage.FinalIncrementalSync;
            base.TimeTracker.CurrentState = RequestState.Finalization;
            base.TimeTracker.SetTimestamp(RequestJobTimestamp.FinalSync, new DateTime?(DateTime.UtcNow));
            base.Report.Append(MrsStrings.ReportFinalSyncStarted);
            base.TestIntegration.Barrier("PostponeFinalSync", new Action(base.RefreshRequestIfNeeded));
            MailboxReplicationService.LogEvent(MRSEventLogConstants.Tuple_MoveFinalizationStarted, new object[]
            {
                base.RequestJobIdentity,
                base.MailboxMerger.TargetMailboxGuid
            });
            bool flag;

            base.MailboxMerger.SourceMailbox.SetInTransitStatus(InTransitStatus.MoveSource, out flag);
            this.isSourceSetInTransit = true;
            base.EnumerateAndApplyIncrementalChanges();
            base.SaveState(SaveStateFlags.Regular, null);
            base.CheckBadItemCount(true);
            if (!base.SkipContentVerification)
            {
                base.ScheduleContentVerification();
            }
            base.ScheduleWorkItem(new Action(this.SetMailboxSettings), WorkloadType.Unknown);
        }
 protected override void StartMerge()
 {
     MrsTracer.Service.Debug("WorkItem: StartMerge", new object[0]);
     if (base.MailboxMerger.SyncState != null && base.MailboxMerger.ICSSyncState != null)
     {
         MrsTracer.Service.Debug("Recovering an interrupted merge.", new object[0]);
         base.CheckServersHealth();
         base.MailboxMerger.SourceMailbox.SetMailboxSyncState(base.MailboxMerger.ICSSyncState.ProviderState);
         if (base.SyncStage == SyncStage.IncrementalSync || base.SyncStage == SyncStage.FinalIncrementalSync)
         {
             base.OverallProgress = this.CopyEndPercentage;
             base.ScheduleWorkItem(new Action(this.InitializeIncrementalSync), WorkloadType.Unknown);
             base.Report.Append(MrsStrings.ReportRequestContinued(base.SyncStage.ToString()));
             MailboxReplicationService.LogEvent(MRSEventLogConstants.Tuple_RequestContinued, new object[]
             {
                 base.RequestJobIdentity,
                 base.RequestJobGuid.ToString(),
                 base.SyncStage.ToString()
             });
             return;
         }
     }
     base.ScheduleWorkItem(new Action(this.CatchupFolderHierarchy), WorkloadType.Unknown);
     base.StartMerge();
     base.MailboxMerger.ICSSyncState = new MailboxMapiSyncState();
 }
Beispiel #4
0
 protected void CompleteMerge()
 {
     base.TestIntegration.Barrier("PostponeResumeAccessToMailbox", new Action(base.RefreshRequestIfNeeded));
     base.ReportProgress(true);
     base.TimeTracker.SetTimestamp(RequestJobTimestamp.InitialSeedingCompleted, new DateTime?(DateTime.UtcNow));
     base.SyncStage                = SyncStage.SyncFinished;
     base.OverallProgress          = 100;
     base.TimeTracker.CurrentState = RequestState.Completed;
     CommonUtils.CatchKnownExceptions(delegate
     {
         this.MailboxMerger.ClearSyncState(SyncStateClearReason.MergeComplete);
     }, null);
     CommonUtils.CatchKnownExceptions(delegate
     {
         base.Report.Append(MrsStrings.ReportRequestCompleted);
         MoveHistoryEntryInternal moveHistoryEntryInternal;
         base.CompleteRequest(this.MailboxMerger.IsOlcSync, out moveHistoryEntryInternal);
         RequestJobLog.Write(base.CachedRequestJob, RequestState.InitialSeedingComplete);
     }, delegate(Exception failure)
     {
         LocalizedString localizedString = CommonUtils.FullExceptionMessage(failure);
         MailboxReplicationService.LogEvent(MRSEventLogConstants.Tuple_FailedToUpdateCompletedRequest, new object[]
         {
             base.RequestJobIdentity,
             base.GetRequestKeyGuid().ToString(),
             base.RequestJobStoringMDB.ToString(),
             localizedString
         });
     });
 }
        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;
                        }
                    }
                }
            }
        }
Beispiel #6
0
 private static void PerformLightJobAction(MapiStore systemMailbox, RequestStatisticsBase requestJobStats)
 {
     CommonUtils.CatchKnownExceptions(delegate
     {
         bool flag = false;
         LightJobBase lightJobBase;
         if (QuarantinedJobs.Contains(requestJobStats.IdentifyingGuid))
         {
             lightJobBase = new QuarantineJob(requestJobStats.IdentifyingGuid, requestJobStats.WorkItemQueueMdb.ObjectGuid, systemMailbox, requestJobStats.MessageId);
         }
         else if (requestJobStats.ShouldRehomeRequest)
         {
             lightJobBase = new RehomeJob(requestJobStats.IdentifyingGuid, requestJobStats.RequestQueue, requestJobStats.OptimalRequestQueue, systemMailbox, requestJobStats.MessageId);
         }
         else if (requestJobStats.ShouldClearRehomeRequest)
         {
             lightJobBase = new ClearRehomeJob(requestJobStats.IdentifyingGuid, requestJobStats.WorkItemQueueMdb.ObjectGuid, systemMailbox, requestJobStats.MessageId);
         }
         else if (requestJobStats.ShouldSuspendRequest)
         {
             lightJobBase = new SuspendJob(requestJobStats.IdentifyingGuid, requestJobStats.WorkItemQueueMdb.ObjectGuid, systemMailbox, requestJobStats.MessageId);
         }
         else
         {
             lightJobBase = new ResumeJob(requestJobStats.IdentifyingGuid, requestJobStats.WorkItemQueueMdb.ObjectGuid, systemMailbox, requestJobStats.MessageId);
             flag         = true;
         }
         using (lightJobBase)
         {
             lightJobBase.Run();
             if (flag)
             {
                 MRSService.Tickle(requestJobStats.IdentifyingGuid, requestJobStats.WorkItemQueueMdb.ObjectGuid, MoveRequestNotification.Created);
             }
         }
     }, delegate(Exception failure)
     {
         LocalizedString localizedString = CommonUtils.FullExceptionMessage(failure);
         MrsTracer.Service.Debug("Unexpected failure occurred trying to perform a light pipe action on MoveJob '{0}' from queue '{1}', skipping it. {2}", new object[]
         {
             requestJobStats.RequestGuid,
             requestJobStats.RequestQueue,
             localizedString
         });
         MailboxReplicationService.LogEvent(MRSEventLogConstants.Tuple_UnableToProcessRequest, new object[]
         {
             requestJobStats.RequestGuid.ToString(),
             requestJobStats.WorkItemQueueMdb.ObjectGuid.ToString(),
             localizedString
         });
     });
 }
Beispiel #7
0
 protected virtual void StartMerge()
 {
     MrsTracer.Service.Debug("WorkItem: StartMerge", new object[0]);
     base.CheckServersHealth();
     base.Report.Append(MrsStrings.ReportRequestStarted);
     MailboxReplicationService.LogEvent(MRSEventLogConstants.Tuple_MoveStarted, new object[]
     {
         base.RequestJobIdentity,
         base.RequestJobGuid.ToString(),
         base.CachedRequestJob.SourceMDBName,
         base.CachedRequestJob.TargetMDBName,
         base.CachedRequestJob.Flags.ToString()
     });
     this.MailboxMerger.SyncState    = new PersistedSyncData(base.RequestJobGuid);
     this.MailboxMerger.ICSSyncState = new MailboxMapiSyncState();
     if (base.TimeTracker.GetTimestamp(RequestJobTimestamp.Start) == null)
     {
         base.TimeTracker.SetTimestamp(RequestJobTimestamp.Start, new DateTime?(DateTime.UtcNow));
     }
     if (base.CachedRequestJob.IgnoreRuleLimitErrors)
     {
         MailboxInformation mailboxInformation = this.MailboxMerger.SourceMailbox.GetMailboxInformation();
         if (mailboxInformation != null && mailboxInformation.RulesSize > 32768)
         {
             MailboxInformation mailboxInformation2 = this.MailboxMerger.DestMailbox.GetMailboxInformation();
             if (mailboxInformation2 != null && mailboxInformation2.ServerVersion < Server.E2007MinVersion)
             {
                 base.Report.Append(MrsStrings.ReportRulesWillNotBeCopied);
             }
         }
     }
     base.SyncStage                = SyncStage.CreatingFolderHierarchy;
     base.OverallProgress          = 5;
     base.TimeTracker.CurrentState = RequestState.CreatingFolderHierarchy;
     base.SaveState(SaveStateFlags.Regular, null);
     base.ScheduleWorkItem(new Action(this.AnalyzeFolderHierarchy), WorkloadType.Unknown);
 }
        protected override void CleanupCanceledJob()
        {
            base.CheckDisposed();
            MrsTracer.Service.Debug("Deleting messages and dumpster folder.", new object[0]);
            using (List <MailboxCopierBase> .Enumerator enumerator = this.GetAllCopiers().GetEnumerator())
            {
                while (enumerator.MoveNext())
                {
                    MailboxCopierBase mbxCtx = enumerator.Current;
                    CommonUtils.CatchKnownExceptions(delegate
                    {
                        if (!mbxCtx.IsDestinationConnected)
                        {
                            mbxCtx.ConnectDestinationMailbox(MailboxConnectFlags.None);
                        }
                        SyncStateError syncStateError = mbxCtx.LoadSyncState(this.Report);
                        if (syncStateError != SyncStateError.None && this.CanBeCanceledOrSuspended())
                        {
                            MrsTracer.Service.Debug("Deleting folders at destination mailbox {0}", new object[]
                            {
                                mbxCtx.TargetTracingID
                            });
                            MrsTracer.Service.Debug(MrsStrings.ReportCleanUpFoldersDestination("CleanupCanceledJob"), new object[0]);
                            this.CleanUpFoldersAtDestination();
                        }
                        mbxCtx.ClearSyncState(SyncStateClearReason.JobCanceled);
                        bool flag;
                        mbxCtx.DestMailbox.SetInTransitStatus(InTransitStatus.NotInTransit, out flag);
                    }, delegate(Exception failure)
                    {
                        LocalizedString localizedString = CommonUtils.FullExceptionMessage(failure);
                        this.Report.Append(MrsStrings.ReportDestinationMailboxCleanupFailed2(CommonUtils.GetFailureType(failure)), failure, ReportEntryFlags.Cleanup | ReportEntryFlags.Target);
                        MailboxReplicationService.LogEvent(MRSEventLogConstants.Tuple_DestinationMailboxCleanupFailed, new object[]
                        {
                            this.RequestJobIdentity,
                            mbxCtx.TargetTracingID,
                            this.CachedRequestJob.TargetMDBName,
                            localizedString
                        });
                    });
                }
            }
            MoveHistoryEntryInternal mhei;

            base.RemoveRequest(true, out mhei);
            using (List <MailboxCopierBase> .Enumerator enumerator2 = this.GetAllCopiers().GetEnumerator())
            {
                while (enumerator2.MoveNext())
                {
                    AuxFolderMoveJob.< > c__DisplayClass138 CS$ < > 8__locals3 = new AuxFolderMoveJob.< > c__DisplayClass138();
                    CS$ < > 8__locals3.mbxCtx = enumerator2.Current;
                    bool resetInTransitSuccess = false;
                    CommonUtils.CatchKnownExceptions(delegate
                    {
                        if (!CS$ < > 8__locals3.mbxCtx.IsSourceConnected)
                        {
                            CS$ < > 8__locals3.mbxCtx.ConnectSourceMailbox(MailboxConnectFlags.None);
                        }
                        bool flag;
                        CS$ < > 8__locals3.mbxCtx.SourceMailbox.SetInTransitStatus(InTransitStatus.NotInTransit, out flag);
                        resetInTransitSuccess = true;
                        if (CS$ < > 8__locals3.mbxCtx.IsRoot && mhei != null)
                        {
                            CS$ < > 8__locals3.mbxCtx.SourceMailbox.AddMoveHistoryEntry(mhei, this.GetConfig <int>("MaxMoveHistoryLength"));
                        }
                    }, delegate(Exception failure)
Beispiel #9
0
        private void ProcessInvalidJob(TransactionalRequestJob requestJob, RequestJobProvider rjProvider)
        {
            MrsTracer.Service.Warning("MoveJob '{0}' on queue '{1}' failed validation: {2}.", new object[]
            {
                requestJob,
                this.RequestQueueGuid,
                requestJob.ValidationMessage
            });
            if (requestJob.IdleTime < MoveJob.MaxADReplicationWaitTime)
            {
                MrsTracer.Service.Warning("MoveJob '{0}' on queue '{1}' appears invalid.  Waiting for {2} for AD Replication.  Already have waited {3}...", new object[]
                {
                    requestJob,
                    this.RequestQueueGuid,
                    MoveJob.MaxADReplicationWaitTime,
                    requestJob.IdleTime
                });
                return;
            }
            if (requestJob.ValidationResult == RequestJobBase.ValidationResultEnum.Orphaned)
            {
                MrsTracer.Service.Warning("MoveJob '{0}' on queue '{1}' is orphaned, removing it.", new object[]
                {
                    requestJob,
                    this.RequestQueueGuid
                });
                rjProvider.Delete(requestJob);
                CommonUtils.CatchKnownExceptions(delegate
                {
                    ReportData reportData2 = new ReportData(requestJob.IdentifyingGuid, requestJob.ReportVersion);
                    reportData2.Delete(rjProvider.SystemMailbox);
                }, null);
                requestJob.RemoveAsyncNotification();
                MailboxReplicationService.LogEvent(MRSEventLogConstants.Tuple_RemovedOrphanedMoveRequest, new object[]
                {
                    this.RequestQueueGuid.ToString(),
                    this.RequestGuid.ToString(),
                    requestJob.ToString(),
                    requestJob.ValidationMessage
                });
                return;
            }
            ReportData reportData = new ReportData(requestJob.IdentifyingGuid, requestJob.ReportVersion);

            reportData.Append(MrsStrings.ReportFailingInvalidMoveRequest(requestJob.ValidationMessage));
            reportData.Flush(rjProvider.SystemMailbox);
            requestJob.Status      = RequestStatus.Failed;
            requestJob.FailureCode = new int?(-2147024809);
            requestJob.FailureType = "InvalidRequest";
            requestJob.FailureSide = new ExceptionSide?(ExceptionSide.None);
            requestJob.Message     = MrsStrings.MoveRequestMessageError(MrsStrings.MoveRequestDataIsCorrupt(requestJob.ValidationMessage));
            requestJob.TimeTracker.SetTimestamp(RequestJobTimestamp.Failure, new DateTime?(DateTime.UtcNow));
            requestJob.TimeTracker.CurrentState = RequestState.Failed;
            rjProvider.Save(requestJob);
            requestJob.UpdateAsyncNotification(reportData);
            MailboxReplicationService.LogEvent(MRSEventLogConstants.Tuple_FailedInvalidRequest, new object[]
            {
                this.RequestQueueGuid.ToString(),
                this.RequestGuid.ToString(),
                requestJob.ToString(),
                requestJob.ValidationMessage
            });
        }