Пример #1
0
        internal static bool IsMessageTypeSupported(MapiMessage message, MapiStore store)
        {
            RequestJobNamedPropertySet requestJobNamedPropertySet = RequestJobNamedPropertySet.Get(store);
            PropValue  prop  = message.GetProp(requestJobNamedPropertySet.PropTags[9]);
            MRSJobType value = MapiUtils.GetValue <MRSJobType>(prop, MRSJobType.RequestJobE14R3);

            return(RequestJobXML.IsKnownJobType(value));
        }
Пример #2
0
 public MoveJob(PropValue[] properties, Guid requestQueueGuid)
 {
     this.JobType = MapiUtils.GetValue <MRSJobType>(properties[9], MRSJobType.Unknown);
     if (!RequestJobXML.IsKnownJobType(this.JobType))
     {
         MrsTracer.Service.Debug("Skipping unknown jobType {0}", new object[]
         {
             (int)this.JobType
         });
         return;
     }
     this.RequestGuid         = MapiUtils.GetValue <Guid>(properties[26], Guid.Empty);
     this.ExchangeGuid        = MapiUtils.GetValue <Guid>(properties[5], Guid.Empty);
     this.ArchiveGuid         = MapiUtils.GetValue <Guid>(properties[6], Guid.Empty);
     this.CancelRequest       = MapiUtils.GetValue <bool>(properties[4], false);
     this.MrsServerName       = MapiUtils.GetValue <string>(properties[2], null);
     this.Status              = MapiUtils.GetValue <RequestStatus>(properties[0], RequestStatus.None);
     this.JobState            = MapiUtils.GetValue <JobProcessingState>(properties[1], JobProcessingState.NotReady);
     this.LastUpdateTimeStamp = MapiUtils.GetValue <DateTime>(properties[7], DateTime.MinValue);
     this.Flags = MapiUtils.GetValue <RequestFlags>(properties[10], RequestFlags.None);
     this.SourceDatabaseGuid        = MapiUtils.GetValue <Guid>(properties[11], Guid.Empty);
     this.TargetDatabaseGuid        = MapiUtils.GetValue <Guid>(properties[12], Guid.Empty);
     this.SourceArchiveDatabaseGuid = MapiUtils.GetValue <Guid>(properties[15], Guid.Empty);
     this.TargetArchiveDatabaseGuid = MapiUtils.GetValue <Guid>(properties[16], Guid.Empty);
     this.Priority = MapiUtils.GetValue <int>(properties[17], -1);
     this.DoNotPickUntilTimestamp = MapiUtils.GetValue <DateTime>(properties[13], DateTime.MinValue);
     this.RequestType             = MapiUtils.GetValue <MRSRequestType>(properties[14], MRSRequestType.Move);
     this.MessageID          = MapiUtils.GetValue <byte[]>(properties[27], null);
     this.SourceExchangeGuid = MapiUtils.GetValue <Guid>(properties[18], Guid.Empty);
     this.TargetExchangeGuid = MapiUtils.GetValue <Guid>(properties[19], Guid.Empty);
     this.RehomeRequest      = MapiUtils.GetValue <bool>(properties[20], false);
     this.InternalFlags      = MapiUtils.GetValue <RequestJobInternalFlags>(properties[21], RequestJobInternalFlags.None);
     this.PoisonCount        = MapiUtils.GetValue <int>(properties[23], 0);
     this.FailureType        = MapiUtils.GetValue <string>(properties[24], null);
     this.WorkloadType       = MapiUtils.GetValue <RequestWorkloadType>(properties[25], RequestWorkloadType.None);
     byte[] value = MapiUtils.GetValue <byte[]>(properties[22], null);
     this.PartitionHint             = ((value != null && value.Length > 0) ? TenantPartitionHint.FromPersistablePartitionHint(value) : null);
     this.RequestQueueGuid          = requestQueueGuid;
     this.IsActiveOnThisMRSInstance = MRSService.JobIsActive(this.RequestGuid);
     this.isInteractive             = MoveJob.IsInteractive(this.RequestType, this.WorkloadType);
 }
