Esempio n. 1
0
 public void Dispatch(SynchronizationEvent e)
 {
     if (this.history != null)
     {
         this.history.AddEvent(e.ToString());
     }
     e.Execute(this);
 }
Esempio n. 2
0
 private void TryToAbortTransaction(SynchronizationEvent e, Microsoft.Transactions.Wsat.Protocol.TransactionEnlistment enlistment)
 {
     if (this is InactiveState)
     {
         enlistment.StateMachine.ChangeState(enlistment.StateMachine.AbortedState);
     }
     else if (this is ActiveState)
     {
         this.state.TransactionManagerSend.Rollback(enlistment);
         enlistment.StateMachine.ChangeState(enlistment.StateMachine.AbortedState);
     }
 }
Esempio n. 3
0
 private void Execute()
 {
     if (DebugTrace.Verbose)
     {
         DebugTrace.TxTrace(TraceLevel.Verbose, this.stateMachine.Enlistment.EnlistmentId, "Now processing events on {0}", this.stateMachine.GetType().Name);
     }
     while (true)
     {
         SynchronizationEvent e = this.queue.Peek();
         if (e == null)
         {
             DiagnosticUtility.FailFast("Peek returned null synchronization event");
         }
         try
         {
             if (DebugTrace.Verbose)
             {
                 DebugTrace.TxTrace(TraceLevel.Verbose, this.stateMachine.Enlistment.EnlistmentId, "Dispatching {0} event to {1} in {2}", e.GetType().Name, this.stateMachine.GetType().Name, this.stateMachine.State.GetType().Name);
             }
             using (Activity.CreateActivity(this.stateMachine.Enlistment.EnlistmentId))
             {
                 this.stateMachine.Dispatch(e);
             }
             if (DebugTrace.Verbose)
             {
                 DebugTrace.TxTrace(TraceLevel.Verbose, this.stateMachine.Enlistment.EnlistmentId, "Dispatched {0} event to {1} in {2}", e.GetType().Name, this.stateMachine.GetType().Name, this.stateMachine.State.GetType().Name);
             }
         }
         catch (Exception exception)
         {
             DebugTrace.TxTrace(TraceLevel.Error, this.stateMachine.Enlistment.EnlistmentId, "REALLY BAD ERROR: Unhandled exception caught by synchronization manager: {0}", exception);
             UnhandledStateMachineExceptionRecord.TraceAndLog(this.stateMachine.Enlistment.EnlistmentId, (this.stateMachine.Enlistment.Enlistment != null) ? this.stateMachine.Enlistment.Enlistment.RemoteTransactionId : string.Empty, this.stateMachine.ToString(), this.stateMachine.State.ToString(), this.stateMachine.History, exception);
             DiagnosticUtility.FailFast(string.Format(CultureInfo.InvariantCulture, "Failfasting due to unhandled exception: {0}\r\n\r\n{1}", new object[] { exception.Message, exception }));
         }
         lock (this.mutex)
         {
             this.queue.Dequeue();
             if (this.queue.Count == 0)
             {
                 break;
             }
         }
         if (DebugTrace.Verbose)
         {
             DebugTrace.TxTrace(TraceLevel.Verbose, this.stateMachine.Enlistment.EnlistmentId, "Continuing to process events on {0}", this.stateMachine.GetType().Name);
         }
     }
     if (DebugTrace.Verbose)
     {
         DebugTrace.TxTrace(TraceLevel.Verbose, this.stateMachine.Enlistment.EnlistmentId, "Stopped processing events on {0}", this.stateMachine.GetType().Name);
     }
 }
 public void Enqueue(SynchronizationEvent newEvent)
 {
     bool flag;
     if (newEvent == null)
     {
         DiagnosticUtility.FailFast("The synchronization manager cannot enqueue a null event");
     }
     if (DiagnosticUtility.ShouldUseActivity)
     {
         DiagnosticUtility.DiagnosticTrace.TraceTransfer(this.stateMachine.Enlistment.EnlistmentId);
     }
     lock (this.mutex)
     {
         this.queue.Enqueue(newEvent);
         flag = this.queue.Count == 1;
     }
     if (flag)
     {
         this.Execute();
     }
 }
Esempio n. 5
0
 public void TraceInvalidEvent(SynchronizationEvent e, bool fatal)
 {
     if (DebugTrace.Error)
     {
         if (this.history != null)
         {
             DebugTrace.TxTrace(TraceLevel.Error, e.Enlistment.EnlistmentId, "The {0} was not expected by the {1} state. The state machine history history follows:\n\n{2}", e, this.current, this.history.ToString());
         }
         else
         {
             DebugTrace.TxTrace(TraceLevel.Error, e.Enlistment.EnlistmentId, "The {0} was not expected by the {1} state", e, this.current);
         }
     }
     if (fatal)
     {
         FatalUnexpectedStateMachineEventRecord.TraceAndLog(this.enlistment.EnlistmentId, this.enlistment.Enlistment.RemoteTransactionId, this.ToString(), this.current.ToString(), this.history, e.ToString(), null);
     }
     else
     {
         NonFatalUnexpectedStateMachineEventRecord.TraceAndLog(this.enlistment.EnlistmentId, this.enlistment.Enlistment.RemoteTransactionId, this.ToString(), this.current.ToString(), this.history, e.ToString(), null);
     }
 }
