CreateTransactionCompletedException() статический приватный Метод

static private CreateTransactionCompletedException ( Guid distributedTxId ) : Exception
distributedTxId Guid
Результат Exception
 public void Complete()
 {
     if (DiagnosticTrace.Verbose)
     {
         MethodEnteredTraceRecord.Trace(System.Transactions.SR.GetString("TraceSourceLtm"), "DependentTransaction.Complete");
     }
     lock (base.internalTransaction)
     {
         if (base.Disposed)
         {
             throw new ObjectDisposedException("Transaction");
         }
         if (base.complete)
         {
             throw TransactionException.CreateTransactionCompletedException(System.Transactions.SR.GetString("TraceSourceLtm"));
         }
         base.complete = true;
         if (this.blocking)
         {
             base.internalTransaction.State.CompleteBlockingClone(base.internalTransaction);
         }
         else
         {
             base.internalTransaction.State.CompleteAbortingClone(base.internalTransaction);
         }
     }
     if (DiagnosticTrace.Information)
     {
         DependentCloneCompleteTraceRecord.Trace(System.Transactions.SR.GetString("TraceSourceLtm"), base.TransactionTraceId);
     }
     if (DiagnosticTrace.Verbose)
     {
         MethodExitedTraceRecord.Trace(System.Transactions.SR.GetString("TraceSourceLtm"), "DependentTransaction.Complete");
     }
 }
 public Enlistment EnlistVolatile(ISinglePhaseNotification singlePhaseNotification, EnlistmentOptions enlistmentOptions)
 {
     if (DiagnosticTrace.Verbose)
     {
         MethodEnteredTraceRecord.Trace(System.Transactions.SR.GetString("TraceSourceLtm"), "Transaction.EnlistVolatile( ISinglePhaseNotification )");
     }
     if (this.Disposed)
     {
         throw new ObjectDisposedException("Transaction");
     }
     if (singlePhaseNotification == null)
     {
         throw new ArgumentNullException("singlePhaseNotification");
     }
     if ((enlistmentOptions != EnlistmentOptions.None) && (enlistmentOptions != EnlistmentOptions.EnlistDuringPrepareRequired))
     {
         throw new ArgumentOutOfRangeException("enlistmentOptions");
     }
     if (this.complete)
     {
         throw TransactionException.CreateTransactionCompletedException(System.Transactions.SR.GetString("TraceSourceLtm"));
     }
     lock (this.internalTransaction)
     {
         Enlistment enlistment2 = this.internalTransaction.State.EnlistVolatile(this.internalTransaction, singlePhaseNotification, enlistmentOptions, this);
         if (DiagnosticTrace.Verbose)
         {
             MethodExitedTraceRecord.Trace(System.Transactions.SR.GetString("TraceSourceLtm"), "Transaction.EnlistVolatile( ISinglePhaseNotification )");
         }
         return(enlistment2);
     }
 }
 void ISerializable.GetObjectData(SerializationInfo serializationInfo, StreamingContext context)
 {
     if (DiagnosticTrace.Verbose)
     {
         MethodEnteredTraceRecord.Trace(System.Transactions.SR.GetString("TraceSourceLtm"), "ISerializable.GetObjectData");
     }
     if (this.Disposed)
     {
         throw new ObjectDisposedException("Transaction");
     }
     if (serializationInfo == null)
     {
         throw new ArgumentNullException("serializationInfo");
     }
     if (this.complete)
     {
         throw TransactionException.CreateTransactionCompletedException(System.Transactions.SR.GetString("TraceSourceLtm"));
     }
     lock (this.internalTransaction)
     {
         this.internalTransaction.State.GetObjectData(this.internalTransaction, serializationInfo, context);
     }
     if (DiagnosticTrace.Information)
     {
         TransactionSerializedTraceRecord.Trace(System.Transactions.SR.GetString("TraceSourceLtm"), this.TransactionTraceId);
     }
     if (DiagnosticTrace.Verbose)
     {
         MethodExitedTraceRecord.Trace(System.Transactions.SR.GetString("TraceSourceLtm"), "ISerializable.GetObjectData");
     }
 }
        public DependentTransaction DependentClone(DependentCloneOption cloneOption)
        {
            if (DiagnosticTrace.Verbose)
            {
                MethodEnteredTraceRecord.Trace(System.Transactions.SR.GetString("TraceSourceLtm"), "Transaction.DependentClone");
            }
            if ((cloneOption != DependentCloneOption.BlockCommitUntilComplete) && (cloneOption != DependentCloneOption.RollbackIfNotComplete))
            {
                throw new ArgumentOutOfRangeException("cloneOption");
            }
            if (this.Disposed)
            {
                throw new ObjectDisposedException("Transaction");
            }
            if (this.complete)
            {
                throw TransactionException.CreateTransactionCompletedException(System.Transactions.SR.GetString("TraceSourceLtm"));
            }
            DependentTransaction transaction = new DependentTransaction(this.isoLevel, this.internalTransaction, cloneOption == DependentCloneOption.BlockCommitUntilComplete);

            if (DiagnosticTrace.Information)
            {
                DependentCloneCreatedTraceRecord.Trace(System.Transactions.SR.GetString("TraceSourceLtm"), transaction.TransactionTraceId, cloneOption);
            }
            if (DiagnosticTrace.Verbose)
            {
                MethodExitedTraceRecord.Trace(System.Transactions.SR.GetString("TraceSourceLtm"), "Transaction.DependentClone");
            }
            return(transaction);
        }
        public bool EnlistPromotableSinglePhase(IPromotableSinglePhaseNotification promotableSinglePhaseNotification)
        {
            if (DiagnosticTrace.Verbose)
            {
                MethodEnteredTraceRecord.Trace(System.Transactions.SR.GetString("TraceSourceLtm"), "Transaction.EnlistPromotableSinglePhase");
            }
            if (this.Disposed)
            {
                throw new ObjectDisposedException("Transaction");
            }
            if (promotableSinglePhaseNotification == null)
            {
                throw new ArgumentNullException("promotableSinglePhaseNotification");
            }
            if (this.complete)
            {
                throw TransactionException.CreateTransactionCompletedException(System.Transactions.SR.GetString("TraceSourceLtm"));
            }
            bool flag = false;

            lock (this.internalTransaction)
            {
                flag = this.internalTransaction.State.EnlistPromotableSinglePhase(this.internalTransaction, promotableSinglePhaseNotification, this);
            }
            if (DiagnosticTrace.Verbose)
            {
                MethodExitedTraceRecord.Trace(System.Transactions.SR.GetString("TraceSourceLtm"), "Transaction.EnlistPromotableSinglePhase");
            }
            return(flag);
        }
