internal void Enqueue(ReplayAction action) { MrsTracer.Provider.Function("ReplayActionsQueue.Enqueue", new object[0]); byte[] itemId = action.ItemId; List <ReplayAction> list; if (!this.optimizeMap.TryGetValue(itemId, out list)) { this.optimizeMap.Add(itemId, new List <ReplayAction> { action }); } else { foreach (ReplayAction replayAction in list) { ActionUpdateGroup actionUpdateGroup; ActionUpdateGroup actionUpdateGroup2; if (!replayAction.Ignored && ReplayActionsQueue.IsActionUpdate(replayAction, out actionUpdateGroup) && ReplayActionsQueue.IsActionUpdate(action, out actionUpdateGroup2) && actionUpdateGroup == actionUpdateGroup2) { MrsTracer.Service.Debug("Action {0} already existed in the batch. Replacing with action: {1}", new object[] { replayAction, action }); replayAction.Ignored = true; } } list.Add(action); } this.queue.Enqueue(action); }
public ReplayActionsQueue GetAndTranslateActions(string replaySyncState, int maxNumberOfActions, MergeSyncContext syncContext, out string retrieveSyncState, out bool moreActions) { MrsTracer.Service.Function("MailboxMerger.GetAndTranslateActions", new object[0]); List <ReplayAction> actions = base.DestMailbox.GetActions(replaySyncState, maxNumberOfActions); moreActions = (actions.Count == maxNumberOfActions); retrieveSyncState = ((actions.Count == 0) ? replaySyncState : actions[actions.Count - 1].Watermark); ReplayActionsQueue replayActionsQueue = new ReplayActionsQueue(actions.Count); foreach (ReplayAction action in actions) { replayActionsQueue.Enqueue(action); } EntryIdMap <List <byte[]> > entryIdMap = new EntryIdMap <List <byte[]> >(); foreach (ReplayAction replayAction in actions) { if (!replayAction.Ignored) { foreach (KeyValuePair <byte[], byte[]> keyValuePair in replayAction.GetMessageEntryIdsToTranslate()) { byte[] key = keyValuePair.Key; byte[] value = keyValuePair.Value; List <byte[]> list; if (!entryIdMap.TryGetValue(key, out list)) { list = new List <byte[]>(); entryIdMap.Add(key, list); } list.Add(value); } } } syncContext.PrefetchSourceMessageIdsFromTargetMessageIds(entryIdMap); foreach (ReplayAction replayAction2 in actions) { if (!replayAction2.Ignored) { replayAction2.TranslateEntryIds(syncContext); } } return(replayActionsQueue); }
public void ReplayActions(ReplayActionsQueue actionsQueue, MergeSyncContext syncContext) { MrsTracer.Service.Function("MailboxMerger.ReplayActions", new object[0]); ReplayAction replayAction; while (actionsQueue.TryQueue(out replayAction)) { if (replayAction.Ignored) { syncContext.NumberOfActionsIgnored++; base.Report.AppendDebug(string.Format("Ignored action: {0}", replayAction)); syncContext.LastActionProcessed = replayAction; } else { List <ReplayActionResult> list = null; try { List <ReplayAction> list2 = new List <ReplayAction>(1); list2.Add(replayAction); list = base.SourceMailbox.ReplayActions(list2); syncContext.NumberOfActionsReplayed++; base.Report.AppendDebug(string.Format("Replayed action: {0}", replayAction)); } catch (MailboxReplicationPermanentException ex) { MrsTracer.Service.Error("Replay the action {0} failed: {1}", new object[] { replayAction, ex }); syncContext.NumberOfActionsIgnored++; base.Report.AppendDebug(string.Format("Permanently failed action: {0}", replayAction)); } syncContext.LastActionProcessed = replayAction; if (list != null) { this.PostReplay(replayAction, list[0]); } } } }
private void EnumerateAndReplayActions(MailboxMerger mbxContext, MergeSyncContext syncContext) { if (mbxContext.ReplaySyncState == null) { mbxContext.ReplaySyncState = new ReplaySyncState(); } string text = mbxContext.ReplaySyncState.ProviderState; bool flag = true; int num = 0; while (flag) { MergeSyncContext mergeSyncContext = (MergeSyncContext)base.MailboxMerger.CreateSyncContext(); string text2; ReplayActionsQueue andTranslateActions = mbxContext.GetAndTranslateActions(text, this.GetActionsPageSize, mergeSyncContext, out text2, out flag); base.Report.Append(MrsStrings.ReportReplayActionsEnumerated(mbxContext.TargetTracingID, andTranslateActions.Count, num)); try { mbxContext.ReplayActions(andTranslateActions, mergeSyncContext); text = text2; syncContext.NumberOfActionsReplayed += mergeSyncContext.NumberOfActionsReplayed; syncContext.NumberOfActionsIgnored += mergeSyncContext.NumberOfActionsIgnored; } catch (MailboxReplicationTransientException) { if (mergeSyncContext.LastActionProcessed != null) { text = mergeSyncContext.LastActionProcessed.Watermark; } } finally { base.Report.Append(MrsStrings.ReportReplayActionsSynced(mbxContext.TargetTracingID, mergeSyncContext.NumberOfActionsReplayed, mergeSyncContext.NumberOfActionsIgnored)); mbxContext.ReplaySyncState.ProviderState = text; mbxContext.SaveReplaySyncState(); } num++; } base.Report.Append(MrsStrings.ReportReplayActionsCompleted(mbxContext.TargetTracingID, syncContext.NumberOfActionsReplayed, syncContext.NumberOfActionsIgnored)); }