Exemplo n.º 1
0
 private void ProcessTaskExecutionResult(MrsSystemTask systemTask)
 {
     this.executionTime += systemTask.ExecutionTime;
     if (systemTask.Failure == null)
     {
         this.ProcessSucceededTask(systemTask.IgnoreTaskSuccessfulExecutionTime);
         return;
     }
     using (SettingsContextBase.ActivateContext(this as ISettingsContextProvider))
     {
         bool flag;
         this.ProcessFailedTask(systemTask.Failure, out flag);
         if (!flag)
         {
             lock (this.jobLock)
             {
                 MrsTracer.Service.Error("Job({0}) failed.", new object[]
                 {
                     base.GetType().Name
                 });
                 this.state = JobState.Failed;
                 this.jobDoneEvent.Set();
             }
             this.StartDeferredDelayIfApplicable();
         }
     }
 }
Exemplo n.º 2
0
        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;
                        }
                    }
                }
            }
        }
Exemplo n.º 3
0
 private void SetSkipMergingAndInternalFlags(TransactionalRequestJob dataObject)
 {
     RequestTaskHelper.SetSkipMerging(this.SkipMerging, dataObject, new Task.TaskErrorLoggingDelegate(base.WriteError));
     RequestTaskHelper.SetInternalFlags(this.InternalFlags, dataObject, new Task.TaskErrorLoggingDelegate(base.WriteError));
     if (this.SkipMerging == null)
     {
         using (SettingsContextBase.ActivateContext(dataObject))
         {
             dataObject.SkipKnownCorruptions = ConfigBase <MRSConfigSchema> .GetConfig <bool>("SkipKnownCorruptionsDefault");
         }
     }
 }
Exemplo n.º 4
0
        protected override TaskStepResult Execute()
        {
            TaskStepResult result;

            using (SettingsContextBase.ActivateContext(this.Job as ISettingsContextProvider))
            {
                this.Job.GetCurrentActivityScope();
                try
                {
                    this.Run();
                }
                catch (Exception exception)
                {
                    this.Job.PerformCrashingFailureActions(exception);
                    throw;
                }
                result = TaskStepResult.Complete;
            }
            return(result);
        }
        MailboxInformation IMailboxReplicationService.GetMailboxInformation4(string requestJobXml, Guid primaryMailboxGuid, Guid physicalMailboxGuid, byte[] partitionHint, Guid targetMdbGuid, string targetMdbName, string remoteHostName, string remoteOrgName, string remoteDCName, string username, string password, string domain)
        {
            MailboxInformation info = null;

            this.ForwardKnownExceptions(delegate
            {
                TenantPartitionHint partitionHint2 = (partitionHint != null) ? TenantPartitionHint.FromPersistablePartitionHint(partitionHint) : null;
                bool flag = string.IsNullOrEmpty(targetMdbName) && targetMdbGuid == Guid.Empty;
                NetworkCredential networkCredential = (!string.IsNullOrEmpty(username)) ? new NetworkCredential(username, password, domain) : null;
                MailboxType mbxType;
                IMailbox mailbox;
                if (string.IsNullOrEmpty(remoteHostName))
                {
                    if (!string.IsNullOrEmpty(remoteDCName))
                    {
                        if (flag)
                        {
                            mbxType = MailboxType.SourceMailbox;
                            mailbox = new MapiSourceMailbox(LocalMailboxFlags.Move);
                        }
                        else
                        {
                            mbxType = MailboxType.DestMailboxIntraOrg;
                            mailbox = new MapiDestinationMailbox(LocalMailboxFlags.None);
                        }
                        mailbox.ConfigADConnection(remoteDCName, remoteDCName, networkCredential);
                    }
                    else
                    {
                        ProxyServerSettings proxyServerSettings;
                        if (targetMdbGuid != Guid.Empty)
                        {
                            proxyServerSettings = CommonUtils.MapDatabaseToProxyServer(targetMdbGuid);
                        }
                        else
                        {
                            proxyServerSettings = CommonUtils.MapMailboxToProxyServer(new Guid?(physicalMailboxGuid), new Guid?(primaryMailboxGuid), partitionHint);
                        }
                        if (flag)
                        {
                            if (proxyServerSettings.Scenario == ProxyScenarios.LocalMdbAndProxy)
                            {
                                mailbox = new StorageSourceMailbox(LocalMailboxFlags.Move);
                            }
                            else
                            {
                                mailbox = new RemoteSourceMailbox(proxyServerSettings.Fqdn, null, null, ProxyControlFlags.DoNotApplyProxyThrottling, null, false, LocalMailboxFlags.Move);
                            }
                            mbxType = MailboxType.SourceMailbox;
                        }
                        else
                        {
                            if (proxyServerSettings.Scenario == ProxyScenarios.LocalMdbAndProxy)
                            {
                                mailbox = new StorageDestinationMailbox(LocalMailboxFlags.Move);
                            }
                            else
                            {
                                mailbox = new RemoteDestinationMailbox(proxyServerSettings.Fqdn, null, null, ProxyControlFlags.DoNotApplyProxyThrottling, null, false, LocalMailboxFlags.Move);
                            }
                            mbxType = MailboxType.DestMailboxIntraOrg;
                        }
                    }
                }
                else
                {
                    ProxyControlFlags proxyControlFlags = ProxyControlFlags.DoNotApplyProxyThrottling;
                    RequestJobXML requestJobXML         = XMLSerializableBase.Deserialize <RequestJobXML>(requestJobXml, true);
                    if (requestJobXML != null)
                    {
                        using (TransactionalRequestJob transactionalRequestJob = new TransactionalRequestJob(requestJobXML))
                        {
                            transactionalRequestJob.IsFake = true;
                            proxyControlFlags |= transactionalRequestJob.GetProxyControlFlags();
                        }
                    }
                    if (flag)
                    {
                        mailbox = new RemoteSourceMailbox(remoteHostName, remoteOrgName, networkCredential, proxyControlFlags, null, true, LocalMailboxFlags.Move);
                        mbxType = MailboxType.SourceMailbox;
                    }
                    else
                    {
                        mailbox = new RemoteDestinationMailbox(remoteHostName, remoteOrgName, networkCredential, proxyControlFlags, null, true, LocalMailboxFlags.Move);
                        mbxType = MailboxType.DestMailboxCrossOrg;
                    }
                }
                using (mailbox)
                {
                    mailbox.Config(null, primaryMailboxGuid, physicalMailboxGuid, partitionHint2, targetMdbGuid, mbxType, null);
                    if (!string.IsNullOrEmpty(targetMdbName))
                    {
                        mailbox.ConfigMDBByName(targetMdbName);
                    }
                    mailbox.Connect(MailboxConnectFlags.None);
                    using (SettingsContextBase.ActivateContext(mailbox as ISettingsContextProvider))
                    {
                        info          = mailbox.GetMailboxInformation();
                        ADUser aduser = mailbox.GetADUser();
                        if (!this.clientVersion[2] && aduser.HasSeparatedArchive)
                        {
                            throw new UnsupportedClientVersionPermanentException(this.clientVersion.ComputerName, this.clientVersion.ToString(), "ArchiveSeparation");
                        }
                        info.UserDataXML       = ConfigurableObjectXML.Serialize <ADUser>(aduser);
                        info.ServerInformation = mailbox.GetMailboxServerInformation();
                        mailbox.Disconnect();
                    }
                }
            }, null);
            return(info);
        }