Пример #6
0
        public IAsyncResult BeginCommit(AsyncCallback?asyncCallback, object?asyncState)
        {
            TransactionsEtwProvider etwLog = TransactionsEtwProvider.Log;

            if (etwLog.IsEnabled())
            {
                etwLog.MethodEnter(TraceSourceType.TraceSourceLtm, this);
                etwLog.TransactionCommit(this, "CommittableTransaction");
            }

            ObjectDisposedException.ThrowIf(Disposed, this);

            lock (_internalTransaction)
            {
                if (_complete)
                {
                    throw TransactionException.CreateTransactionCompletedException(DistributedTxId);
                }

                Debug.Assert(_internalTransaction.State != null);
                // this.complete will get set to true when the transaction enters a state that is
                // beyond Phase0.
                _internalTransaction.State.BeginCommit(_internalTransaction, true, asyncCallback, asyncState);
            }

            if (etwLog.IsEnabled())
            {
                etwLog.MethodExit(TraceSourceType.TraceSourceLtm, this);
            }

            return(this);
        }
Пример #7
0
        internal static OletxTransaction ConvertToOletxTransaction(
            Transaction transaction
            )
        {
            if (null == transaction)
            {
                throw new ArgumentNullException("transaction");
            }

            if (transaction.Disposed)
            {
                throw new ObjectDisposedException("Transaction");
            }

            if (transaction.complete)
            {
                throw TransactionException.CreateTransactionCompletedException(SR.GetString(SR.TraceSourceLtm), transaction.DistributedTxId);
            }

            OletxTransaction oletxTx = transaction.Promote();

            System.Diagnostics.Debug.Assert(oletxTx != null, "transaction.Promote returned null instead of throwing.");

            return(oletxTx);
        }
Пример #8
0
        public IAsyncResult BeginCommit(AsyncCallback asyncCallback, object asyncState)
        {
            if (DiagnosticTrace.Verbose)
            {
                MethodEnteredTraceRecord.Trace(SR.TraceSourceLtm, "CommittableTransaction.BeginCommit");
                TransactionCommitCalledTraceRecord.Trace(SR.TraceSourceLtm, TransactionTraceId);
            }

            if (Disposed)
            {
                throw new ObjectDisposedException(nameof(CommittableTransaction));
            }

            lock (_internalTransaction)
            {
                if (_complete)
                {
                    throw TransactionException.CreateTransactionCompletedException(SR.TraceSourceLtm, DistributedTxId);
                }

                // this.complete will get set to true when the transaction enters a state that is
                // beyond Phase0.
                _internalTransaction.State.BeginCommit(_internalTransaction, true, asyncCallback, asyncState);
            }

            if (DiagnosticTrace.Verbose)
            {
                MethodExitedTraceRecord.Trace(SR.TraceSourceLtm, "CommittableTransaction.BeginCommit");
            }

            return(this);
        }
