private void MarkSessionRunning() { using (RuntimeEntityModel context = RuntimeEntityModel.CreateInstance()) { var sessionQuery = context.RTSessionSet.Where (s => s.SessionUniqueId.Equals(SessionId)); Debug.Assert(sessionQuery.Count() == 1); // we want to keep StartedInStandaloneProcess session status untouched if (sessionQuery.First().State != (int)BusinessModelManager.SessionStateEnum.StartedInStandaloneProcess) { sessionQuery.First().State = (int)BusinessModelManager.SessionStateEnum.Running; } context.TrySaveChanges(); } // If the OrchestrationStatus for the session is PausedByConflict, it should stay in that state // until all conflict for the session are resolved if (m_syncStateMachine.CurrentState != PipelineState.PausedByConflict) { if (m_syncStateMachine.TryTransit(PipelineSyncCommand.START)) { m_syncStateMachine.CommandTransitFinished(PipelineSyncCommand.START); } else { throw new MigrationException(); } } }
private void MarkSessionRunning() { using (RuntimeEntityModel context = RuntimeEntityModel.CreateInstance()) { var sessionQuery = context.RTSessionSet.Where (s => s.SessionUniqueId.Equals(SessionId)); Debug.Assert(sessionQuery.Count() == 1); // we want to keep StartedInStandaloneProcess session status untouched if (sessionQuery.First().State != (int)BusinessModelManager.SessionStateEnum.StartedInStandaloneProcess) { sessionQuery.First().State = (int)BusinessModelManager.SessionStateEnum.Running; } context.TrySaveChanges(); } if (m_syncStateMachine.TryTransit(PipelineSyncCommand.START)) { m_syncStateMachine.CommandTransitFinished(PipelineSyncCommand.START); } else { throw new MigrationException(); } }
/// <summary> /// /// </summary> public void Check() { // transit from intermittent state to stable state switch (m_syncStateMachine.CurrentState) { case PipelineState.Pausing: m_syncStateMachine.CommandTransitFinished(PipelineSyncCommand.PAUSE); break; case PipelineState.PausingForConflict: m_syncStateMachine.CommandTransitFinished(PipelineSyncCommand.PAUSE_FOR_CONFLICT); break; case PipelineState.Starting: m_syncStateMachine.CommandTransitFinished(PipelineSyncCommand.START); break; case PipelineState.Stopping: m_syncStateMachine.CommandTransitFinished(PipelineSyncCommand.STOP); break; case PipelineState.StoppingSingleTrip: m_syncStateMachine.CommandTransitFinished(PipelineSyncCommand.STOP_CURRENT_TRIP); break; default: break; } while (m_syncStateMachine.CurrentState == PipelineState.Paused) { // sleep at "PAUSED" Thread.Sleep(ResumePollingMilliSecs); } switch (m_syncStateMachine.CurrentState) { case PipelineState.Paused: // if this really happens, we simply proceed to next check point break; case PipelineState.PausedByConflict: throw new PauseConflictedSessionException(); case PipelineState.Running: break; case PipelineState.Stopped: throw new StopSessionException(); case PipelineState.StoppedSingleTrip: throw new StopSingleTripException(); default: break; } }