Esempio n. 6
0
        public void Enqueue(SynchronizationEvent newEvent)
        {
            bool flag;

            if (newEvent == null)
            {
                DiagnosticUtility.FailFast("The synchronization manager cannot enqueue a null event");
            }
            if (DiagnosticUtility.ShouldUseActivity)
            {
                DiagnosticUtility.DiagnosticTrace.TraceTransfer(this.stateMachine.Enlistment.EnlistmentId);
            }
            lock (this.mutex)
            {
                this.queue.Enqueue(newEvent);
                flag = this.queue.Count == 1;
            }
            if (flag)
            {
                this.Execute();
            }
        }
 protected void TraceInvalidEvent(SynchronizationEvent e, bool fatal)
 {
     e.StateMachine.TraceInvalidEvent(e, fatal);
 }
 private void InvalidTransactionManagerEvent(SynchronizationEvent e)
 {
     this.TraceInvalidEvent(e, true);
     this.InvalidEventFailfast(e);
 }
Esempio n. 9
0
 private void InvalidParticipantFaultEvent(SynchronizationEvent e, ParticipantEnlistment participant)
 {
     this.TraceInvalidEvent(e, false);
     this.TryToAbortTransaction(e, participant);
 }
Esempio n. 10
0
 private void InvalidInternalEvent(SynchronizationEvent e)
 {
     this.TraceInvalidEvent(e, true);
     this.InvalidEventFailfast(e);
 }
 private void TraceGenericEvent(SynchronizationEvent e)
 {
     DebugTrace.TxTrace(TraceLevel.Info, e.Enlistment.EnlistmentId, "{0}", e);
 }
 private void InvalidParticipantFaultEvent(SynchronizationEvent e, ParticipantEnlistment participant)
 {
     this.TraceInvalidEvent(e, false);
     this.TryToAbortTransaction(e, participant);
 }
 private void InvalidFaultEvent(SynchronizationEvent e, Microsoft.Transactions.Wsat.Protocol.TransactionEnlistment enlistment, MessageFault fault)
 {
     this.TraceInvalidEvent(e, false);
     this.TryToAbortTransaction(e, enlistment);
 }
Esempio n. 14
0
 protected void TraceInvalidEvent(SynchronizationEvent e, bool fatal)
 {
     e.StateMachine.TraceInvalidEvent(e, fatal);
 }
Esempio n. 15
0
 private void InvalidTransactionManagerEvent(SynchronizationEvent e)
 {
     this.TraceInvalidEvent(e, true);
     this.InvalidEventFailfast(e);
 }
 public void TraceInvalidEvent(SynchronizationEvent e, bool fatal)
 {
     if (DebugTrace.Error)
     {
         if (this.history != null)
         {
             DebugTrace.TxTrace(TraceLevel.Error, e.Enlistment.EnlistmentId, "The {0} was not expected by the {1} state. The state machine history history follows:\n\n{2}", e, this.current, this.history.ToString());
         }
         else
         {
             DebugTrace.TxTrace(TraceLevel.Error, e.Enlistment.EnlistmentId, "The {0} was not expected by the {1} state", e, this.current);
         }
     }
     if (fatal)
     {
         FatalUnexpectedStateMachineEventRecord.TraceAndLog(this.enlistment.EnlistmentId, this.enlistment.Enlistment.RemoteTransactionId, this.ToString(), this.current.ToString(), this.history, e.ToString(), null);
     }
     else
     {
         NonFatalUnexpectedStateMachineEventRecord.TraceAndLog(this.enlistment.EnlistmentId, this.enlistment.Enlistment.RemoteTransactionId, this.ToString(), this.current.ToString(), this.history, e.ToString(), null);
     }
 }
 public void Enqueue(SynchronizationEvent e)
 {
     this.synchronization.Enqueue(e);
 }
 public void Dispatch(SynchronizationEvent e)
 {
     if (this.history != null)
     {
         this.history.AddEvent(e.ToString());
     }
     e.Execute(this);
 }
Esempio n. 19
0
 public void Enqueue(SynchronizationEvent e)
 {
     this.synchronization.Enqueue(e);
 }
 private void TryToAbortTransaction(SynchronizationEvent e, Microsoft.Transactions.Wsat.Protocol.TransactionEnlistment enlistment)
 {
     if (this is InactiveState)
     {
         enlistment.StateMachine.ChangeState(enlistment.StateMachine.AbortedState);
     }
     else if (this is ActiveState)
     {
         this.state.TransactionManagerSend.Rollback(enlistment);
         enlistment.StateMachine.ChangeState(enlistment.StateMachine.AbortedState);
     }
 }
 private void InvalidEventFailfast(SynchronizationEvent e)
 {
     DiagnosticUtility.FailFast(string.Format(CultureInfo.InvariantCulture, "Failfasting due to unexpected event {0} for state {1}", new object[] { e, this }));
 }
 private void TraceFault(MessageFault fault, SynchronizationEvent e)
 {
     DebugTrace.TxTrace(TraceLevel.Info, e.Enlistment.EnlistmentId, "{0} {1}: {2}", e, Library.GetFaultCodeName(fault), Library.GetFaultCodeReason(fault));
 }
 private void InvalidInternalEvent(SynchronizationEvent e)
 {
     this.TraceInvalidEvent(e, true);
     this.InvalidEventFailfast(e);
 }
Esempio n. 24
0
 private void InvalidEventFailfast(SynchronizationEvent e)
 {
     DiagnosticUtility.FailFast(string.Format(CultureInfo.InvariantCulture, "Failfasting due to unexpected event {0} for state {1}", new object[] { e, this }));
 }
Esempio n. 25
0
 private void InvalidFaultEvent(SynchronizationEvent e, Microsoft.Transactions.Wsat.Protocol.TransactionEnlistment enlistment, MessageFault fault)
 {
     this.TraceInvalidEvent(e, false);
     this.TryToAbortTransaction(e, enlistment);
 }
 private void TraceTmResponse(SynchronizationEvent e, Status status)
 {
     DebugTrace.TxTrace(TraceLevel.Info, e.Enlistment.EnlistmentId, "{0} {1}", e, status);
 }