Пример #9
0
        // Create a clone of the transaction that forwards requests to this object.
        //
        public Transaction Clone()
        {
            if (DiagnosticTrace.Verbose)
            {
                MethodEnteredTraceRecord.Trace(SR.TraceSourceLtm, "Transaction.Clone");
            }

            if (Disposed)
            {
                throw new ObjectDisposedException(nameof(Transaction));
            }

            if (_complete)
            {
                throw TransactionException.CreateTransactionCompletedException(SR.TraceSourceLtm, DistributedTxId);
            }

            Transaction clone = InternalClone();

            if (DiagnosticTrace.Verbose)
            {
                MethodExitedTraceRecord.Trace(SR.TraceSourceLtm, "Transaction.Clone");
            }
            return(clone);
        }
Пример #10
0
        // Create a clone of the transaction that forwards requests to this object.
        //
        public Transaction Clone()
        {
            TransactionsEtwProvider etwLog = TransactionsEtwProvider.Log;

            if (etwLog.IsEnabled())
            {
                etwLog.MethodEnter(TraceSourceType.TraceSourceLtm, this);
            }

            if (Disposed)
            {
                throw new ObjectDisposedException(nameof(Transaction));
            }

            if (_complete)
            {
                throw TransactionException.CreateTransactionCompletedException(DistributedTxId);
            }

            Transaction clone = InternalClone();

            if (etwLog.IsEnabled())
            {
                etwLog.MethodExit(TraceSourceType.TraceSourceLtm, this);
            }
            return(clone);
        }
Пример #11
0
 public void Commit()
 {
     if (DiagnosticTrace.Verbose)
     {
         MethodEnteredTraceRecord.Trace(System.Transactions.SR.GetString("TraceSourceLtm"), "CommittableTransaction.Commit");
         TransactionCommitCalledTraceRecord.Trace(System.Transactions.SR.GetString("TraceSourceLtm"), base.TransactionTraceId);
     }
     if (base.Disposed)
     {
         throw new ObjectDisposedException("Transaction");
     }
     lock (base.internalTransaction)
     {
         if (base.complete)
         {
             throw TransactionException.CreateTransactionCompletedException(System.Transactions.SR.GetString("TraceSourceLtm"));
         }
         base.internalTransaction.State.BeginCommit(base.internalTransaction, false, null, null);
         while (!base.internalTransaction.State.IsCompleted(base.internalTransaction) && Monitor.Wait(base.internalTransaction))
         {
         }
         base.internalTransaction.State.EndCommit(base.internalTransaction);
     }
     if (DiagnosticTrace.Verbose)
     {
         MethodExitedTraceRecord.Trace(System.Transactions.SR.GetString("TraceSourceLtm"), "CommittableTransaction.Commit");
     }
 }
Пример #12
0
 public IAsyncResult BeginCommit(AsyncCallback asyncCallback, object asyncState)
 {
     if (DiagnosticTrace.Verbose)
     {
         MethodEnteredTraceRecord.Trace(System.Transactions.SR.GetString("TraceSourceLtm"), "CommittableTransaction.BeginCommit");
         TransactionCommitCalledTraceRecord.Trace(System.Transactions.SR.GetString("TraceSourceLtm"), base.TransactionTraceId);
     }
     if (base.Disposed)
     {
         throw new ObjectDisposedException("Transaction");
     }
     lock (base.internalTransaction)
     {
         if (base.complete)
         {
             throw TransactionException.CreateTransactionCompletedException(System.Transactions.SR.GetString("TraceSourceLtm"));
         }
         base.internalTransaction.State.BeginCommit(base.internalTransaction, true, asyncCallback, asyncState);
     }
     if (DiagnosticTrace.Verbose)
     {
         MethodExitedTraceRecord.Trace(System.Transactions.SR.GetString("TraceSourceLtm"), "CommittableTransaction.BeginCommit");
     }
     return(this);
 }
