コード例 #1
0
 public void Commit(Enlistment enlistment)
 {
     log.Debug("Commit {0}, Messages: {1}", TransactionId, Messages.Count);
     if (_oncommit != null) _oncommit(this);
     enlistment.Done();
     TransactionOpen = false;
 }
コード例 #2
0
ファイル: TransactedString.cs プロジェクト: nickchal/pash
 void IEnlistmentNotification.Commit(Enlistment enlistment)
 {
     this.m_Value = new StringBuilder(this.m_TemporaryValue.ToString());
     this.m_TemporaryValue = null;
     this.enlistedTransaction = null;
     enlistment.Done();
 }
コード例 #3
0
 /// <summary>
 /// Performs necessary commit actions, clearing the current <see cref="TransactionContext"/>
 /// </summary>
 public void Commit(Enlistment enlistment)
 {
     BeforeCommit();
     DoCommit();
     TransactionContext.Clear();
     enlistment.Done();
 }
コード例 #4
0
ファイル: Db4oEnlist.cs プロジェクト: JoeyCyril/BoC
 public void Rollback(Enlistment enlistment)
 {
     container.Rollback();
     container.Ext().Refresh(oldItem, int.MaxValue);
     oldItem = null;
     container = null;
 }
コード例 #5
0
ファイル: TransactedString.cs プロジェクト: 40a/PowerShell
 /// <summary>
 /// Make the transacted changes permanent.
 /// </summary>
 void IEnlistmentNotification.Commit(Enlistment enlistment)
 {
     _value = new StringBuilder(_temporaryValue.ToString());
     _temporaryValue = null;
     _enlistedTransaction = null;
     enlistment.Done();
 }
コード例 #6
0
 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();
     }
 }
コード例 #7
0
 public void InDoubt(Enlistment enlistment)
 {
     enlistment.Done();
     this.notification.InDoubt();
     Marshal.ReleaseComObject(this.notification);
     this.notification = null;
 }
コード例 #8
0
 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();
            }
        }
コード例 #11
0
			public void Commit(Enlistment enlistment)
			{
				if (_ThrowIt)
					Assert.Fail("commit is never called if prepare failed");

				enlistment.Done();
			}
コード例 #12
0
 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;
 }
コード例 #13
0
		public override void Rollback(Enlistment enlistment)
		{
			if (_ThrowOnRollback)
				throw new Exception("Simulated rollback error");

			base.Rollback(enlistment);
		}
コード例 #14
0
		public override void Commit(Enlistment enlistment)
		{
			if (_ThrowOnCommit)
				throw new Exception("Simulated commit error");

			base.Commit(enlistment);
		}
コード例 #15
0
		void IEnlistmentNotification.Commit(Enlistment enlistment)
		{
			if (_ThrowIt && ++_ErrorCount < 2)
				throw new ApplicationException("simulating resource failure");

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

            enlistment.Done();

            Status = TxfmStatus.InTransaction;
        }
コード例 #20
0
 public void InDoubt(Enlistment enlistment)
 {
     lock (_sharedLock)
     {
         if (InDoubtAction != null) InDoubtAction();
     }
     enlistment.Done();
 }
コード例 #21
0
 public void Rollback(Enlistment enlistment)
 {
     lock (_sharedLock)
     {
         if (RollbackAction != null) RollbackAction();
     }
     enlistment.Done();
 }
コード例 #22
0
 /// <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();
     }
 }
コード例 #23
0
 public void Commit(Enlistment enlistment)
 {
     lock (_sharedLock)
     {
         if (CommitAction != null) CommitAction();
     }
     enlistment.Done();
 }
コード例 #24
0
 public virtual void InDoubt(Enlistment enlistment)
 {
     Trace.WriteIf(Tracing.Is.TraceVerbose, string.Empty);
     if (null != enlistment)
     {
         enlistment.Done();
     }
 }
コード例 #25
0
 public void Commit(Enlistment enlistment)
 {
     foreach (var x in _commands)
     {
         x();
     }
     enlistment.Done();
 }
コード例 #26
0
        public void Commit(Enlistment enlistment)
        {
            if (_model.IsOpen)
            {
                _model.TxCommit();
            }

            enlistment.Done();
        }
コード例 #27
0
        public void Rollback(Enlistment enlistment)
        {
            if (_model.IsOpen)
            {
                _model.TxRollback();
            }

            enlistment.Done();
        }
コード例 #28
0
        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);
        }
コード例 #29
0
ファイル: AmbientTxHack.cs プロジェクト: asgerhallas/Rebus
        public void InDoubt(Enlistment enlistment)
        {
            AssertEnlisted();

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

            enlistment.Done();
        }
コード例 #30
0
        public override void Commit(Enlistment enlistment)
        {
            foreach (var action in Actions)
            {
                action.Invoke();
            }

            base.Commit(enlistment);
        }
コード例 #31
0
 internal DurableInternalEnlistment(Enlistment enlistment, Guid resourceManagerIdentifier, InternalTransaction transaction, IEnlistmentNotification twoPhaseNotifications, ISinglePhaseNotification singlePhaseNotifications, Transaction atomicTransaction) : base(enlistment, transaction, twoPhaseNotifications, singlePhaseNotifications, atomicTransaction)
 {
     this.resourceManagerIdentifier = resourceManagerIdentifier;
 }
コード例 #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);
        }
コード例 #33
0
ファイル: Enlistment.cs プロジェクト: z77ma/runtime
 protected DurableInternalEnlistment(Enlistment enlistment, IEnlistmentNotification twoPhaseNotifications) :
     base(enlistment, twoPhaseNotifications)
 {
 }
コード例 #34
0
ファイル: Enlistment.cs プロジェクト: z77ma/runtime
 internal RecoveringInternalEnlistment(Enlistment enlistment, IEnlistmentNotification twoPhaseNotifications, object syncRoot) :
     base(enlistment, twoPhaseNotifications)
 {
     _syncRoot = syncRoot;
 }
コード例 #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);
        }