public void Commit(Enlistment enlistment)
 {
     log.Debug("Commit {0}, Messages: {1}", TransactionId, Messages.Count);
     if (_oncommit != null) _oncommit(this);
     enlistment.Done();
     TransactionOpen = false;
 }
Beispiel #2
0
 void IEnlistmentNotification.Commit(Enlistment enlistment)
 {
     this.m_Value = new StringBuilder(this.m_TemporaryValue.ToString());
     this.m_TemporaryValue = null;
     this.enlistedTransaction = null;
     enlistment.Done();
 }
 /// <summary>
 /// Performs necessary commit actions, clearing the current <see cref="TransactionContext"/>
 /// </summary>
 public void Commit(Enlistment enlistment)
 {
     BeforeCommit();
     DoCommit();
     TransactionContext.Clear();
     enlistment.Done();
 }
Beispiel #4
0
 public void Rollback(Enlistment enlistment)
 {
     container.Rollback();
     container.Ext().Refresh(oldItem, int.MaxValue);
     oldItem = null;
     container = null;
 }
Beispiel #5
0
 /// <summary>
 /// Make the transacted changes permanent.
 /// </summary>
 void IEnlistmentNotification.Commit(Enlistment enlistment)
 {
     _value = new StringBuilder(_temporaryValue.ToString());
     _temporaryValue = null;
     _enlistedTransaction = null;
     enlistment.Done();
 }
 public void Commit(Enlistment enlistment)
 {
     try
     {
         assertNotDisposed();
         logger.DebugFormat("Committing enlistment with id: {0}", Id);
         queueStorage.Global(actions =>
         {
             actions.RemoveReversalsMoveCompletedMessagesAndFinishSubQueueMove(Id);
             actions.MarkAsReadyToSend(Id);
             actions.DeleteRecoveryInformation(Id);
             actions.Commit();
         });
         enlistment.Done();
         logger.DebugFormat("Commited enlistment with id: {0}", Id);
     }
     catch (Exception e)
     {
         logger.Warn("Failed to commit enlistment " + Id, e);
         throw;
     }
     finally
     {
         onCompelete();
     }
 }
 public void InDoubt(Enlistment enlistment)
 {
     enlistment.Done();
     this.notification.InDoubt();
     Marshal.ReleaseComObject(this.notification);
     this.notification = null;
 }
 public void Rollback(Enlistment enlistment)
 {
     enlistment.Done();
     this.notification.Aborted(0, false, 0, 0);
     Marshal.ReleaseComObject(this.notification);
     this.notification = null;
 }
		public void Commit(Enlistment enlistment)
		{
			if (_transaction != null && !_transaction.IsUpdated)
			{
				_transaction.Commit();
				_transaction = null;

				if (Completed != null)
				{
					Completed(this, new EventArgs());
				}

				if (_connection != null)
				{
					if (!_connection.Options.Pooling && (_connection.OwningConnection == null || _connection.OwningConnection.IsClosed))
					{
						_connection.Disconnect();
					}
				}
				_connection = null;
				_systemTransaction = null;

				// Declare done on the enlistment
				enlistment.Done();
			}
		}
        public void Commit(Enlistment enlistment)
        {
            if (this.transaction != null && !this.transaction.IsUpdated)
            {
                this.transaction.Commit();
                this.transaction = null;

                if (this.Completed != null)
                {
                    this.Completed(this, new EventArgs());
                }

                if (this.connection != null)
                {
                    if (!this.connection.Pooled && (this.connection.OwningConnection == null || this.connection.OwningConnection.IsClosed))
                    {
                        this.connection.Disconnect();
                    }
                }
                this.connection         = null;
                this.systemTransaction  = null;

                // Declare done on the enlistment
                enlistment.Done();
            }
        }
			public void Commit(Enlistment enlistment)
			{
				if (_ThrowIt)
					Assert.Fail("commit is never called if prepare failed");

				enlistment.Done();
			}
 public void InDoubt(Enlistment enlistment)
 {
     log.Warn("transaction in doubt {0}, messages {1}", TransactionId, this.Messages.Count);
     if (_onrollback != null) _onrollback(this);
     enlistment.Done();
     TransactionOpen = false;
 }
		public override void Rollback(Enlistment enlistment)
		{
			if (_ThrowOnRollback)
				throw new Exception("Simulated rollback error");

			base.Rollback(enlistment);
		}
		public override void Commit(Enlistment enlistment)
		{
			if (_ThrowOnCommit)
				throw new Exception("Simulated commit error");

			base.Commit(enlistment);
		}
		void IEnlistmentNotification.Commit(Enlistment enlistment)
		{
			if (_ThrowIt && ++_ErrorCount < 2)
				throw new ApplicationException("simulating resource failure");

			enlistment.Done();
		}
 public void Commit(Enlistment enlistment)
 {
     enlistment.Done();
     this.notification.Committed(false, 0, 0);
     Marshal.ReleaseComObject(this.notification);
     this.notification = null;
 }
 public void Commit(Enlistment enlistment)
 {
     #if DEBUG
     System.Diagnostics.Trace.WriteLine("NuoDbTransaction::IEnlistmentNotification::Commit()");
     #endif
     Commit();
     enlistment.Done();
 }
 public void Rollback(Enlistment enlistment)
 {
     foreach (var x in _rollbackCommands)
     {
         x();
     }
     enlistment.Done();
 }
        public void InDoubt( Enlistment enlistment )
        {
            Status = TxfmStatus.InInDoubt;

            enlistment.Done();

            Status = TxfmStatus.InTransaction;
        }
