internal void Migrate(Guid targetSideSourceId, SessionOrchestrationPolicy orchPolicy) { try { Debug.Assert(m_serviceContainers.ContainsKey(targetSideSourceId), string.Format(MigrationToolkitResources.UnknownSourceId, targetSideSourceId)); ChangeGroupService changegroupService = (ChangeGroupService)m_serviceContainers[targetSideSourceId].GetService( typeof(ChangeGroupService)); Debug.Assert(changegroupService != null, string.Format("Change group service on {0} is not loaded", targetSideSourceId)); changegroupService.DemoteInProgressActionsToPending(); int pageNumber = 0; IEnumerable <ChangeGroup> changeGroups = null; long?firstConflictedChangeGroupId = null; if (StopMigrationEngineOnBasicConflict) { firstConflictedChangeGroupId = changegroupService.GetFirstConflictedChangeGroup(ChangeStatus.Pending); } do { // NOTE: we do not increment pageNumber here, because the processed ChangeGroups are marked "Complete" and no longer // appear in the table TraceManager.TraceInformation("Loading {0} ChangeGroup(s)", m_pageSize); changeGroups = changegroupService.NextMigrationInstructionTablePage(pageNumber, m_pageSize, false, false); foreach (ChangeGroup nextChangeGroup in changeGroups) { if (firstConflictedChangeGroupId.HasValue && firstConflictedChangeGroupId <= nextChangeGroup.ChangeGroupId) { // we should not process any conflicted change group or the following ones // if StopMigrationEngineOnBasicConflict is the policy return; } //ToDo Session.OnMigratingChangeStarting(args); TraceManager.TraceInformation("Processing ChangeGroup #{0}", nextChangeGroup.ChangeGroupId); ProcessMigrInstructionTableEntry(nextChangeGroup, targetSideSourceId); nextChangeGroup.UpdateStatus(ChangeStatus.InProgress); if (NoActiveMigrationInstructionInChangeGroup(nextChangeGroup)) { nextChangeGroup.Complete(); continue; } ConversionResult result; try { result = m_migrationProviders[targetSideSourceId].ProcessChangeGroup(nextChangeGroup); } catch (MigrationUnresolvedConflictException) { // We have already created an unresolved conflict, just return. return; } catch (Exception e) { ConflictManager manager = m_serviceContainers[targetSideSourceId].GetService(typeof(ConflictManager)) as ConflictManager; ErrorManager.TryHandleException(e, manager); return; } if (!result.ContinueProcessing) { return; } if (!string.IsNullOrEmpty(result.ChangeId)) { FinishChangeGroupMigration(nextChangeGroup, result); InvokePostChangeGroupMigrationAddins(targetSideSourceId, nextChangeGroup); } orchPolicy.Check(); } }while (changeGroups.Count() == m_pageSize); } catch (Microsoft.TeamFoundation.Migration.Toolkit.SessionOrchestrationPolicy.StopSingleTripException) { throw; } catch (Microsoft.TeamFoundation.Migration.Toolkit.SessionOrchestrationPolicy.StopSessionException) { throw; } catch (Exception e) { ConflictManager manager = m_serviceContainers[targetSideSourceId].GetService(typeof(ConflictManager)) as ConflictManager; ErrorManager.TryHandleException(e, manager); } }
private void OneDirectionProcessPipeline( bool isLeftToRight, Guid sourceMigrationSourceId, Guid targetMigrationSourceId, bool contextSyncNeeded, bool bidirection) { try { m_orchPolicy.Check(); AnalysisEngine.SourceMigrationSourceId = sourceMigrationSourceId; AnalysisEngine.InvokePreAnalysisAddins(sourceMigrationSourceId); if (!AnalysisEngine.InvokeProceedToAnalysisOnAnalysisAddins(sourceMigrationSourceId)) { // In case any of the AnalysisAddins perform cleanup in the PostAnalysis method AnalysisEngine.InvokePostAnalysisAddins(sourceMigrationSourceId); return; } TraceManager.TraceInformation("Pipeline flow from {0} to {1}", sourceMigrationSourceId, targetMigrationSourceId); if (contextSyncNeeded) { TraceManager.TraceInformation("Generating context info tables for the migration source {0}", sourceMigrationSourceId); AnalysisEngine.GenerateContextInfoTables(sourceMigrationSourceId); m_orchPolicy.Check(); } TraceManager.TraceInformation("Generating delta tables for the migration source {0}", sourceMigrationSourceId); AnalysisEngine.GenerateDeltaTables(sourceMigrationSourceId); m_orchPolicy.Check(); AnalysisEngine.InvokePostDeltaComputationAddins(sourceMigrationSourceId); TraceManager.TraceInformation("Generating linking delta for the migration source {0}", sourceMigrationSourceId); LinkEngine.GenerateLinkDelta(SessionId, sourceMigrationSourceId); m_orchPolicy.Check(); AnalysisEngine.InvokePostAnalysisAddins(sourceMigrationSourceId); ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// // Above: data collection at source side // // Below: data migration/submission at target side // ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// MigrationEngine.InvokePreMigrationAddins(targetMigrationSourceId); if (contextSyncNeeded) { TraceManager.TraceInformation("Establishing context for the migration source {0}", targetMigrationSourceId); MigrationEngine.EstablishContext(targetMigrationSourceId); m_orchPolicy.Check(); } if (!AnalysisEngine.DisableTargetAnalysis) { TraceManager.TraceInformation("Generating delta tables for the migration source {0}", targetMigrationSourceId); AnalysisEngine.GenerateDeltaTables(targetMigrationSourceId); m_orchPolicy.Check(); } TraceManager.TraceInformation("Generating migration instructions for the migration source {0}", targetMigrationSourceId); AnalysisEngine.GenerateMigrationInstructions(targetMigrationSourceId); m_orchPolicy.Check(); TraceManager.TraceInformation("Post-processing delta table entries from the migration source {0}", targetMigrationSourceId); AnalysisEngine.PostProcessDeltaTableEntries(targetMigrationSourceId, bidirection); m_orchPolicy.Check(); TraceManager.TraceInformation("Migrating to the migration source {0}", targetMigrationSourceId); MigrationEngine.Migrate(targetMigrationSourceId, m_orchPolicy); m_orchPolicy.Check(); MigrationEngine.InvokePostMigrationAddins(targetMigrationSourceId); TraceManager.TraceInformation("Processing linking delta"); LinkEngine.AnalyzeLinkDelta(SessionId, sourceMigrationSourceId, bidirection); m_orchPolicy.Check(); TraceManager.TraceInformation("Migrating links to the migration source {0}", targetMigrationSourceId); LinkEngine.MigrateLinks(SessionId, targetMigrationSourceId); m_orchPolicy.Check(); } finally { // Record a sync point in the database try { RecordSyncPoint(isLeftToRight, sourceMigrationSourceId, targetMigrationSourceId); } catch (Exception ex) { TraceManager.TraceWarning("{0}: Unable to record SyncPoint data due to exception: {1}", m_thread.Name, ex.ToString()); } } }