Пример #13
0
        internal static DistributedTransaction ConvertToDistributedTransaction(Transaction transaction)
        {
            if (null == transaction)
            {
                throw new ArgumentNullException(nameof(transaction));
            }

            if (transaction.Disposed)
            {
                throw new ObjectDisposedException(nameof(Transaction));
            }

            if (transaction._complete)
            {
                throw TransactionException.CreateTransactionCompletedException(transaction.DistributedTxId);
            }

            DistributedTransaction distributedTx = transaction.Promote();

            if (distributedTx == null)
            {
                throw DistributedTransaction.NotSupported();
            }
            return(distributedTx);
        }
Пример #14
0
        // Create a dependent clone of the transaction that forwards requests to this object.
        //
        public DependentTransaction DependentClone(
            DependentCloneOption cloneOption
            )
        {
            TransactionsEtwProvider etwLog = TransactionsEtwProvider.Log;

            if (etwLog.IsEnabled())
            {
                etwLog.MethodEnter(TraceSourceType.TraceSourceLtm, this);
            }

            if (cloneOption != DependentCloneOption.BlockCommitUntilComplete &&
                cloneOption != DependentCloneOption.RollbackIfNotComplete)
            {
                throw new ArgumentOutOfRangeException(nameof(cloneOption));
            }

            ObjectDisposedException.ThrowIf(Disposed, this);

            if (_complete)
            {
                throw TransactionException.CreateTransactionCompletedException(DistributedTxId);
            }

            DependentTransaction clone = new DependentTransaction(
                _isoLevel, _internalTransaction, cloneOption == DependentCloneOption.BlockCommitUntilComplete);

            if (etwLog.IsEnabled())
            {
                etwLog.TransactionCloneCreate(clone, "DependentTransaction");
                etwLog.MethodExit(TraceSourceType.TraceSourceLtm, this);
            }
            return(clone);
        }
Пример #15
0
        public Enlistment PromoteAndEnlistDurable(Guid resourceManagerIdentifier,
                                                  IPromotableSinglePhaseNotification promotableNotification,
                                                  ISinglePhaseNotification enlistmentNotification,
                                                  EnlistmentOptions enlistmentOptions)
        {
            TransactionsEtwProvider etwLog = TransactionsEtwProvider.Log;

            if (etwLog.IsEnabled())
            {
                etwLog.MethodEnter(TraceSourceType.TraceSourceDistributed, this);
            }

            if (Disposed)
            {
                throw new ObjectDisposedException(nameof(Transaction));
            }

            if (resourceManagerIdentifier == Guid.Empty)
            {
                throw new ArgumentException(SR.BadResourceManagerId, nameof(resourceManagerIdentifier));
            }

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

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

            if (enlistmentOptions != EnlistmentOptions.None && enlistmentOptions != EnlistmentOptions.EnlistDuringPrepareRequired)
            {
                throw new ArgumentOutOfRangeException(nameof(enlistmentOptions));
            }

            if (_complete)
            {
                throw TransactionException.CreateTransactionCompletedException(DistributedTxId);
            }

            lock (_internalTransaction)
            {
                Debug.Assert(_internalTransaction.State != null);
                Enlistment enlistment = _internalTransaction.State.PromoteAndEnlistDurable(_internalTransaction,
                                                                                           resourceManagerIdentifier, promotableNotification, enlistmentNotification, enlistmentOptions, this);

                if (etwLog.IsEnabled())
                {
                    etwLog.MethodExit(TraceSourceType.TraceSourceDistributed, this);
                }

                return(enlistment);
            }
        }
Пример #16
0
        public Enlistment PromoteAndEnlistDurable(Guid resourceManagerIdentifier,
                                                  IPromotableSinglePhaseNotification promotableNotification,
                                                  ISinglePhaseNotification enlistmentNotification,
                                                  EnlistmentOptions enlistmentOptions)
        {
            if (DiagnosticTrace.Verbose)
            {
                MethodEnteredTraceRecord.Trace(SR.TraceSourceDistributed, "Transaction.PromoteAndEnlistDurable");
            }

            if (Disposed)
            {
                throw new ObjectDisposedException(nameof(Transaction));
            }

            if (resourceManagerIdentifier == Guid.Empty)
            {
                throw new ArgumentException(SR.BadResourceManagerId, nameof(resourceManagerIdentifier));
            }

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

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

            if (enlistmentOptions != EnlistmentOptions.None && enlistmentOptions != EnlistmentOptions.EnlistDuringPrepareRequired)
            {
                throw new ArgumentOutOfRangeException(nameof(enlistmentOptions));
            }

            if (_complete)
            {
                throw TransactionException.CreateTransactionCompletedException(SR.TraceSourceLtm, DistributedTxId);
            }

            lock (_internalTransaction)
            {
                Enlistment enlistment = _internalTransaction.State.PromoteAndEnlistDurable(_internalTransaction,
                                                                                           resourceManagerIdentifier, promotableNotification, enlistmentNotification, enlistmentOptions, this);

                if (DiagnosticTrace.Verbose)
                {
                    MethodExitedTraceRecord.Trace(SR.TraceSourceDistributed, "Transaction.PromoteAndEnlistDurable");
                }
                return(enlistment);
            }
        }