Beispiel #20
0
 public void InDoubt(Enlistment enlistment)
 {
     lock (_sharedLock)
     {
         if (InDoubtAction != null) InDoubtAction();
     }
     enlistment.Done();
 }
Beispiel #21
0
 public void Rollback(Enlistment enlistment)
 {
     lock (_sharedLock)
     {
         if (RollbackAction != null) RollbackAction();
     }
     enlistment.Done();
 }
 /// <summary>
 /// Responds to the Commit notification.
 /// </summary>
 /// <param name="enlistment">An Enlistment that facilitates communication between the enlisted transaction participant and the transaction manager during the final phase of the transaction.</param>
 public override void Commit(Enlistment enlistment)
 {
     if (enlistment != null)
     {
         // Indicate that the transaction participant has completed its work.
         enlistment.Done();
     }
 }
Beispiel #23
0
 public void Commit(Enlistment enlistment)
 {
     lock (_sharedLock)
     {
         if (CommitAction != null) CommitAction();
     }
     enlistment.Done();
 }
 public virtual void InDoubt(Enlistment enlistment)
 {
     Trace.WriteIf(Tracing.Is.TraceVerbose, string.Empty);
     if (null != enlistment)
     {
         enlistment.Done();
     }
 }
 public void Commit(Enlistment enlistment)
 {
     foreach (var x in _commands)
     {
         x();
     }
     enlistment.Done();
 }
        public void Commit(Enlistment enlistment)
        {
            if (_model.IsOpen)
            {
                _model.TxCommit();
            }

            enlistment.Done();
        }
        public void Rollback(Enlistment enlistment)
        {
            if (_model.IsOpen)
            {
                _model.TxRollback();
            }

            enlistment.Done();
        }
        void IEnlistmentNotification.Rollback(Enlistment enlistment)
        {
            enlistment.Done();
            Fx.Assert(this.currentTransaction.TransactionInformation.Status == TransactionStatus.Aborted, "Transaction state should be Aborted at this point");
            TransactionException exception = this.GetAbortedOrInDoubtTransactionException();

            Fx.Assert(exception != null, "Need a valid TransactionException at this point");
            this.durableInstance.OnTransactionAbortOrInDoubt(exception);
        }
Beispiel #29
0
        public void InDoubt(Enlistment enlistment)
        {
            AssertEnlisted();

            log.Warn("AmbientTxHack in doubt...");
            DisposeStuff();

            enlistment.Done();
        }
        public override void Commit(Enlistment enlistment)
        {
            foreach (var action in Actions)
            {
                action.Invoke();
            }

            base.Commit(enlistment);
        }
 internal DurableInternalEnlistment(Enlistment enlistment, Guid resourceManagerIdentifier, InternalTransaction transaction, IEnlistmentNotification twoPhaseNotifications, ISinglePhaseNotification singlePhaseNotifications, Transaction atomicTransaction) : base(enlistment, transaction, twoPhaseNotifications, singlePhaseNotifications, atomicTransaction)
 {
     this.resourceManagerIdentifier = resourceManagerIdentifier;
 }