Пример #3
0
        public JobPickupRec AttemptToPick(MapiStore systemMailbox)
        {
            if (!RequestJobXML.IsKnownRequestType(this.RequestType))
            {
                return(new JobPickupRec(this, JobPickupResult.UnknownJobType, DateTime.MaxValue, MrsStrings.PickupStatusRequestTypeNotSupported(this.RequestType.ToString()), null));
            }
            if (!RequestJobXML.IsKnownJobType(this.JobType))
            {
                return(new JobPickupRec(this, JobPickupResult.UnknownJobType, DateTime.MaxValue, MrsStrings.PickupStatusJobTypeNotSupported(this.JobType.ToString()), null));
            }
            if (this.PoisonCount >= ConfigBase <MRSConfigSchema> .GetConfig <int>("HardPoisonLimit"))
            {
                return(new JobPickupRec(this, JobPickupResult.PoisonedJob, DateTime.MaxValue, MrsStrings.PickupStatusJobPoisoned(this.PoisonCount), null));
            }
            if (this.IsActiveOnThisMRSInstance)
            {
                return(new JobPickupRec(this, JobPickupResult.JobAlreadyActive, DateTime.MaxValue, LocalizedString.Empty, null));
            }
            DateTime utcNow = DateTime.UtcNow;

            if (this.Status == RequestStatus.Completed && (!this.DoNotPickUntilHasElapsed || this.DoNotPickUntilTimestamp == DateTime.MinValue) && !this.RehomeRequest)
            {
                return(new JobPickupRec(this, JobPickupResult.CompletedJobSkipped, (this.DoNotPickUntilTimestamp == DateTime.MinValue) ? DateTime.MaxValue : this.DoNotPickUntilTimestamp, LocalizedString.Empty, null));
            }
            if (this.CancelRequest && !this.DoNotPickUntilHasElapsed)
            {
                return(new JobPickupRec(this, JobPickupResult.PostponeCancel, this.DoNotPickUntilTimestamp, LocalizedString.Empty, null));
            }
            if (!this.isInteractive && !this.IsLightRequest && !this.DoNotPickUntilHasElapsed)
            {
                MrsTracer.Service.Debug("Ignoring MoveJob '{0}' on queue '{1}' having DoNotPickUntilTimestamp of {2}.", new object[]
                {
                    this.RequestGuid,
                    this.RequestQueueGuid,
                    this.DoNotPickUntilTimestamp.ToLocalTime()
                });
                return(new JobPickupRec(this, JobPickupResult.JobIsPostponed, this.DoNotPickUntilTimestamp, LocalizedString.Empty, null));
            }
            if (this.InternalFlags.HasFlag(RequestJobInternalFlags.ExecutedByTransportSync))
            {
                MrsTracer.Service.Debug("Ignoring MoveJob '{0}' since Tranport Sync Owns Execution of the job.", new object[]
                {
                    this.RequestGuid
                });
                return(new JobPickupRec(this, JobPickupResult.JobOwnedByTransportSync, DateTime.MaxValue, LocalizedString.Empty, null));
            }
            JobPickupRec result;

            using (DisposeGuard disposeGuard = default(DisposeGuard))
            {
                using (RequestJobProvider requestJobProvider = new RequestJobProvider(this.RequestQueueGuid, systemMailbox))
                {
                    using (TransactionalRequestJob transactionalRequestJob = (TransactionalRequestJob)requestJobProvider.Read <TransactionalRequestJob>(new RequestJobObjectId(this.RequestGuid, this.RequestQueueGuid, this.MessageID)))
                    {
                        if (transactionalRequestJob == null)
                        {
                            result = new JobPickupRec(this, JobPickupResult.InvalidJob, DateTime.MaxValue, MrsStrings.PickupStatusCorruptJob, null);
                        }
                        else if (!transactionalRequestJob.IsSupported())
                        {
                            result = new JobPickupRec(this, JobPickupResult.UnknownJobType, DateTime.MaxValue, MrsStrings.PickupStatusSubTypeNotSupported(transactionalRequestJob.RequestType.ToString()), null);
                        }
                        else if (transactionalRequestJob.ValidationResult != RequestJobBase.ValidationResultEnum.Valid)
                        {
                            this.ProcessInvalidJob(transactionalRequestJob, requestJobProvider);
                            result = new JobPickupRec(this, JobPickupResult.InvalidJob, DateTime.MaxValue, MrsStrings.PickupStatusInvalidJob(transactionalRequestJob.ValidationResult.ToString(), transactionalRequestJob.ValidationMessage), null);
                        }
                        else if (transactionalRequestJob.Status == RequestStatus.Completed && !transactionalRequestJob.RehomeRequest)
                        {
                            this.CleanupCompletedJob(transactionalRequestJob, requestJobProvider);
                            result = new JobPickupRec(this, JobPickupResult.CompletedJobCleanedUp, DateTime.MaxValue, MrsStrings.PickupStatusCompletedJob, null);
                        }
                        else if (!transactionalRequestJob.ShouldProcessJob())
                        {
                            result = new JobPickupRec(this, JobPickupResult.DisabledJobPickup, DateTime.MaxValue, MrsStrings.PickupStatusDisabled, null);
                        }
                        else
                        {
                            ReservationContext reservationContext = null;
                            if (!this.IsLightRequest && !MoveJob.CacheJobQueues)
                            {
                                reservationContext = new ReservationContext();
                                disposeGuard.Add <ReservationContext>(reservationContext);
                                try
                                {
                                    this.ReserveLocalForestResources(reservationContext, transactionalRequestJob);
                                }
                                catch (LocalizedException ex)
                                {
                                    if (CommonUtils.ExceptionIs(ex, new WellKnownException[]
                                    {
                                        WellKnownException.ResourceReservation
                                    }))
                                    {
                                        return(new JobPickupRec(this, JobPickupResult.ReservationFailure, utcNow + MoveJob.JobPickupRetryInterval, MrsStrings.PickupStatusReservationFailure(CommonUtils.FullExceptionMessage(ex)), ex as ResourceReservationException));
                                    }
                                    throw;
                                }
                            }
                            if (!TestIntegration.Instance.DisableRemoteHostNameBlacklisting && transactionalRequestJob.RequestType == MRSRequestType.Move && (transactionalRequestJob.Flags & RequestFlags.CrossOrg) != RequestFlags.None && (transactionalRequestJob.Flags & RequestFlags.RemoteLegacy) == RequestFlags.None && !string.IsNullOrEmpty(transactionalRequestJob.RemoteHostName))
                            {
                                string   key = transactionalRequestJob.RemoteHostName.ToLowerInvariant();
                                DateTime nextRecommendedPickup;
                                if (MoveJob.RemoteHostsInProxyBackoff.TryGetValue(key, out nextRecommendedPickup))
                                {
                                    return(new JobPickupRec(this, JobPickupResult.ProxyBackoff, nextRecommendedPickup, MrsStrings.PickupStatusProxyBackoff(transactionalRequestJob.RemoteHostName), null));
                                }
                            }
                            MrsTracer.Service.Debug("Attempting to take over MoveJob '{0}' on queue '{1}', priority={2}", new object[]
                            {
                                transactionalRequestJob,
                                this.RequestQueueGuid,
                                transactionalRequestJob.Priority
                            });
                            transactionalRequestJob.RequestJobState = JobProcessingState.InProgress;
                            transactionalRequestJob.MRSServerName   = CommonUtils.LocalComputerName;
                            if (!this.IsLightRequest)
                            {
                                transactionalRequestJob.PoisonCount++;
                                transactionalRequestJob.LastPickupTime = new DateTime?(DateTime.UtcNow);
                            }
                            if (!transactionalRequestJob.Suspend && !transactionalRequestJob.RehomeRequest && transactionalRequestJob.Status != RequestStatus.Suspended && transactionalRequestJob.Status != RequestStatus.AutoSuspended && transactionalRequestJob.Status != RequestStatus.Failed && transactionalRequestJob.Status != RequestStatus.Completed && transactionalRequestJob.Status != RequestStatus.CompletedWithWarning)
                            {
                                transactionalRequestJob.Status = ((reservationContext == null) ? RequestStatus.Queued : RequestStatus.InProgress);
                            }
                            requestJobProvider.Save(transactionalRequestJob);
                            this.Status = transactionalRequestJob.Status;
                            JobPickupRec jobPickupRec;
                            if (this.IsLightRequest)
                            {
                                jobPickupRec = new JobPickupRec(this, JobPickupResult.JobPickedUp, DateTime.MaxValue, MrsStrings.PickupStatusLightJob(transactionalRequestJob.Suspend, transactionalRequestJob.RehomeRequest, transactionalRequestJob.Priority.ToString()), null);
                                MoveJob.PerformLightJobAction(requestJobProvider.SystemMailbox, RequestJobProvider.CreateRequestStatistics(transactionalRequestJob));
                            }
                            else
                            {
                                MailboxSyncerJobs.CreateJob(transactionalRequestJob, reservationContext);
                                jobPickupRec = new JobPickupRec(this, JobPickupResult.JobPickedUp, DateTime.MaxValue, MrsStrings.PickupStatusCreateJob(transactionalRequestJob.SyncStage.ToString(), transactionalRequestJob.CancelRequest, transactionalRequestJob.Priority.ToString()), null);
                            }
                            disposeGuard.Success();
                            result = jobPickupRec;
                        }
                    }
                }
            }
            return(result);
        }