Пример #17
0
 internal static OletxTransaction ConvertToOletxTransaction(Transaction transaction)
 {
     if (null == transaction)
     {
         throw new ArgumentNullException("transaction");
     }
     if (transaction.Disposed)
     {
         throw new ObjectDisposedException("Transaction");
     }
     if (transaction.complete)
     {
         throw TransactionException.CreateTransactionCompletedException(System.Transactions.SR.GetString("TraceSourceLtm"));
     }
     return(transaction.Promote());
 }
Пример #18
0
        // Forward the commit to the state machine to take the appropriate action.
        //
        /// <include file='doc\Transaction.uex' path='docs/doc[@for="Transaction."]/*' />
        public void Commit()
        {
            if (DiagnosticTrace.Verbose)
            {
                MethodEnteredTraceRecord.Trace(SR.GetString(SR.TraceSourceLtm),
                                               "CommittableTransaction.Commit"
                                               );
                TransactionCommitCalledTraceRecord.Trace(SR.GetString(SR.TraceSourceLtm),
                                                         this.TransactionTraceId
                                                         );
            }

            if (Disposed)
            {
                throw new ObjectDisposedException("Transaction");
            }

            lock (this.internalTransaction)
            {
                if (this.complete)
                {
                    throw TransactionException.CreateTransactionCompletedException(SR.GetString(SR.TraceSourceLtm), this.DistributedTxId);
                }

                this.internalTransaction.State.BeginCommit(this.internalTransaction, false, null, null);

                // now that commit has started wait for the monitor on the transaction to know
                // if the transaction is done.
                do
                {
                    if (this.internalTransaction.State.IsCompleted(this.internalTransaction))
                    {
                        break;
                    }
                } while (System.Threading.Monitor.Wait(this.internalTransaction));

                this.internalTransaction.State.EndCommit(this.internalTransaction);
            }

            if (DiagnosticTrace.Verbose)
            {
                MethodExitedTraceRecord.Trace(SR.GetString(SR.TraceSourceLtm),
                                              "CommittableTransaction.Commit"
                                              );
            }
        }
Пример #19
0
        internal static OletxTransaction ConvertToOletxTransaction(Transaction transaction)
        {
            ArgumentNullException.ThrowIfNull(transaction);

            ObjectDisposedException.ThrowIf(transaction.Disposed, transaction);

            if (transaction._complete)
            {
                throw TransactionException.CreateTransactionCompletedException(transaction.DistributedTxId);
            }

            OletxTransaction?oletxTx = transaction.Promote();

            Debug.Assert(oletxTx != null, "transaction.Promote returned null instead of throwing.");

            return(oletxTx);
        }
Пример #20
0
        /// <summary>
        /// Create a promotable single phase enlistment that promotes to a distributed transaction manager other than MSDTC.
        /// </summary>
        /// <param name="promotableSinglePhaseNotification">The object that implements the IPromotableSinglePhaseNotification interface.</param>
        /// <param name="promoterType">
        /// The promoter type Guid that identifies the format of the byte[] that is returned by the ITransactionPromoter.Promote
        /// call that is implemented by the IPromotableSinglePhaseNotificationObject, and thus the promoter of the transaction.
        /// </param>
        /// <returns>
        /// True if the enlistment is successful.
        ///
        /// False if the transaction already has a durable enlistment or promotable single phase enlistment or
        /// if the transaction has already promoted. In this case, the caller will need to enlist in the transaction through other
        /// means.
        ///
        /// If the Transaction.PromoterType matches the promoter type supported by the caller, then the
        /// Transaction.PromotedToken can be retrieved and used to enlist directly with the identified distributed transaction manager.
        ///
        /// How the enlistment is created with the distributed transaction manager identified by the Transaction.PromoterType
        /// is defined by that distributed transaction manager.
        /// </returns>
        public bool EnlistPromotableSinglePhase(IPromotableSinglePhaseNotification promotableSinglePhaseNotification, Guid promoterType)
        {
            TransactionsEtwProvider etwLog = TransactionsEtwProvider.Log;

            if (etwLog.IsEnabled())
            {
                etwLog.MethodEnter(TraceSourceType.TraceSourceLtm, this);
            }

            if (Disposed)
            {
                throw new ObjectDisposedException(nameof(Transaction));
            }

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

            if (promoterType == Guid.Empty)
            {
                throw new ArgumentException(SR.PromoterTypeInvalid, nameof(promoterType));
            }

            if (_complete)
            {
                throw TransactionException.CreateTransactionCompletedException(DistributedTxId);
            }

            bool succeeded = false;

            lock (_internalTransaction)
            {
                Debug.Assert(_internalTransaction.State != null);
                succeeded = _internalTransaction.State.EnlistPromotableSinglePhase(_internalTransaction, promotableSinglePhaseNotification, this, promoterType);
            }

            if (etwLog.IsEnabled())
            {
                etwLog.MethodExit(TraceSourceType.TraceSourceLtm, this);
            }

            return(succeeded);
        }