Beispiel #32
0
        public static Enlistment Reenlist(
            Guid resourceManagerIdentifier,
            byte[] recoveryInformation,
            IEnlistmentNotification enlistmentNotification)
        {
            if (resourceManagerIdentifier == Guid.Empty)
            {
                throw new ArgumentException(SR.BadResourceManagerId, nameof(resourceManagerIdentifier));
            }

            if (null == recoveryInformation)
            {
                throw new ArgumentNullException(nameof(recoveryInformation));
            }

            if (null == enlistmentNotification)
            {
                throw new ArgumentNullException(nameof(enlistmentNotification));
            }

            TransactionsEtwProvider etwLog = TransactionsEtwProvider.Log;

            if (etwLog.IsEnabled())
            {
                etwLog.MethodEnter(TraceSourceType.TraceSourceBase, "TransactionManager.Reenlist");
                etwLog.TransactionManagerReenlist(resourceManagerIdentifier);
            }

            // Put the recovery information into a stream.
            MemoryStream stream = new MemoryStream(recoveryInformation);
            int          recoveryInformationVersion = 0;
            string       nodeName = null;

            byte[] resourceManagerRecoveryInformation = null;

            try
            {
                BinaryReader reader = new BinaryReader(stream);
                recoveryInformationVersion = reader.ReadInt32();

                if (recoveryInformationVersion == TransactionManager.RecoveryInformationVersion1)
                {
                    nodeName = reader.ReadString();

                    resourceManagerRecoveryInformation = reader.ReadBytes(recoveryInformation.Length - checked ((int)stream.Position));
                }
                else
                {
                    if (etwLog.IsEnabled())
                    {
                        etwLog.TransactionExceptionTrace(TraceSourceType.TraceSourceBase, TransactionExceptionType.UnrecognizedRecoveryInformation, nameof(recoveryInformation), string.Empty);
                    }

                    throw new ArgumentException(SR.UnrecognizedRecoveryInformation, nameof(recoveryInformation));
                }
            }
            catch (EndOfStreamException e)
            {
                if (etwLog.IsEnabled())
                {
                    etwLog.TransactionExceptionTrace(TraceSourceType.TraceSourceBase, TransactionExceptionType.UnrecognizedRecoveryInformation, nameof(recoveryInformation), e.ToString());
                }
                throw new ArgumentException(SR.UnrecognizedRecoveryInformation, nameof(recoveryInformation), e);
            }
            catch (FormatException e)
            {
                if (etwLog.IsEnabled())
                {
                    etwLog.TransactionExceptionTrace(TraceSourceType.TraceSourceBase, TransactionExceptionType.UnrecognizedRecoveryInformation, nameof(recoveryInformation), e.ToString());
                }
                throw new ArgumentException(SR.UnrecognizedRecoveryInformation, nameof(recoveryInformation), e);
            }
            finally
            {
                stream.Dispose();
            }

            DistributedTransactionManager transactionManager = CheckTransactionManager(nodeName);

            // Now ask the Transaction Manager to reenlist.
            object     syncRoot    = new object();
            Enlistment returnValue = new Enlistment(enlistmentNotification, syncRoot);

            EnlistmentState.EnlistmentStatePromoted.EnterState(returnValue.InternalEnlistment);

            returnValue.InternalEnlistment.PromotedEnlistment =
                transactionManager.ReenlistTransaction(
                    resourceManagerIdentifier,
                    resourceManagerRecoveryInformation,
                    (RecoveringInternalEnlistment)returnValue.InternalEnlistment
                    );

            if (etwLog.IsEnabled())
            {
                etwLog.MethodExit(TraceSourceType.TraceSourceBase, "TransactionManager.Reenlist");
            }

            return(returnValue);
        }
Beispiel #33
0
 protected DurableInternalEnlistment(Enlistment enlistment, IEnlistmentNotification twoPhaseNotifications) :
     base(enlistment, twoPhaseNotifications)
 {
 }
