public OrganizationSettingsContext(OrganizationId orgId, SettingsContextBase nextContext = null) : base(nextContext) { if (orgId != OrganizationId.ForestWideOrgId) { this.Initialize(OrganizationSettingsContext.OrgCache.Get(orgId)); } }
private void TransmitThread() { MrsTracer.ActivityID = this.traceActivityID; SettingsContextBase.RunOperationInContext(this.configContexts, delegate { for (;;) { CommonUtils.SafeWait(this.eventWakeUpTransmitter, this.mainThread); if (this.quitting) { break; } CommonUtils.CatchKnownExceptions(delegate { AsynchronousTransmitter.AsyncTransmitterWaitForReplyMessage asyncTransmitterWaitForReplyMessage = this.currentMessage as AsynchronousTransmitter.AsyncTransmitterWaitForReplyMessage; if (asyncTransmitterWaitForReplyMessage != null) { this.replyMessage = base.WrappedObject.SendMessageAndWaitForReply(asyncTransmitterWaitForReplyMessage.Request); return; } base.WrappedObject.SendMessage(this.currentMessage); }, delegate(Exception failure) { failure.PreserveExceptionStack(); this.lastFailure = failure; }); this.currentMessage = null; this.eventWakeUpTransmitter.Reset(); this.eventBufferIsAvailableToAccept.Set(); } }); }
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(); } } }
public DatabaseSettingsContext(Guid mdbGuid, SettingsContextBase nextContext = null) : base(mdbGuid, nextContext) { DatabaseLocationInfo databaseLocationInfo = null; try { databaseLocationInfo = ActiveManager.GetCachingActiveManagerInstance().GetServerForDatabase(mdbGuid, GetServerForDatabaseFlags.IgnoreAdSiteBoundary | GetServerForDatabaseFlags.BasicQuery); } catch (ObjectNotFoundException) { } if (databaseLocationInfo != null) { this.databaseName = databaseLocationInfo.DatabaseName; this.databaseVersion = databaseLocationInfo.AdminDisplayVersion; this.serverName = databaseLocationInfo.ServerFqdn; this.serverVersion = new ServerVersion(databaseLocationInfo.ServerVersion); this.serverGuid = new Guid?(databaseLocationInfo.ServerGuid); return; } this.databaseName = string.Empty; this.databaseVersion = new ServerVersion(0); this.serverName = string.Empty; this.serverVersion = new ServerVersion(0); this.serverGuid = new Guid?(Guid.Empty); }
private void RunExportThread(Action threadOperation) { this.traceActivityID = MrsTracer.ActivityID; this.configContexts = SettingsContextBase.GetCurrentContexts(); this.exportThread = new Thread(new ParameterizedThreadStart(this.ExportThread)); this.exportThread.Name = "DataExport Thread"; this.exportThread.Start(threadOperation); }
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; } } } } }
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"); } } }
private void SpinUpTransmitterThread() { if (this.transmitThread != null) { return; } this.traceActivityID = MrsTracer.ActivityID; this.configContexts = SettingsContextBase.GetCurrentContexts(); Thread thread = new Thread(new ThreadStart(this.TransmitThread)); thread.Name = "MRS transmitter thread"; thread.Start(); this.transmitThread = thread; }
private void ExportThread(object context) { MrsTracer.ActivityID = this.traceActivityID; Action exportOperation = (Action)context; CommonUtils.CatchKnownExceptions(delegate { this.WaitForTheNextCall(); SettingsContextBase.RunOperationInContext(this.configContexts, exportOperation); this.exportFailure = null; }, delegate(Exception ex) { ex.PreserveExceptionStack(); this.exportFailure = ex; }); this.result = DataExport.DataExportResult.Done; this.eventDataAvailable.Set(); }
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); }
public ServerSettingsContext(string serverName, string serverRole, string processName, SettingsContextBase nextContext = null) : base(nextContext) { this.serverName = serverName; this.serverRole = serverRole; this.processName = processName; this.DateCreated = DateTime.UtcNow; }
public ServerSettingsContext(Server server, string processName, SettingsContextBase nextContext = null) : base(nextContext) { this.Initialize(server, processName); this.DateCreated = DateTime.UtcNow; }
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); }
public OrganizationSettingsContext(ExchangeConfigurationUnit org, SettingsContextBase nextContext = null) : base(nextContext) { this.Initialize(org); }
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); }