Пример #21
0
        public void SetDistributedTransactionIdentifier(IPromotableSinglePhaseNotification promotableNotification,
                                                        Guid distributedTransactionIdentifier)
        {
            TransactionsEtwProvider etwLog = TransactionsEtwProvider.Log;

            if (etwLog.IsEnabled())
            {
                etwLog.MethodEnter(TraceSourceType.TraceSourceLtm, this);
            }

            if (Disposed)
            {
                throw new ObjectDisposedException(nameof(Transaction));
            }

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

            if (distributedTransactionIdentifier == Guid.Empty)
            {
                throw new ArgumentException(null, nameof(distributedTransactionIdentifier));
            }

            if (_complete)
            {
                throw TransactionException.CreateTransactionCompletedException(DistributedTxId);
            }

            lock (_internalTransaction)
            {
                Debug.Assert(_internalTransaction.State != null);
                _internalTransaction.State.SetDistributedTransactionId(_internalTransaction,
                                                                       promotableNotification,
                                                                       distributedTransactionIdentifier);

                if (etwLog.IsEnabled())
                {
                    etwLog.MethodExit(TraceSourceType.TraceSourceLtm, this);
                }
                return;
            }
        }
Пример #22
0
        public void SetDistributedTransactionIdentifier(IPromotableSinglePhaseNotification promotableNotification,
                                                        Guid distributedTransactionIdentifier)
        {
            if (DiagnosticTrace.Verbose)
            {
                MethodEnteredTraceRecord.Trace(SR.TraceSourceLtm, "Transaction.SetDistributedTransactionIdentifier");
            }

            if (Disposed)
            {
                throw new ObjectDisposedException(nameof(Transaction));
            }

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

            if (distributedTransactionIdentifier == Guid.Empty)
            {
                throw new ArgumentException(null, nameof(distributedTransactionIdentifier));
            }

            if (_complete)
            {
                throw TransactionException.CreateTransactionCompletedException(SR.TraceSourceLtm, DistributedTxId);
            }

            lock (_internalTransaction)
            {
                _internalTransaction.State.SetDistributedTransactionId(_internalTransaction,
                                                                       promotableNotification,
                                                                       distributedTransactionIdentifier);

                if (DiagnosticTrace.Verbose)
                {
                    MethodExitedTraceRecord.Trace(SR.TraceSourceLtm,
                                                  "Transaction.SetDistributedTransactionIdentifier"
                                                  );
                }
                return;
            }
        }
Пример #23
0
        // Forward the commit to the state machine to take the appropriate action.
        //
        public void Commit()
        {
            TransactionsEtwProvider etwLog = TransactionsEtwProvider.Log;

            if (etwLog.IsEnabled())
            {
                etwLog.MethodEnter(TraceSourceType.TraceSourceLtm, this);
                etwLog.TransactionCommit(this, "CommittableTransaction");
            }

            if (Disposed)
            {
                throw new ObjectDisposedException(nameof(CommittableTransaction));
            }

            lock (_internalTransaction)
            {
                if (_complete)
                {
                    throw TransactionException.CreateTransactionCompletedException(DistributedTxId);
                }

                Debug.Assert(_internalTransaction.State != null);
                _internalTransaction.State.BeginCommit(_internalTransaction, false, null, null);

                // now that commit has started wait for the monitor on the transaction to know
                // if the transaction is done.
                do
                {
                    if (_internalTransaction.State.IsCompleted(_internalTransaction))
                    {
                        break;
                    }
                } while (Monitor.Wait(_internalTransaction));

                _internalTransaction.State.EndCommit(_internalTransaction);
            }

            if (etwLog.IsEnabled())
            {
                etwLog.MethodExit(TraceSourceType.TraceSourceLtm, this);
            }
        }
        internal static OletxTransaction ConvertToOletxTransaction(Transaction transaction)
        {
            ArgumentNullException.ThrowIfNull(transaction);

            ObjectDisposedException.ThrowIf(transaction.Disposed, transaction);

            if (transaction._complete)
            {
                throw TransactionException.CreateTransactionCompletedException(transaction.DistributedTxId);
            }

            OletxTransaction?distributedTx = transaction.Promote();

            if (distributedTx == null)
            {
                throw OletxTransaction.NotSupported();
            }
            return(distributedTx);
        }
