Beispiel #1
0
        public void Initialize(int sessionRunId)
        {
            m_context = RuntimeEntityModel.CreateInstance();

            m_sessionRunId = sessionRunId;
            AnalysisEngine.Initialize(sessionRunId, this);
            MigrationEngine.Initialize(sessionRunId);

            // Create a worker thread and mark it a background thread
            m_thread              = new Thread(Run);
            m_thread.Name         = m_threadName;
            m_thread.IsBackground = true;

            SubscribeListeners();
        }
Beispiel #2
0
        internal SessionWorker(
            Guid sessionId,
            ManualResetEvent sessionEvent,
            AnalysisEngine analysisEngine,
            MigrationEngine migrationEngine,
            LinkEngine linkEngine,
            Guid leftMigrationSourceId,
            Guid rightMigrationSourceId,
            WorkFlowType workFlowType,
            int secondsSyncWaitInterval,
            string threadName)
        {
            SessionId              = sessionId;
            Event                  = sessionEvent;
            AnalysisEngine         = analysisEngine;
            MigrationEngine        = migrationEngine;
            LinkEngine             = linkEngine;
            LeftMigrationSourceid  = leftMigrationSourceId;
            RightMigrationSourceid = rightMigrationSourceId;
            WorkFlowType           = workFlowType;
            m_threadName           = threadName;

            SqlSyncStateManager manager = SqlSyncStateManager.GetInstance();

            m_syncStateManager = manager;
            m_syncCommandQueue = manager;

            m_syncStateMachine = new SyncStateMachine(PipelineState.Default, new SyncStateTransitionAlgorithm(),
                                                      OwnerType.Session, sessionId, m_syncStateManager);
            m_orchPolicy = new SessionOrchestrationPolicy(WorkFlowType, m_syncStateMachine);

            try
            {
                checked
                {
                    MilliSecondsSyncWaitInterval = secondsSyncWaitInterval * 1000;
                }
            }
            catch (OverflowException)
            {
                MilliSecondsSyncWaitInterval = int.MaxValue;
                TraceManager.TraceInformation(
                    "The speicified interval of {0} minutes is too long for the system to handle. The interval is now changed to {1} minutes.",
                    secondsSyncWaitInterval / 60,
                    (int)(MilliSecondsSyncWaitInterval / 1000 / 60));
            }
        }
Beispiel #3
0
 private void CleanupDeltaTable(Guid migrationSourceid)
 {
     AnalysisEngine.ObsoleteDeltaTableEntries(migrationSourceid);
 }
Beispiel #4
0
        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());
                }
            }
        }