public PublicFolderPerformanceLogger(PublicFolderSynchronizerContext syncContext) { ArgumentValidator.ThrowIfNull("syncContext", syncContext); this.syncContext = syncContext; this.transientRetryDelayTracker = new PerformanceDataProvider("TransientRetryDelay"); this.performanceTrackers = new Dictionary <SyncActivity, PublicFolderActivityPerformanceTracker>(30); }
public PublicFolderHierarchyProxyPool(PublicFolderSynchronizerContext syncContext, IHierarchySyncExecutor syncExecutor, IFxProxyPool destinationProxyPool, TransientExceptionHandler transientExceptionHandler) : base(destinationProxyPool, false) { ArgumentValidator.ThrowIfNull("syncContext", syncContext); ArgumentValidator.ThrowIfNull("syncExecutor", syncExecutor); ArgumentValidator.ThrowIfNull("destinationProxyPool", destinationProxyPool); ArgumentValidator.ThrowIfNull("transientExceptionHandler", transientExceptionHandler); this.syncContext = syncContext; this.syncExecutor = syncExecutor; this.destinationMailbox = syncContext.DestinationMailbox; this.transientExceptionHandler = transientExceptionHandler; }
private PublicFolderSynchronizer(PublicFolderSynchronizerContext syncContext, IActivityScope activityScope, Action <Exception> onEndCallback) { this.syncContext = syncContext; this.activityScope = activityScope; this.onEndCallback = onEndCallback; bool isHierarchyReady = syncContext.IsHierarchyReady; this.transientExceptionHandler = new TransientExceptionHandler(PublicFolderSynchronizer.Tracer, isHierarchyReady ? 5 : PublicFolderSynchronizer.FibonacciSequence.Length, new FilterDelegate(null, (UIntPtr)ldftn(IsTransientException)), this.syncContext.CorrelationId, new Action <Exception>(this.ConnectionFailedHandler)); this.maximumAllowedDelay = (isHierarchyReady ? TimeSpan.FromMinutes(2.0) : TimeSpan.FromMinutes(10.0)); this.resourcesToAccess = new ResourceKey[] { ProcessorResourceKey.Local, new MdbReplicationResourceHealthMonitorKey(this.syncContext.ContentMailboxGuid), new MdbResourceHealthMonitorKey(this.syncContext.ContentMailboxGuid) }; }
public static void Begin(OrganizationId organizationId, Guid contentMailboxGuid, bool executeReconcileFolders, Action <Exception> onEndCallback) { ArgumentValidator.ThrowIfNull("organizationId", organizationId); ArgumentValidator.ThrowIfEmpty("contentMailboxGuid", contentMailboxGuid); ArgumentValidator.ThrowIfNull("onEndCallback", onEndCallback); PublicFolderSynchronizer.Tracer.TraceDebug <OrganizationId, Guid, bool>(0L, "PublicFolderSynchronizer.Begin() for organization {0}, mailbox {1}, executeReconcileFolders {2}", organizationId, contentMailboxGuid, executeReconcileFolders); ConfigBase <MRSConfigSchema> .InitializeConfigProvider(new Func <IConfigSchema, IConfigProvider>(ConfigProvider.CreateProvider)); IActivityScope activityScope = ActivityContext.Start(null, ActivityType.System); activityScope.Component = "PublicFolderSynchronizer"; try { PublicFolderSynchronizerContext publicFolderSynchronizerContext = new PublicFolderSynchronizerContext(organizationId, contentMailboxGuid, false, executeReconcileFolders, activityScope.ActivityId); PublicFolderSynchronizer publicFolderSynchronizer = new PublicFolderSynchronizer(publicFolderSynchronizerContext, activityScope, onEndCallback); PublicFolderSynchronizer.Tracer.TraceDebug <int>(0L, "Created PublicFolderSynchronizer={0}", publicFolderSynchronizer.GetHashCode()); publicFolderSynchronizer.Execute(); } finally { ActivityContext.ClearThreadScope(); } }
protected override bool TryCreateJob(byte[] data, out Job job, out EnqueueResult result) { job = null; if (data == null) { result = new EnqueueResult(EnqueueResultType.InvalidData, "Null arguments"); return(false); } PublicFolderSyncJobRpcInParameters publicFolderSyncJobRpcInParameters = null; try { publicFolderSyncJobRpcInParameters = new PublicFolderSyncJobRpcInParameters(data); if (publicFolderSyncJobRpcInParameters.ContentMailboxGuid == Guid.Empty) { result = new EnqueueResult(EnqueueResultType.InvalidData, "Empty ContentMailboxGuid"); } } catch (SerializationException ex) { result = new EnqueueResult(EnqueueResultType.InvalidData, ex.Message); return(false); } if (publicFolderSyncJobRpcInParameters.SyncAction == PublicFolderSyncJobRpcInParameters.PublicFolderSyncAction.SyncFolder) { LocalizedException lastError = null; try { using (PublicFolderSynchronizerContext publicFolderSynchronizerContext = new PublicFolderSynchronizerContext(publicFolderSyncJobRpcInParameters.OrganizationId, publicFolderSyncJobRpcInParameters.ContentMailboxGuid, true, false, Guid.NewGuid())) { PublicFolderHierarchySyncExecutor publicFolderHierarchySyncExecutor = PublicFolderHierarchySyncExecutor.CreateForSingleFolderSync(publicFolderSynchronizerContext); publicFolderHierarchySyncExecutor.SyncSingleFolder(publicFolderSyncJobRpcInParameters.FolderId); } } catch (PublicFolderSyncPermanentException ex2) { lastError = ex2; } catch (PublicFolderSyncTransientException ex3) { lastError = ex3; } result = new PublicFolderSyncJobEnqueueResult(EnqueueResultType.Successful, new PublicFolderSyncJobState(PublicFolderSyncJobState.Status.None, lastError)); return(false); } if (publicFolderSyncJobRpcInParameters.SyncAction == PublicFolderSyncJobRpcInParameters.PublicFolderSyncAction.StartSyncHierarchy || publicFolderSyncJobRpcInParameters.SyncAction == PublicFolderSyncJobRpcInParameters.PublicFolderSyncAction.StartSyncHierarchyWithFolderReconciliation) { lock (this.lockObject) { if (this.completedPublicFolderSyncJobs.Contains(publicFolderSyncJobRpcInParameters.ContentMailboxGuid)) { this.completedPublicFolderSyncJobs.Remove(publicFolderSyncJobRpcInParameters.ContentMailboxGuid); } if (this.queuedPublicFolderSyncJobs.ContainsKey(publicFolderSyncJobRpcInParameters.ContentMailboxGuid)) { result = new PublicFolderSyncJobEnqueueResult(EnqueueResultType.Successful, new PublicFolderSyncJobState(PublicFolderSyncJobState.Status.Queued, null)); return(false); } result = new PublicFolderSyncJobEnqueueResult(EnqueueResultType.Successful, new PublicFolderSyncJobState(PublicFolderSyncJobState.Status.Queued, null)); job = new PublicFolderSyncJob(this, publicFolderSyncJobRpcInParameters.OrganizationId, publicFolderSyncJobRpcInParameters.ContentMailboxGuid, publicFolderSyncJobRpcInParameters.SyncAction == PublicFolderSyncJobRpcInParameters.PublicFolderSyncAction.StartSyncHierarchyWithFolderReconciliation); this.queuedPublicFolderSyncJobs[publicFolderSyncJobRpcInParameters.ContentMailboxGuid] = (PublicFolderSyncJob)job; return(true); } } if (publicFolderSyncJobRpcInParameters.SyncAction == PublicFolderSyncJobRpcInParameters.PublicFolderSyncAction.QueryStatusSyncHierarchy) { lock (this.lockObject) { PublicFolderSyncJob publicFolderSyncJob = null; if (this.queuedPublicFolderSyncJobs.TryGetValue(publicFolderSyncJobRpcInParameters.ContentMailboxGuid, out publicFolderSyncJob)) { result = new PublicFolderSyncJobEnqueueResult(EnqueueResultType.Successful, new PublicFolderSyncJobState(PublicFolderSyncJobState.Status.Queued, null)); } else if (this.completedPublicFolderSyncJobs.TryGetValue(publicFolderSyncJobRpcInParameters.ContentMailboxGuid, out publicFolderSyncJob)) { result = new PublicFolderSyncJobEnqueueResult(EnqueueResultType.Successful, new PublicFolderSyncJobState(PublicFolderSyncJobState.Status.Completed, (LocalizedException)publicFolderSyncJob.LastError)); } else { result = new PublicFolderSyncJobEnqueueResult(EnqueueResultType.Successful, new PublicFolderSyncJobState(PublicFolderSyncJobState.Status.None, null)); } return(false); } } throw new InvalidOperationException(string.Format("Should not have reached here. SyncAction: {0}", publicFolderSyncJobRpcInParameters.SyncAction)); }