Пример #25
0
        // Forward request to the state machine to take the appropriate action.
        //
        public Enlistment EnlistVolatile(ISinglePhaseNotification singlePhaseNotification, EnlistmentOptions enlistmentOptions)
        {
            TransactionsEtwProvider etwLog = TransactionsEtwProvider.Log;

            if (etwLog.IsEnabled())
            {
                etwLog.MethodEnter(TraceSourceType.TraceSourceLtm, this);
            }

            if (Disposed)
            {
                throw new ObjectDisposedException(nameof(Transaction));
            }

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

            if (enlistmentOptions != EnlistmentOptions.None && enlistmentOptions != EnlistmentOptions.EnlistDuringPrepareRequired)
            {
                throw new ArgumentOutOfRangeException(nameof(enlistmentOptions));
            }

            if (_complete)
            {
                throw TransactionException.CreateTransactionCompletedException(DistributedTxId);
            }

            lock (_internalTransaction)
            {
                Debug.Assert(_internalTransaction.State != null);
                Enlistment enlistment = _internalTransaction.State.EnlistVolatile(_internalTransaction,
                                                                                  singlePhaseNotification, enlistmentOptions, this);

                if (etwLog.IsEnabled())
                {
                    etwLog.MethodExit(TraceSourceType.TraceSourceLtm, this);
                }
                return(enlistment);
            }
        }
Пример #26
0
        // Forward request to the state machine to take the appropriate action.
        //
        public Enlistment EnlistVolatile(ISinglePhaseNotification singlePhaseNotification, EnlistmentOptions enlistmentOptions)
        {
            if (DiagnosticTrace.Verbose)
            {
                MethodEnteredTraceRecord.Trace(SR.TraceSourceLtm, "Transaction.EnlistVolatile( ISinglePhaseNotification )");
            }

            if (Disposed)
            {
                throw new ObjectDisposedException(nameof(Transaction));
            }

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

            if (enlistmentOptions != EnlistmentOptions.None && enlistmentOptions != EnlistmentOptions.EnlistDuringPrepareRequired)
            {
                throw new ArgumentOutOfRangeException(nameof(enlistmentOptions));
            }

            if (_complete)
            {
                throw TransactionException.CreateTransactionCompletedException(SR.TraceSourceLtm, DistributedTxId);
            }

            lock (_internalTransaction)
            {
                Enlistment enlistment = _internalTransaction.State.EnlistVolatile(_internalTransaction,
                                                                                  singlePhaseNotification, enlistmentOptions, this);

                if (DiagnosticTrace.Verbose)
                {
                    MethodExitedTraceRecord.Trace(SR.TraceSourceLtm,
                                                  "Transaction.EnlistVolatile( ISinglePhaseNotification )"
                                                  );
                }
                return(enlistment);
            }
        }
Пример #27
0
        /// <summary>
        /// Create a promotable single phase enlistment that promotes to a distributed transaction manager other than MSDTC.
        /// </summary>
        /// <param name="promotableSinglePhaseNotification">The object that implements the IPromotableSinglePhaseNotification interface.</param>
        /// <param name="promoterType">
        /// The promoter type Guid that identifies the format of the byte[] that is returned by the ITransactionPromoter.Promote
        /// call that is implemented by the IPromotableSinglePhaseNotificationObject, and thus the promoter of the transaction.
        /// </param>
        /// <returns>
        /// True if the enlistment is successful.
        ///
        /// False if the transaction already has a durable enlistment or promotable single phase enlistment or
        /// if the transaction has already promoted. In this case, the caller will need to enlist in the transaction through other
        /// means.
        ///
        /// If the Transaction.PromoterType matches the promoter type supported by the caller, then the
        /// Transaction.PromotedToken can be retrieved and used to enlist directly with the identified distributed transaction manager.
        ///
        /// How the enlistment is created with the distributed transaction manager identified by the Transaction.PromoterType
        /// is defined by that distributed transaction manager.
        /// </returns>
        public bool EnlistPromotableSinglePhase(IPromotableSinglePhaseNotification promotableSinglePhaseNotification, Guid promoterType)
        {
            if (DiagnosticTrace.Verbose)
            {
                MethodEnteredTraceRecord.Trace(SR.TraceSourceLtm, "Transaction.EnlistPromotableSinglePhase");
            }

            if (Disposed)
            {
                throw new ObjectDisposedException(nameof(Transaction));
            }

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

            if (promoterType == Guid.Empty)
            {
                throw new ArgumentException(SR.PromoterTypeInvalid, nameof(promoterType));
            }

            if (_complete)
            {
                throw TransactionException.CreateTransactionCompletedException(SR.TraceSourceLtm, DistributedTxId);
            }

            bool succeeded = false;

            lock (_internalTransaction)
            {
                succeeded = _internalTransaction.State.EnlistPromotableSinglePhase(_internalTransaction, promotableSinglePhaseNotification, this, promoterType);
            }

            if (DiagnosticTrace.Verbose)
            {
                MethodExitedTraceRecord.Trace(SR.TraceSourceLtm, "Transaction.EnlistPromotableSinglePhase");
            }

            return(succeeded);
        }