Exemplo n.º 6
0
        private MrsSystemTask GetTask(SystemWorkloadBase systemWorkload, ResourceReservationContext context)
        {
            MrsTracer.ActivityID = this.traceActivityID;
            base.CheckDisposed();
            MrsSystemTask result;

            using (SettingsContextBase.ActivateContext(this as ISettingsContextProvider))
            {
                lock (this.jobLock)
                {
                    if (this.IsFinished)
                    {
                        MrsTracer.Service.Debug("Job({0}) is finished.", new object[]
                        {
                            base.GetType().Name
                        });
                        this.state = JobState.Finished;
                        this.jobDoneEvent.Set();
                        result = null;
                    }
                    else
                    {
                        WorkItem workItem = null;
                        bool     flag2    = true;
                        foreach (WorkItem workItem2 in this.workItemQueue.GetCandidateWorkItems())
                        {
                            if (workItem2.ScheduledRunTime <= ExDateTime.UtcNow || CommonUtils.ServiceIsStopping)
                            {
                                flag2 = false;
                                if (this.GetWorkloadType(workItem2.WorkloadType) == systemWorkload.WorkloadType)
                                {
                                    workItem = workItem2;
                                    break;
                                }
                            }
                        }
                        if (workItem == null)
                        {
                            if (flag2)
                            {
                                this.state = JobState.Waiting;
                            }
                            result = null;
                        }
                        else
                        {
                            this.RevertToPreviousUnthrottledState();
                            IEnumerable <ResourceKey> enumerable = this.ResourceDependencies;
                            if (enumerable == null)
                            {
                                enumerable = Array <ResourceKey> .Empty;
                            }
                            ResourceKey         resource    = null;
                            ResourceReservation reservation = this.GetReservation(workItem, systemWorkload, context, enumerable, out resource);
                            if (reservation != null)
                            {
                                if (reservation.DelayFactor > 0.0)
                                {
                                    this.MoveToThrottledState(resource, true);
                                }
                                this.TraceWorkItem(workItem);
                                this.workItemQueue.Remove(workItem);
                                result = new MrsSystemTask(this, workItem.Callback, systemWorkload, reservation, workItem is JobCheck);
                            }
                            else
                            {
                                this.MoveToThrottledState(resource, false);
                                result = null;
                            }
                        }
                    }
                }
            }
            return(result);
        }