Beispiel #34
0
 internal RecoveringInternalEnlistment(Enlistment enlistment, IEnlistmentNotification twoPhaseNotifications, object syncRoot) :
     base(enlistment, twoPhaseNotifications)
 {
     _syncRoot = syncRoot;
 }
Beispiel #35
0
        static public Enlistment Reenlist(
            Guid resourceManagerIdentifier,
            byte[] recoveryInformation,
            IEnlistmentNotification enlistmentNotification
            )
        {
            if (resourceManagerIdentifier == Guid.Empty)
            {
                throw new ArgumentException(SR.GetString(SR.BadResourceManagerId), "resourceManagerIdentifier");
            }

            if (null == recoveryInformation)
            {
                throw new ArgumentNullException("recoveryInformation");
            }

            if (null == enlistmentNotification)
            {
                throw new ArgumentNullException("enlistmentNotification");
            }

            if (!TransactionManager._platformValidated)
            {
                TransactionManager.ValidatePlatform();
            }

            if (DiagnosticTrace.Verbose)
            {
                MethodEnteredTraceRecord.Trace(SR.GetString(SR.TraceSourceBase),
                                               "TransactionManager.Reenlist"
                                               );
            }

            if (DiagnosticTrace.Information)
            {
                ReenlistTraceRecord.Trace(SR.GetString(SR.TraceSourceBase),
                                          resourceManagerIdentifier
                                          );
            }

            // Put the recovery information into a stream.
            MemoryStream stream = new MemoryStream(recoveryInformation);
            int          recoveryInformationVersion = 0;
            string       nodeName = null;

            byte[] resourceManagerRecoveryInformation = null;

            try
            {
                BinaryReader reader = new BinaryReader(stream);
                recoveryInformationVersion = reader.ReadInt32();

                if (recoveryInformationVersion == TransactionManager.recoveryInformationVersion1)
                {
                    nodeName = reader.ReadString();

                    resourceManagerRecoveryInformation = reader.ReadBytes(recoveryInformation.Length - checked ((int)stream.Position));
                }
                else
                {
                    if (DiagnosticTrace.Error)
                    {
                        TransactionExceptionTraceRecord.Trace(SR.GetString(SR.TraceSourceBase),
                                                              SR.GetString(SR.UnrecognizedRecoveryInformation)
                                                              );
                    }
                    throw new ArgumentException(SR.GetString(SR.UnrecognizedRecoveryInformation), "recoveryInformation");
                }
            }
            catch (System.IO.EndOfStreamException e)
            {
                if (DiagnosticTrace.Error)
                {
                    TransactionExceptionTraceRecord.Trace(SR.GetString(SR.TraceSourceBase),
                                                          SR.GetString(SR.UnrecognizedRecoveryInformation)
                                                          );
                }
                throw new ArgumentException(SR.GetString(SR.UnrecognizedRecoveryInformation), "recoveryInformation", e);
            }
            catch (System.FormatException e)
            {
                if (DiagnosticTrace.Error)
                {
                    TransactionExceptionTraceRecord.Trace(SR.GetString(SR.TraceSourceBase),
                                                          SR.GetString(SR.UnrecognizedRecoveryInformation)
                                                          );
                }
                throw new ArgumentException(SR.GetString(SR.UnrecognizedRecoveryInformation), "recoveryInformation", e);
            }
            finally
            {
                stream.Close();
            }

            Oletx.OletxTransactionManager transactionManager = CheckTransactionManager(nodeName);

            // Now ask the Transaction Manager to reenlist.
            object     syncRoot    = new object();
            Enlistment returnValue = new Enlistment(enlistmentNotification, syncRoot);

            EnlistmentState._EnlistmentStatePromoted.EnterState(returnValue.InternalEnlistment);

            returnValue.InternalEnlistment.PromotedEnlistment =
                transactionManager.ReenlistTransaction(
                    resourceManagerIdentifier,
                    resourceManagerRecoveryInformation,
                    (RecoveringInternalEnlistment)returnValue.InternalEnlistment
                    );

            if (DiagnosticTrace.Verbose)
            {
                MethodExitedTraceRecord.Trace(SR.GetString(SR.TraceSourceBase),
                                              "TransactionManager.Reenlist"
                                              );
            }

            return(returnValue);
        }