Пример #28
0
        // Forward the commit to the state machine to take the appropriate action.
        //
        public void Commit()
        {
            if (DiagnosticTrace.Verbose)
            {
                MethodEnteredTraceRecord.Trace(SR.TraceSourceLtm, "CommittableTransaction.Commit");
                TransactionCommitCalledTraceRecord.Trace(SR.TraceSourceLtm, TransactionTraceId);
            }

            if (Disposed)
            {
                throw new ObjectDisposedException(nameof(CommittableTransaction));
            }

            lock (_internalTransaction)
            {
                if (_complete)
                {
                    throw TransactionException.CreateTransactionCompletedException(SR.TraceSourceLtm, DistributedTxId);
                }

                _internalTransaction.State.BeginCommit(_internalTransaction, false, null, null);

                // now that commit has started wait for the monitor on the transaction to know
                // if the transaction is done.
                do
                {
                    if (_internalTransaction.State.IsCompleted(_internalTransaction))
                    {
                        break;
                    }
                } while (Monitor.Wait(_internalTransaction));

                _internalTransaction.State.EndCommit(_internalTransaction);
            }

            if (DiagnosticTrace.Verbose)
            {
                MethodExitedTraceRecord.Trace(SR.TraceSourceLtm, "CommittableTransaction.Commit");
            }
        }
Пример #29
0
        public void Complete()
        {
            if (DiagnosticTrace.Verbose)
            {
                MethodEnteredTraceRecord.Trace(SR.TraceSourceLtm, "DependentTransaction.Complete");
            }

            lock (_internalTransaction)
            {
                if (Disposed)
                {
                    throw new ObjectDisposedException(nameof(DependentTransaction));
                }

                if (_complete)
                {
                    throw TransactionException.CreateTransactionCompletedException(SR.TraceSourceLtm, DistributedTxId);
                }

                _complete = true;

                if (_blocking)
                {
                    _internalTransaction.State.CompleteBlockingClone(_internalTransaction);
                }
                else
                {
                    _internalTransaction.State.CompleteAbortingClone(_internalTransaction);
                }
            }

            if (DiagnosticTrace.Information)
            {
                DependentCloneCompleteTraceRecord.Trace(SR.TraceSourceLtm, TransactionTraceId);
            }
            if (DiagnosticTrace.Verbose)
            {
                MethodExitedTraceRecord.Trace(SR.TraceSourceLtm, "DependentTransaction.Complete");
            }
        }
        public void Complete()
        {
            TransactionsEtwProvider etwLog = TransactionsEtwProvider.Log;

            if (etwLog.IsEnabled())
            {
                etwLog.MethodEnter(TraceSourceType.TraceSourceLtm, this);
            }

            lock (_internalTransaction)
            {
                if (Disposed)
                {
                    throw new ObjectDisposedException(nameof(DependentTransaction));
                }

                if (_complete)
                {
                    throw TransactionException.CreateTransactionCompletedException(DistributedTxId);
                }

                _complete = true;

                Debug.Assert(_internalTransaction.State != null);
                if (_blocking)
                {
                    _internalTransaction.State.CompleteBlockingClone(_internalTransaction);
                }
                else
                {
                    _internalTransaction.State.CompleteAbortingClone(_internalTransaction);
                }
            }

            if (etwLog.IsEnabled())
            {
                etwLog.TransactionDependentCloneComplete(this, "DependentTransaction");
                etwLog.MethodExit(TraceSourceType.TraceSourceLtm, this);
            }
        }