public void TestInitialize() { target = new TransactionEnlistmentHelper(); ensureTransaction = true; options = EnlistmentOptions.None; enlistmentNotification = MockRepository.GenerateMock<IEnlistmentNotification>(); enlistmentNotification.Expect( en => en.Prepare( null ) ) .IgnoreArguments() .WhenCalled( a => { PreparingEnlistment e = a.Arguments.GetValue( 0 ) as PreparingEnlistment; e.Prepared(); } ) .Repeat.Once(); enlistmentNotification.Expect( en => en.Commit( null ) ) .IgnoreArguments() .WhenCalled( a => { Enlistment e = a.Arguments.GetValue( 0 ) as Enlistment; e.Done(); } ) .Repeat.Once(); }
public override void OnEvent(MsgEnlistTransactionEvent e) { CoordinatorEnlistment coordinator = e.Coordinator; if (!base.state.TransactionManager.Settings.NetworkInboundAccess) { base.ForwardEnlistmentEventToSubordinate(e); coordinator.StateMachine.ChangeState(base.state.States.CoordinatorInitializationFailed); } else { CoordinationContext currentContext = e.Body.CurrentContext; RegistrationProxy proxy = base.state.TryCreateRegistrationProxy(currentContext.RegistrationService); if (proxy == null) { coordinator.ContextManager.Fault = base.state.Faults.RegistrationProxyFailed; coordinator.StateMachine.ChangeState(base.state.States.CoordinatorInitializationFailed); } else { try { coordinator.SetRegistrationProxy(proxy); EnlistmentOptions options = coordinator.CreateEnlistmentOptions(currentContext.Expires, currentContext.ExpiresPresent, currentContext.IsolationLevel, currentContext.IsolationFlags, currentContext.Description); base.state.TransactionManagerSend.EnlistTransaction(coordinator, options, e); e.StateMachine.ChangeState(base.state.States.CoordinatorEnlisting); } finally { proxy.Release(); } } } }
internal OletxEnlistment( bool canDoSinglePhase, IEnlistmentNotificationInternal enlistmentNotification, Guid transactionGuid, EnlistmentOptions enlistmentOptions, OletxResourceManager oletxResourceManager, OletxTransaction oletxTransaction) : base(oletxResourceManager, oletxTransaction) { // This will get set later by the creator of this object after it // has enlisted with the proxy. EnlistmentShim = null; _phase0Shim = null; _canDoSinglePhase = canDoSinglePhase; _iEnlistmentNotification = enlistmentNotification; State = OletxEnlistmentState.Active; _transactionGuid = transactionGuid; _proxyPrepareInfoByteArray = null; TransactionsEtwProvider etwLog = TransactionsEtwProvider.Log; if (etwLog.IsEnabled()) { etwLog.EnlistmentCreated(TraceSourceType.TraceSourceOleTx, InternalTraceIdentifier, EnlistmentType.Durable, enlistmentOptions); } // Always do this last in case anything earlier fails. AddToEnlistmentTable(); }
/// <summary> /// Enlists a resource manager in this transaction. /// </summary> /// <param name="p_entNotification">The resource manager to enlist.</param> /// <param name="p_eopOptions">The enlistment options. This value must be <see cref="EnlistmentOptions.None"/>.</param> /// <exception cref="ArgumentException">Thrown if <paramref name="p_eopOptions"/> is not /// <see cref="EnlistmentOptions.None"/>.</exception> public void EnlistVolatile(IEnlistmentNotification p_entResourceManager, EnlistmentOptions p_eopOptions) { if (p_eopOptions != EnlistmentOptions.None) throw new ArgumentException("EnlistmentOptions must be None.", "p_eopOptions"); m_lstNotifications.Add(p_entResourceManager); }
public Enlistment EnlistVolatile( ISinglePhaseNotification notification, EnlistmentOptions options) { /* FIXME: Anything extra reqd for this? */ return(EnlistVolatileInternal(notification, options)); }
public static EnlistmentHandle Create( EnlistmentAccess access, string name, ObjectFlags objectFlags, DirectoryHandle rootDirectory, ResourceManagerHandle resourceManagerHandle, TransactionHandle transactionHandle, EnlistmentOptions createOptions, NotificationMask notificationMask, IntPtr enlistmentKey ) { ObjectAttributes oa = new ObjectAttributes(name, objectFlags, rootDirectory); IntPtr handle; try { Win32.NtCreateEnlistment( out handle, access, resourceManagerHandle, transactionHandle, ref oa, createOptions, notificationMask, enlistmentKey ).ThrowIf(); } finally { oa.Dispose(); } return(new EnlistmentHandle(handle, true)); }
public void EnlistDuringPhase0(EnlistmentOptions enlistmentOption, Phase1Vote phase1Vote, bool expectPhase0EnlistSuccess, bool commit, EnlistmentOutcome expectedOutcome, TransactionStatus expectedTxStatus) { Transaction tx = null; AutoResetEvent outcomeEvent = null; try { using (TransactionScope ts = new TransactionScope()) { tx = Transaction.Current.Clone(); outcomeEvent = new AutoResetEvent(false); TestEnlistment enlistment = new TestEnlistment(phase1Vote, expectedOutcome, true, expectPhase0EnlistSuccess, outcomeEvent); tx.EnlistVolatile(enlistment, enlistmentOption); if (commit) { ts.Complete(); } } } catch (TransactionInDoubtException) { Assert.Equal(TransactionStatus.InDoubt, expectedTxStatus); } catch (TransactionAbortedException) { Assert.Equal(TransactionStatus.Aborted, expectedTxStatus); } Assert.True(outcomeEvent.WaitOne(TimeSpan.FromSeconds(MaxTransactionCommitTimeoutInSeconds))); Assert.NotNull(tx); Assert.Equal(expectedTxStatus, tx.TransactionInformation.Status); }
internal Enlistment( InternalTransaction transaction, IEnlistmentNotification twoPhaseNotifications, ISinglePhaseNotification singlePhaseNotifications, Transaction atomicTransaction, EnlistmentOptions enlistmentOptions) { if ((enlistmentOptions & EnlistmentOptions.EnlistDuringPrepareRequired) != 0) { _internalEnlistment = new InternalEnlistment( this, transaction, twoPhaseNotifications, singlePhaseNotifications, atomicTransaction ); } else { _internalEnlistment = new Phase1VolatileEnlistment( this, transaction, twoPhaseNotifications, singlePhaseNotifications, atomicTransaction ); } }
public void TestCleanup() { target = null; ensureTransaction = true; options = EnlistmentOptions.None; enlistmentNotification = null; }
public Enlistment PromoteAndEnlistDurable( Guid manager, IPromotableSinglePhaseNotification promotableNotification, ISinglePhaseNotification notification, EnlistmentOptions options) { throw new NotImplementedException("DTC unsupported, multiple durable resource managers aren't supported."); }
public override void OnEvent(MsgCreateTransactionEvent e) { CompletionEnlistment completion = e.Completion; EnlistmentOptions options = completion.CreateEnlistmentOptions(e.Body.Expires, e.Body.ExpiresPresent, e.Body.IsolationLevel, 0, null); base.state.TransactionManagerSend.CreateTransaction(completion, options, e); e.StateMachine.ChangeState(base.state.States.CompletionCreating); }
/// <summary> /// Enlists a resource manager in this transaction. /// </summary> /// <param name="p_entNotification">The resource manager to enlist.</param> /// <param name="p_eopOptions">The enlistment options. This value must be <see cref="EnlistmentOptions.None"/>.</param> /// <exception cref="ArgumentException">Thrown if <paramref name="p_eopOptions"/> is not /// <see cref="EnlistmentOptions.None"/>.</exception> public void EnlistVolatile(IEnlistmentNotification p_entResourceManager, EnlistmentOptions p_eopOptions) { if (p_eopOptions != EnlistmentOptions.None) { throw new ArgumentException("EnlistmentOptions must be None.", "p_eopOptions"); } m_lstNotifications.Add(p_entResourceManager); }
public static Task EnlistVolatileAsync(this Transaction transaction, IEnlistmentNotification enlistmentNotification, EnlistmentOptions enlistmentOptions) { return(Task.FromResult(transaction.EnlistVolatile (enlistmentNotification, enlistmentOptions))); }
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); } }
/// <summary> /// Enlists this instance as a volatile resource /// manager using the specified enlistment /// options. /// </summary> /// <param name="enlistmentOptions">The enlistment options.</param> /// <remarks> /// <para> /// The instance is enlisted as a volatile resource /// to receive two phase commit notifications. /// </para> /// </remarks> /// <exception cref="InvalidOperationException"> /// No ambient transaction detected. The instance cannot enlist /// a <b>null</b> transaction. /// </exception> /// <seealso cref="System.Transactions.Transaction.Current"/> public void EnlistVolatile(EnlistmentOptions enlistmentOptions) { if (Transaction.Current == null) { throw new InvalidOperationException( String.Format( "Cannot enlist resource {0}: no ambient transaction detected.", this.managedPath)); } Transaction.Current.EnlistVolatile(this, enlistmentOptions); }
internal static void Trace(string traceSource, EnlistmentTraceIdentifier enTraceId, EnlistmentType enType, EnlistmentOptions enOptions) { lock (record) { record.traceSource = traceSource; record.enTraceId = enTraceId; record.enType = enType; record.enOptions = enOptions; DiagnosticTrace.TraceEvent(TraceEventType.Information, "http://msdn.microsoft.com/2004/06/System/Transactions/Enlistment", System.Transactions.SR.GetString("TraceEnlistment"), record); } }
internal OletxVolatileEnlistment(IEnlistmentNotificationInternal enlistmentNotification, EnlistmentOptions enlistmentOptions, OletxTransaction oletxTransaction) : base(null, oletxTransaction) { this.iEnlistmentNotification = enlistmentNotification; this.enlistDuringPrepareRequired = (enlistmentOptions & EnlistmentOptions.EnlistDuringPrepareRequired) != EnlistmentOptions.None; this.container = null; this.pendingOutcome = TransactionStatus.Active; if (DiagnosticTrace.Information) { EnlistmentTraceRecord.Trace(System.Transactions.SR.GetString("TraceSourceOletx"), base.InternalTraceIdentifier, EnlistmentType.Volatile, enlistmentOptions); } }
private Enlistment EnlistVolatileInternal( IEnlistmentNotification notification, EnlistmentOptions options) { EnsureIncompleteCurrentScope(); /* FIXME: Handle options.EnlistDuringPrepareRequired */ Volatiles.Add(notification); /* FIXME: Enlistment.. ? */ return(new Enlistment()); }
internal Enlistment(InternalTransaction transaction, IEnlistmentNotification twoPhaseNotifications, ISinglePhaseNotification singlePhaseNotifications, Transaction atomicTransaction, EnlistmentOptions enlistmentOptions) { if ((enlistmentOptions & EnlistmentOptions.EnlistDuringPrepareRequired) != EnlistmentOptions.None) { this.internalEnlistment = new System.Transactions.InternalEnlistment(this, transaction, twoPhaseNotifications, singlePhaseNotifications, atomicTransaction); } else { this.internalEnlistment = new Phase1VolatileEnlistment(this, transaction, twoPhaseNotifications, singlePhaseNotifications, atomicTransaction); } }
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); } }
protected DurableEnlistmentNotification(Guid resourceManager, EnlistmentOptions enlistmentOptions) { Trace.WriteIf(Tracing.Is.TraceVerbose, "resourceManager={0} enlistmentOptions={1}".FormatWith(resourceManager, enlistmentOptions.ToString("G"))); Operation = new Operation(resourceManager); if (null == Transaction.Current) { throw new InvalidOperationException("There is no transaction scope to enlist with."); } Transaction.Current.EnlistDurable(resourceManager, this, enlistmentOptions); Transaction.Current.TransactionCompleted += OnTransactionCompleted; }
public void EnlistVolatile(int volatileCount, EnlistmentOptions enlistmentOption, Phase1Vote volatilePhase1Vote, Phase1Vote lastPhase1Vote, bool commit, EnlistmentOutcome expectedEnlistmentOutcome, TransactionStatus expectedTxStatus) { AutoResetEvent[] outcomeEvents = null; Transaction tx = null; try { using (TransactionScope ts = new TransactionScope()) { tx = Transaction.Current.Clone(); if (volatileCount > 0) { TestEnlistment[] volatiles = new TestEnlistment[volatileCount]; outcomeEvents = new AutoResetEvent[volatileCount]; for (int i = 0; i < volatileCount - 1; i++) { outcomeEvents[i] = new AutoResetEvent(false); volatiles[i] = new TestEnlistment(volatilePhase1Vote, expectedEnlistmentOutcome, false, true, outcomeEvents[i]); tx.EnlistVolatile(volatiles[i], enlistmentOption); } outcomeEvents[volatileCount - 1] = new AutoResetEvent(false); volatiles[volatileCount - 1] = new TestEnlistment(lastPhase1Vote, expectedEnlistmentOutcome, false, true, outcomeEvents[volatileCount - 1]); tx.EnlistVolatile(volatiles[volatileCount - 1], enlistmentOption); } if (commit) { ts.Complete(); } } } catch (TransactionInDoubtException) { Assert.Equal(TransactionStatus.InDoubt, expectedTxStatus); } catch (TransactionAbortedException) { Assert.Equal(TransactionStatus.Aborted, expectedTxStatus); } Task.Run(() => // in case current thread is STA thread, where WaitHandle.WaitAll isn't supported { Assert.True(WaitHandle.WaitAll(outcomeEvents, TimeSpan.FromSeconds(MaxTransactionCommitTimeoutInSeconds))); }).GetAwaiter().GetResult(); Assert.NotNull(tx); Assert.Equal(expectedTxStatus, tx.TransactionInformation.Status); }
internal static void Trace(string traceSource, EnlistmentTraceIdentifier enTraceId, EnlistmentType enType, EnlistmentOptions enOptions) { lock (record) { record.traceSource = traceSource; record.enTraceId = enTraceId; record.enType = enType; record.enOptions = enOptions; DiagnosticTrace.TraceEvent(TraceEventType.Information, TransactionsTraceCode.Enlistment, SR.GetString(SR.TraceEnlistment), record); } }
internal override Enlistment EnlistDurable(InternalTransaction tx, Guid resourceManagerIdentifier, ISinglePhaseNotification enlistmentNotification, EnlistmentOptions enlistmentOptions, Transaction atomicTransaction) { if ((tx.durableEnlistment != null) || ((enlistmentOptions & EnlistmentOptions.EnlistDuringPrepareRequired) != EnlistmentOptions.None)) { tx.promoteState.EnterState(tx); return tx.State.EnlistDurable(tx, resourceManagerIdentifier, enlistmentNotification, enlistmentOptions, atomicTransaction); } Enlistment enlistment = new Enlistment(resourceManagerIdentifier, tx, enlistmentNotification, enlistmentNotification, atomicTransaction); tx.durableEnlistment = enlistment.InternalEnlistment; DurableEnlistmentState._DurableEnlistmentActive.EnterState(tx.durableEnlistment); if (DiagnosticTrace.Information) { EnlistmentTraceRecord.Trace(System.Transactions.SR.GetString("TraceSourceLtm"), tx.durableEnlistment.EnlistmentTraceId, EnlistmentType.Durable, EnlistmentOptions.None); } return enlistment; }
public void TwoPhaseDurable(int volatileCount, EnlistmentOptions volatileEnlistmentOption, EnlistmentOptions durableEnlistmentOption, Phase1Vote volatilePhase1Vote, bool commit, EnlistmentOutcome expectedVolatileOutcome, EnlistmentOutcome expectedDurableOutcome, TransactionStatus expectedTxStatus) { Transaction tx = null; try { using (TransactionScope ts = new TransactionScope()) { tx = Transaction.Current.Clone(); if (volatileCount > 0) { TestEnlistment[] volatiles = new TestEnlistment[volatileCount]; for (int i = 0; i < volatileCount; i++) { // It doesn't matter what we specify for SinglePhaseVote. volatiles[i] = new TestEnlistment(volatilePhase1Vote, expectedVolatileOutcome); tx.EnlistVolatile(volatiles[i], volatileEnlistmentOption); } } TestEnlistment durable = new TestEnlistment(Phase1Vote.Prepared, expectedDurableOutcome); // TODO: Issue #10353 - This needs to change once we have promotion support. Assert.Throws <PlatformNotSupportedException>(() => // Creation of two phase durable enlistment attempts to promote to MSDTC { tx.EnlistDurable(Guid.NewGuid(), durable, durableEnlistmentOption); }); if (commit) { ts.Complete(); } } } catch (TransactionInDoubtException) { Assert.Equal(TransactionStatus.InDoubt, expectedTxStatus); } catch (TransactionAbortedException) { Assert.Equal(TransactionStatus.Aborted, expectedTxStatus); } Assert.NotNull(tx); Assert.Equal(expectedTxStatus, tx.TransactionInformation.Status); }
internal override Enlistment EnlistVolatile(InternalTransaction tx, ISinglePhaseNotification enlistmentNotification, EnlistmentOptions enlistmentOptions, Transaction atomicTransaction) { Enlistment enlistment = new Enlistment(tx, enlistmentNotification, enlistmentNotification, atomicTransaction, enlistmentOptions); if ((enlistmentOptions & EnlistmentOptions.EnlistDuringPrepareRequired) != EnlistmentOptions.None) { base.AddVolatileEnlistment(ref tx.phase0Volatiles, enlistment); } else { base.AddVolatileEnlistment(ref tx.phase1Volatiles, enlistment); } if (DiagnosticTrace.Information) { EnlistmentTraceRecord.Trace(System.Transactions.SR.GetString("TraceSourceLtm"), enlistment.InternalEnlistment.EnlistmentTraceId, EnlistmentType.Volatile, enlistmentOptions); } return enlistment; }
public void TwoPhaseDurable(int volatileCount, EnlistmentOptions volatileEnlistmentOption, EnlistmentOptions durableEnlistmentOption, Phase1Vote volatilePhase1Vote, Phase1Vote durablePhase1Vote, bool commit, EnlistmentOutcome expectedVolatileOutcome, EnlistmentOutcome expectedDurableOutcome, TransactionStatus expectedTxStatus) { Transaction tx = null; try { using (TransactionScope ts = new TransactionScope()) { tx = Transaction.Current.Clone(); if (volatileCount > 0) { TestEnlistment[] volatiles = new TestEnlistment[volatileCount]; for (int i = 0; i < volatileCount; i++) { // It doesn't matter what we specify for SinglePhaseVote. volatiles[i] = new TestEnlistment(volatilePhase1Vote, expectedVolatileOutcome); tx.EnlistVolatile(volatiles[i], volatileEnlistmentOption); } } TestEnlistment durable = new TestEnlistment(Phase1Vote.Prepared, expectedDurableOutcome); // TODO: Issue #10353 - This needs to change once we have promotion support. Assert.Throws<PlatformNotSupportedException>(() => // Creation of two phase durable enlistment attempts to promote to MSDTC { tx.EnlistDurable(Guid.NewGuid(), durable, durableEnlistmentOption); }); if (commit) { ts.Complete(); } } } catch (TransactionInDoubtException) { Assert.Equal(expectedTxStatus, TransactionStatus.InDoubt); } catch (TransactionAbortedException) { Assert.Equal(expectedTxStatus, TransactionStatus.Aborted); } Assert.NotNull(tx); Assert.Equal(expectedTxStatus, tx.TransactionInformation.Status); }
public void SinglePhaseDurable(int volatileCount, EnlistmentOptions volatileEnlistmentOption, Phase1Vote volatilePhase1Vote, SinglePhaseVote singlePhaseVote, bool commit, EnlistmentOutcome expectedVolatileOutcome, TransactionStatus expectedTxStatus) { Transaction tx = null; try { using (TransactionScope ts = new TransactionScope()) { tx = Transaction.Current.Clone(); if (volatileCount > 0) { TestSinglePhaseEnlistment[] volatiles = new TestSinglePhaseEnlistment[volatileCount]; for (int i = 0; i < volatileCount; i++) { // It doesn't matter what we specify for SinglePhaseVote. volatiles[i] = new TestSinglePhaseEnlistment(volatilePhase1Vote, SinglePhaseVote.InDoubt, expectedVolatileOutcome); tx.EnlistVolatile(volatiles[i], volatileEnlistmentOption); } } // Doesn't really matter what we specify for EnlistmentOutcome here. This is an SPC, so Phase2 won't happen for this enlistment. TestSinglePhaseEnlistment durable = new TestSinglePhaseEnlistment(Phase1Vote.Prepared, singlePhaseVote, EnlistmentOutcome.Committed); tx.EnlistDurable(Guid.NewGuid(), durable, EnlistmentOptions.None); if (commit) { ts.Complete(); } } } catch (TransactionInDoubtException) { Assert.Equal(TransactionStatus.InDoubt, expectedTxStatus); } catch (TransactionAbortedException) { Assert.Equal(TransactionStatus.Aborted, expectedTxStatus); } Assert.NotNull(tx); Assert.Equal(expectedTxStatus, tx.TransactionInformation.Status); }
public void SinglePhaseDurable(int volatileCount, EnlistmentOptions volatileEnlistmentOption, Phase1Vote volatilePhase1Vote, SinglePhaseVote singlePhaseVote, bool commit, EnlistmentOutcome expectedVolatileOutcome, TransactionStatus expectedTxStatus) { Transaction tx = null; try { using (TransactionScope ts = new TransactionScope()) { tx = Transaction.Current.Clone(); if (volatileCount > 0) { TestSinglePhaseEnlistment[] volatiles = new TestSinglePhaseEnlistment[volatileCount]; for (int i = 0; i < volatileCount; i++) { // It doesn't matter what we specify for SinglePhaseVote. volatiles[i] = new TestSinglePhaseEnlistment(volatilePhase1Vote, SinglePhaseVote.InDoubt, expectedVolatileOutcome); tx.EnlistVolatile(volatiles[i], volatileEnlistmentOption); } } // Doesn't really matter what we specify for EnlistmentOutcome here. This is an SPC, so Phase2 won't happen for this enlistment. TestSinglePhaseEnlistment durable = new TestSinglePhaseEnlistment(Phase1Vote.Prepared, singlePhaseVote, EnlistmentOutcome.Committed); tx.EnlistDurable(Guid.NewGuid(), durable, EnlistmentOptions.None); if (commit) { ts.Complete(); } } } catch (TransactionInDoubtException) { Assert.Equal(expectedTxStatus, TransactionStatus.InDoubt); } catch (TransactionAbortedException) { Assert.Equal(expectedTxStatus, TransactionStatus.Aborted); } Assert.NotNull(tx); Assert.Equal(expectedTxStatus, tx.TransactionInformation.Status); }
public Enlistment EnlistDurable(Guid manager, ISinglePhaseNotification notification, EnlistmentOptions options) { EnsureIncompleteCurrentScope(); if (pspe != null || Durables.Count > 0) { throw new NotImplementedException("DTC unsupported, multiple durable resource managers aren't supported."); } if (options != EnlistmentOptions.None) { throw new NotImplementedException("EnlistmentOptions other than None aren't supported"); } Durables.Add(notification); /* FIXME: Enlistment ?? */ return(new Enlistment()); }
public Enlistment EnlistDurable(Guid manager, ISinglePhaseNotification notification, EnlistmentOptions options) { if (durables.Count == 1) { throw new NotImplementedException("Only LTM supported. Cannot have more than 1 durable resource per transaction."); } EnsureIncompleteCurrentScope(); if (options != EnlistmentOptions.None) { throw new NotImplementedException("Implement me"); } durables.Add(notification); /* FIXME: Enlistment ?? */ return(new Enlistment()); }
public Enlistment EnlistVolatile ( IEnlistmentNotification notification, EnlistmentOptions options) { return EnlistVolatileInternal (notification, options); }
public Enlistment EnlistDurable (Guid manager, ISinglePhaseNotification notification, EnlistmentOptions options) { EnsureIncompleteCurrentScope (); if (pspe != null || Durables.Count > 0) throw new NotImplementedException ("DTC unsupported, multiple durable resource managers aren't supported."); if (options != EnlistmentOptions.None) throw new NotImplementedException ("EnlistmentOptions other than None aren't supported"); Durables.Add (notification); /* FIXME: Enlistment ?? */ return new Enlistment (); }
public Enlistment EnlistDurable (Guid manager, IEnlistmentNotification notification, EnlistmentOptions options) { throw new NotImplementedException ("DTC unsupported, only SinglePhase commit supported for durable resource managers."); }
internal IPromotedEnlistment EnlistVolatile(ISinglePhaseNotificationInternal singlePhaseNotification, EnlistmentOptions enlistmentOptions) { if (DiagnosticTrace.Verbose) { MethodEnteredTraceRecord.Trace(System.Transactions.SR.GetString("TraceSourceOletx"), "OletxTransaction.EnlistVolatile( ISinglePhaseNotificationInternal )"); } if ((this.realOletxTransaction == null) || this.realOletxTransaction.TooLateForEnlistments) { throw TransactionException.Create(System.Transactions.SR.GetString("TraceSourceOletx"), System.Transactions.SR.GetString("TooLate"), null); } IPromotedEnlistment enlistment = this.realOletxTransaction.EnlistVolatile(singlePhaseNotification, enlistmentOptions, this); if (DiagnosticTrace.Verbose) { MethodExitedTraceRecord.Trace(System.Transactions.SR.GetString("TraceSourceOletx"), "OletxTransaction.EnlistVolatile( ISinglePhaseNotificationInternal )"); } return(enlistment); }
internal IPromotedEnlistment EnlistVolatile(VolatileDemultiplexer volatileDemux, EnlistmentOptions enlistmentOptions) { throw NotSupported(); }
internal IPromotedEnlistment EnlistVolatile(InternalEnlistment internalEnlistment, EnlistmentOptions enlistmentOptions) { throw NotSupported(); }
// Forward request to the state machine to take the appropriate action. // /// <include file='doc\Transaction' path='docs/doc[@for="Transaction.EnlistVolatile"]/*' /> public Enlistment EnlistVolatile( ISinglePhaseNotification singlePhaseNotification, EnlistmentOptions enlistmentOptions ) { if (DiagnosticTrace.Verbose) { MethodEnteredTraceRecord.Trace(SR.GetString(SR.TraceSourceLtm), "Transaction.EnlistVolatile( ISinglePhaseNotification )" ); } if (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(SR.GetString(SR.TraceSourceLtm)); } lock (this.internalTransaction) { Enlistment enlistment = this.internalTransaction.State.EnlistVolatile(this.internalTransaction, singlePhaseNotification, enlistmentOptions, this); if (DiagnosticTrace.Verbose) { MethodExitedTraceRecord.Trace(SR.GetString(SR.TraceSourceLtm), "Transaction.EnlistVolatile( ISinglePhaseNotification )" ); } return enlistment; } }
/// <summary> /// Enlists the supplied transaction manager in the current transaction. /// </summary> /// <param name="ensureTransaction">if set to <c>true</c> forces an exception if there are no available transactions.</param> /// <param name="enlistmentNotification">The <c>IEnlistmentNotification</c> instance to enlist in the transaction.</param> /// <param name="options">The transaction enlistment options.</param> public void EnlistInTransaction( Boolean ensureTransaction, IEnlistmentNotification enlistmentNotification, EnlistmentOptions options ) { options.EnsureIsDefined(); if( enlistmentNotification == null ) { throw new ArgumentNullException( "enlistmentNotification" ); } if( ensureTransaction && Transaction.Current == null ) { throw new InvalidOperationException( "Transaction is mandatory." ); } if( this.EnlistedInTransaction && this.enlistedTransaction != Transaction.Current ) { //Errore siamo in una transazione diversa da quella in cui ci siamo enlisted. throw new NotSupportedException( "Multiple Transation detected." ); } if( Transaction.Current != null ) { /* * Dobbiamo inserirci in una Transazione: * - ci teniamo un riferimento alla transazione in cui andiamo ad inserirci * - chiediamo alla transazione di inserirci all'interno del suo processo */ this.enlistedTransaction = Transaction.Current; this.enlistedTransaction.EnlistVolatile( enlistmentNotification, options ); /* * Ci interessa tenere traccia di quando la transazione finisce * per liberare un po' di risorse */ this.enlistedTransaction.TransactionCompleted += new TransactionCompletedEventHandler( OnEnlistedTransactionTransactionCompleted ); this.OnTransactionEnlisted(); } }
public Enlistment EnlistVolatile ( ISinglePhaseNotification notification, EnlistmentOptions options) { /* FIXME: Anything extra reqd for this? */ return EnlistVolatileInternal (notification, options); }
public Enlistment EnlistVolatile(IEnlistmentNotification enlistmentNotification, EnlistmentOptions enlistmentOptions) { }
public Enlistment EnlistDurable(System.Guid resourceManagerIdentifier, ISinglePhaseNotification singlePhaseNotification, EnlistmentOptions enlistmentOptions) { }
public Enlistment EnlistDurable(System.Guid resourceManagerIdentifier, IEnlistmentNotification enlistmentNotification, EnlistmentOptions enlistmentOptions) { }
internal virtual Enlistment EnlistVolatile(InternalTransaction tx, ISinglePhaseNotification enlistmentNotification, EnlistmentOptions enlistmentOptions, Transaction atomicTransaction) { throw TransactionException.CreateTransactionStateException(System.Transactions.SR.GetString("TraceSourceLtm"), tx.innerException); }
internal virtual Enlistment EnlistDurable(InternalTransaction tx, Guid resourceManagerIdentifier, IEnlistmentNotification enlistmentNotification, EnlistmentOptions enlistmentOptions, Transaction atomicTransaction) { throw TransactionException.CreateTransactionStateException(System.Transactions.SR.GetString("TraceSourceLtm"), tx.innerException); }
private Enlistment EnlistVolatileInternal ( IEnlistmentNotification notification, EnlistmentOptions options) { EnsureIncompleteCurrentScope (); /* FIXME: Handle options.EnlistDuringPrepareRequired */ Volatiles.Add (notification); /* FIXME: Enlistment.. ? */ return new Enlistment (); }
public Enlistment EnlistDurable( Guid resourceManagerIdentifier, IEnlistmentNotification enlistmentNotification, EnlistmentOptions enlistmentOptions ) { if (DiagnosticTrace.Verbose) { MethodEnteredTraceRecord.Trace(SR.GetString(SR.TraceSourceLtm), "Transaction.EnlistDurable( IEnlistmentNotification )" ); } if (Disposed) { throw new ObjectDisposedException("Transaction"); } if (resourceManagerIdentifier == Guid.Empty) { throw new ArgumentException(SR.GetString(SR.BadResourceManagerId), "resourceManagerIdentifier"); } if (enlistmentNotification == null) { throw new ArgumentNullException("enlistmentNotification"); } if (enlistmentOptions != EnlistmentOptions.None && enlistmentOptions != EnlistmentOptions.EnlistDuringPrepareRequired) { throw new ArgumentOutOfRangeException("enlistmentOptions"); } if (this.complete) { throw TransactionException.CreateTransactionCompletedException(SR.GetString(SR.TraceSourceLtm)); } lock (this.internalTransaction) { Enlistment enlistment = this.internalTransaction.State.EnlistDurable(this.internalTransaction, resourceManagerIdentifier, enlistmentNotification, enlistmentOptions, this); if (DiagnosticTrace.Verbose) { MethodExitedTraceRecord.Trace(SR.GetString(SR.TraceSourceLtm), "Transaction.EnlistDurable( IEnlistmentNotification )" ); } return enlistment; } }
internal override Enlistment EnlistDurable(InternalTransaction tx, Guid resourceManagerIdentifier, IEnlistmentNotification enlistmentNotification, EnlistmentOptions enlistmentOptions, Transaction atomicTransaction) { tx.promoteState.EnterState(tx); return tx.State.EnlistDurable(tx, resourceManagerIdentifier, enlistmentNotification, enlistmentOptions, atomicTransaction); }
public Enlistment EnlistVolatile( IEnlistmentNotification notification, EnlistmentOptions options) { return(EnlistVolatileInternal(notification, options)); }
public Enlistment EnlistDurable (Guid manager, ISinglePhaseNotification notification, EnlistmentOptions options) { if (durables.Count == 1) throw new NotImplementedException ("Only LTM supported. Cannot have more than 1 durable resource per transaction."); EnsureIncompleteCurrentScope (); if (options != EnlistmentOptions.None) throw new NotImplementedException ("Implement me"); durables.Add (notification); /* FIXME: Enlistment ?? */ return new Enlistment (); }
internal IPromotedEnlistment EnlistVolatile(ISinglePhaseNotificationInternal enlistmentNotification, EnlistmentOptions enlistmentOptions, OletxTransaction oletxTransaction) { return this.CommonEnlistVolatile(enlistmentNotification, enlistmentOptions, oletxTransaction); }
internal IPromotedEnlistment EnlistDurable(Guid resourceManagerIdentifier, DurableInternalEnlistment internalEnlistment, bool v, EnlistmentOptions enlistmentOptions) { throw NotSupported(); }
internal IPromotedEnlistment CommonEnlistVolatile(IEnlistmentNotificationInternal enlistmentNotification, EnlistmentOptions enlistmentOptions, OletxTransaction oletxTransaction) { OletxVolatileEnlistment enlistment = null; bool flag2 = false; bool flag = false; OletxPhase0VolatileEnlistmentContainer target = null; OletxPhase1VolatileEnlistmentContainer container = null; IntPtr zero = IntPtr.Zero; IVoterBallotShim voterBallotShim = null; IPhase0EnlistmentShim shim = null; bool flag3 = false; RuntimeHelpers.PrepareConstrainedRegions(); try { lock (this) { enlistment = new OletxVolatileEnlistment(enlistmentNotification, enlistmentOptions, oletxTransaction); if ((enlistmentOptions & EnlistmentOptions.EnlistDuringPrepareRequired) != EnlistmentOptions.None) { if (this.phase0EnlistVolatilementContainerList == null) { this.phase0EnlistVolatilementContainerList = new ArrayList(1); } if (this.phase0EnlistVolatilementContainerList.Count == 0) { target = new OletxPhase0VolatileEnlistmentContainer(this); flag = true; } else { target = this.phase0EnlistVolatilementContainerList[this.phase0EnlistVolatilementContainerList.Count - 1] as OletxPhase0VolatileEnlistmentContainer; if (!target.NewEnlistmentsAllowed) { target = new OletxPhase0VolatileEnlistmentContainer(this); flag = true; } else { flag = false; } } if (flag) { zero = HandleTable.AllocHandle(target); } } else if (this.phase1EnlistVolatilementContainer == null) { flag2 = true; container = new OletxPhase1VolatileEnlistmentContainer(this) { voterHandle = HandleTable.AllocHandle(container) }; } else { flag2 = false; container = this.phase1EnlistVolatilementContainer; } try { if (flag) { lock (target) { this.transactionShim.Phase0Enlist(zero, out shim); target.Phase0EnlistmentShim = shim; } } if (flag2) { this.transactionShim.CreateVoter(container.voterHandle, out voterBallotShim); flag3 = true; container.VoterBallotShim = voterBallotShim; } if ((enlistmentOptions & EnlistmentOptions.EnlistDuringPrepareRequired) != EnlistmentOptions.None) { target.AddEnlistment(enlistment); if (flag) { this.phase0EnlistVolatilementContainerList.Add(target); } return enlistment; } container.AddEnlistment(enlistment); if (flag2) { this.phase1EnlistVolatilementContainer = container; } return enlistment; } catch (COMException exception) { OletxTransactionManager.ProxyException(exception); throw; } return enlistment; } } finally { if ((zero != IntPtr.Zero) && (target.Phase0EnlistmentShim == null)) { HandleTable.FreeHandle(zero); } if ((!flag3 && (container != null)) && ((container.voterHandle != IntPtr.Zero) && flag2)) { HandleTable.FreeHandle(container.voterHandle); } } return enlistment; }
public Enlistment EnlistVolatile(ISinglePhaseNotification singlePhaseNotification, EnlistmentOptions enlistmentOptions) { }
internal IPromotedEnlistment EnlistDurable(Guid resourceManagerIdentifier, ISinglePhaseNotificationInternal singlePhaseNotification, bool canDoSinglePhase, EnlistmentOptions enlistmentOptions) { if (DiagnosticTrace.Verbose) { MethodEnteredTraceRecord.Trace(System.Transactions.SR.GetString("TraceSourceOletx"), "OletxTransaction.EnlistDurable( ISinglePhaseNotificationInternal )"); } if ((this.realOletxTransaction == null) || this.realOletxTransaction.TooLateForEnlistments) { throw TransactionException.Create(System.Transactions.SR.GetString("TraceSourceOletx"), System.Transactions.SR.GetString("TooLate"), null); } OletxEnlistment enlistment = this.realOletxTransaction.OletxTransactionManagerInstance.FindOrRegisterResourceManager(resourceManagerIdentifier).EnlistDurable(this, canDoSinglePhase, singlePhaseNotification, enlistmentOptions); if (DiagnosticTrace.Verbose) { MethodExitedTraceRecord.Trace(System.Transactions.SR.GetString("TraceSourceOletx"), "OletxTransaction.EnlistDurable( ISinglePhaseNotificationInternal )"); } return(enlistment); }
internal void TransactionstateEnlist(EnlistmentTraceIdentifier enlistmentID, EnlistmentType enlistmentType, EnlistmentOptions enlistmentOption) { if (IsEnabled(EventLevel.Informational, ALL_KEYWORDS)) { TransactionstateEnlist(enlistmentID.EnlistmentIdentifier.ToString(), enlistmentType.ToString(), enlistmentOption.ToString()); } }
public Enlistment EnlistDurable(Guid manager, IEnlistmentNotification notification, EnlistmentOptions options) { throw new NotImplementedException("DTC unsupported, only SinglePhase commit supported for durable resource managers."); }
// 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); } }
/// <summary> /// Enlist a durable resource manager that supports single phase commit optimization to participate in a transaction. /// </summary> /// <param name="resourceManagerIdentifier">A global resource identifier for the durable resource.</param> /// <param name="enlistmentNotification">Describes an interface that a resource manager should implement to two phase /// commit notifications callbacks for the transaction manager upon enlisting for participation.</param> /// <param name="enlistmentOptions">Detemines whether the object should be enlisted during the prepare phase.</param> public void EnlistDurable(Guid resourceManagerIdentifier, IEnlistmentNotification enlistmentNotification, EnlistmentOptions enlistmentOptions) { // Enlist the volatile resource manager in this transaction for the two phase commit callback notifications. this.committableTransaction.EnlistDurable(resourceManagerIdentifier, enlistmentNotification, enlistmentOptions); }