예제 #1
0
 public void Prepare(PreparingEnlistment preparingEnlistment)
 {
     switch (_phase1Vote)
     {
         case Phase1Vote.Prepared:
             {
                 preparingEnlistment.Prepared();
                 break;
             }
         case Phase1Vote.ForceRollback:
             {
                 preparingEnlistment.ForceRollback();
                 break;
             }
         case Phase1Vote.Done:
             {
                 preparingEnlistment.Done();
                 break;
             }
     }
 }
 /// <summary>
 /// Responds to the Prepare notification.
 /// </summary>
 /// <param name="preparingEnlistment">An Enlistment that facilitates communication between the enlisted transaction participant and the transaction manager during the Prepare phase of the transaction.</param>
 public override void Prepare(PreparingEnlistment preparingEnlistment)
 {
     // Allow the base class to handle the Prepare notification.
     base.Prepare(preparingEnlistment);
 }
예제 #3
0
 public void Prepare(PreparingEnlistment preparingEnlistment)
 {
     switch (_phase1Vote)
     {
         case Phase1Vote.Prepared:
             {
                 if (_volatileEnlistDuringPrepare)
                 {
                     TestEnlistment newVol = new TestEnlistment(_phase1Vote, _expectedOutcome);
                     try
                     {
                         _txToEnlist.EnlistVolatile(newVol, EnlistmentOptions.None);
                         Assert.Equal(_expectEnlistToSucceed, true);
                     }
                     catch (Exception)
                     {
                         Assert.Equal(_expectEnlistToSucceed, false);
                     }
                 }
                 preparingEnlistment.Prepared();
                 break;
             }
         case Phase1Vote.ForceRollback:
             {
                 if (_outcomeReceived != null)
                 {
                     _outcomeReceived.Set();
                 }
                 preparingEnlistment.ForceRollback();
                 break;
             }
         case Phase1Vote.Done:
             {
                 if (_outcomeReceived != null)
                 {
                     _outcomeReceived.Set();
                 }
                 preparingEnlistment.Done();
                 break;
             }
     }
 }
예제 #4
0
 public void Prepare(PreparingEnlistment preparingEnlistment)
 {
     Logger.TheInstance.WriteToLog("VolatileRM: Prepare");
     preparingEnlistment.Prepared();
 }
예제 #5
0
 public void Prepare(PreparingEnlistment preparingEnlistment)
 {
     preparingEnlistment.Prepared();
 }
예제 #6
0
        // This *doesn't* get called when we get enlisted in a Tx, it gets
        // called when we're about to commit a transaction. We can *probably*
        // get away with calling .Done() here and skipping the commit phase,
        // but I'm not sure if we'd get InDoubt signalling if we did that.
        public void Prepare(PreparingEnlistment preparingEnlistment)
        {
            log.Debug("Registry prepared to commit transaction");

            preparingEnlistment.Prepared();
        }
예제 #7
0
 public void Prepare(PreparingEnlistment preparingEnlistment)
 {
     _logger.DebugFormat("In Memory Repository, prepare notification received");
     OnPrepare();
     preparingEnlistment.Prepared();
 }
예제 #8
0
 void IEnlistmentNotification.Prepare(PreparingEnlistment preparingEnlistment)
 {
     preparingEnlistment.Prepared();
 }
 // fail during prepare, this will cause scope.Complete to throw
 public void Prepare(PreparingEnlistment preparingEnlistment) => preparingEnlistment.ForceRollback();
예제 #10
0
 public void Prepare(PreparingEnlistment preparingEnlistment)
 {
     Console.WriteLine("Tx Prepare");
     preparingEnlistment.Prepared();
 }
 public void Prepare(PreparingEnlistment preparingEnlistment)
 {
     log.Debug("Prepared");
     preparingEnlistment.Prepared();
 }
예제 #12
0
 public void Prepare(PreparingEnlistment preparingEnlistment)
 {
     lockingInfo.Release();
 }
예제 #13
0
 void IEnlistmentNotification.Prepare(PreparingEnlistment preparingEnlistment)
 {
     this.preparingEnlistment = preparingEnlistment;
     ActionItem.Schedule(PrepareCallback, this);
 }
예제 #14
0
 /// <summary>
 /// Notifies an enlisted object that a transaction is being prepared for commitment.
 /// </summary>
 /// <param name="preparingEnlistment">A <see cref="T:System.Transactions.PreparingEnlistment" /> object used to send a response to the transaction manager.</param>
 public void Prepare(PreparingEnlistment preparingEnlistment)
 {
     preparingEnlistment.Done();
 }
예제 #15
0
 public void Prepare(PreparingEnlistment preparingEnlistment)
 {
     //preparingEnlistment.Prepared();
     preparingEnlistment.ForceRollback();
 }
예제 #16
0
 public void Prepare(PreparingEnlistment preparingEnlistment)
 {
     throw new NotImplementedException();
 }
 public void Prepare(PreparingEnlistment preparingEnlistment)
 {
     _logger.LogInformation($"{nameof(Prepare)} was called");
     preparingEnlistment.Prepared();
 }
예제 #18
0
 public void Prepare(PreparingEnlistment preparingEnlistment)
 {
     database.PutStatic("transactions/recoveryInformation/" + txId, null, preparingEnlistment.RecoveryInformation(), new RavenJObject());
     preparingEnlistment.Prepared();
 }
예제 #19
0
 public void Prepare(PreparingEnlistment preparingEnlistment)
 {
     // shouldn't be called, already
     // prepared, otherwise we won't have this issue
     preparingEnlistment.Prepared();
 }
예제 #20
0
 public void Prepare(PreparingEnlistment enlistment)
 {
     Console.Write("Prepare ");
     enlistment.Prepared();
 }
예제 #21
0
 public void Prepare(PreparingEnlistment preparingEnlistment)
 {
     Neo4jTransaction.DoKeepAlive(_transactionExecutionEnvironment);
     preparingEnlistment.Done();
 }
예제 #22
0
 protected override void OnPrepare(PreparingEnlistment enlistment)
 {
 }
 public void Prepare(PreparingEnlistment preparingEnlistment)
 {
     // fail during prepare, this will cause scope.Complete to throw
     preparingEnlistment.ForceRollback();
 }
        public void Prepare(PreparingEnlistment preparingEnlistment)
        {
            try
            {
                dtcControlEvent.Reset();

                Tracer.Debug("Prepare notification received for TX id: " + this.transactionId);

                BeforeEnd();

                // Before sending the request to the broker, log the recovery bits, if
                // this fails we can't prepare and the TX should be rolled back.
                RecoveryLogger.LogRecoveryInfo(this.transactionId as XATransactionId,
                                               preparingEnlistment.RecoveryInformation());

                // Inform the broker that work on the XA'sh TX Branch is complete.
                TransactionInfo info = new TransactionInfo();
                info.ConnectionId  = this.connection.ConnectionId;
                info.TransactionId = this.transactionId;
                info.Type          = (int)TransactionType.End;

                this.connection.CheckConnected();
                this.connection.SyncRequest(info);

                // Prepare the Transaction for commit.
                info.Type = (int)TransactionType.Prepare;
                IntegerResponse response = (IntegerResponse)this.connection.SyncRequest(info);
                if (response.Result == XA_READONLY)
                {
                    Tracer.Debug("Transaction Prepare done and doesn't need a commit, TX id: " + this.transactionId);

                    this.transactionId     = null;
                    this.currentEnlistment = null;

                    // Read Only means there's nothing to recover because there was no
                    // change on the broker.
                    RecoveryLogger.LogRecovered(this.transactionId as XATransactionId);

                    // if server responds that nothing needs to be done, then reply prepared
                    // but clear the current state data so we appear done to the commit method.
                    preparingEnlistment.Prepared();

                    // Done so commit won't be called.
                    AfterCommit();
                }
                else
                {
                    Tracer.Debug("Transaction Prepare succeeded TX id: " + this.transactionId);

                    // If work finished correctly, reply prepared
                    preparingEnlistment.Prepared();
                }
            }
            catch (Exception ex)
            {
                Tracer.DebugFormat("Transaction[{0}] Prepare failed with error: {1}",
                                   this.transactionId, ex.Message);

                AfterRollback();
                preparingEnlistment.ForceRollback();
                try
                {
                    this.connection.OnException(ex);
                }
                catch (Exception error)
                {
                    Tracer.Error(error.ToString());
                }

                this.currentEnlistment = null;
                this.transactionId     = null;
            }
            finally
            {
                this.dtcControlEvent.Set();
            }
        }
 public void Prepare(PreparingEnlistment preparingEnlistment)
 {
     _callbacks.PrepareTransaction();
     // TODO: record prepared
     preparingEnlistment.Prepared();
 }
예제 #26
0
        public void Prepare(PreparingEnlistment preparingEnlistment)
        {
            lock (this.syncObject)
            {
                this.netTxState = TxState.Pending;

                try
                {
                    Tracer.Debug("Prepare notification received for TX id: " + this.transactionId);

                    BeforeEnd();

                    // Before sending the request to the broker, log the recovery bits, if
                    // this fails we can't prepare and the TX should be rolled back.
                    RecoveryLogger.LogRecoveryInfo(this.transactionId as XATransactionId,
                                                   preparingEnlistment.RecoveryInformation());

                    // Inform the broker that work on the XA'sh TX Branch is complete.
                    TransactionInfo info = new TransactionInfo();
                    info.ConnectionId  = this.connection.ConnectionId;
                    info.TransactionId = this.transactionId;
                    info.Type          = (int)TransactionType.End;

                    this.connection.CheckConnected();
                    this.connection.SyncRequest(info);

                    // Prepare the Transaction for commit.
                    info.Type = (int)TransactionType.Prepare;
                    IntegerResponse response = (IntegerResponse)this.connection.SyncRequest(info);
                    if (response.Result == XA_READONLY)
                    {
                        Tracer.Debug("Transaction Prepare done and doesn't need a commit, TX id: " + this.transactionId);

                        this.transactionId     = null;
                        this.currentEnlistment = null;

                        // Read Only means there's nothing to recover because there was no
                        // change on the broker.
                        RecoveryLogger.LogRecovered(this.transactionId as XATransactionId);

                        // if server responds that nothing needs to be done, then reply done.
                        // otherwise the DTC will call Commit or Rollback but another transaction
                        // can already be in progress and this one would be commited or rolled back
                        // immediately.
                        preparingEnlistment.Done();

                        // Done so commit won't be called.
                        AfterCommit();

                        // A Read-Only TX is considered closed at this point, DTC won't call us again.
                        this.dtcControlEvent.Set();
                    }
                    else
                    {
                        Tracer.Debug("Transaction Prepare succeeded TX id: " + this.transactionId);

                        // If work finished correctly, reply prepared
                        preparingEnlistment.Prepared();
                    }
                }
                catch (Exception ex)
                {
                    Tracer.DebugFormat("Transaction[{0}] Prepare failed with error: {1}",
                                       this.transactionId, ex.Message);

                    AfterRollback();
                    preparingEnlistment.ForceRollback();
                    try
                    {
                        this.connection.OnException(ex);
                    }
                    catch (Exception error)
                    {
                        Tracer.Error(error.ToString());
                    }

                    this.currentEnlistment = null;
                    this.transactionId     = null;
                    this.netTxState        = TxState.None;
                    this.dtcControlEvent.Set();
                }
            }
        }
예제 #27
0
 protected override void PrepareInternal(PreparingEnlistment preparingEnlistment)
 {
     _transaction = _db.Database.BeginTransaction();
     _db.Books.Add(_book);
     _db.SaveChanges();
 }
예제 #28
0
 public byte[] GetRecoveryInformation(PreparingEnlistment preparingEnlistment)
 {
     return(preparingEnlistment.RecoveryInformation());
 }
예제 #29
0
 void IEnlistmentNotification.Prepare(PreparingEnlistment enlistment)
 {
     OnPrepare(enlistment);
     enlistment.Prepared();
 }
 /// <summary>
 /// Responds to the Prepare notification.
 /// </summary>
 /// <param name="preparingEnlistment">An Enlistment that facilitates communication between the enlisted transaction participant and the transaction manager during the Prepare phase of the transaction.</param>
 public override void Prepare(PreparingEnlistment preparingEnlistment)
 {
     // Allow the base class to handle the Prepare notification.
     base.Prepare(preparingEnlistment);
 }
예제 #31
0
            public void Prepare(PreparingEnlistment preparingEnlistment)
            {
                if (_enlistDuringPrepare)
                {
                    Trace(string.Format("MyEnlistment.Prepare - attempting another enlistment with options {0}", _enlistOptions.ToString()));
                    try
                    {
                        MyEnlistment enlist2 = new MyEnlistment(
                            _secondEnlistmentCompleted,
                            /*votePrepared=*/ true,
                            /*enlistDuringPrepare=*/ false,
                            _enlistOptions);
                        this.TransactionToEnlist.EnlistVolatile(enlist2, _enlistOptions);
                        if (!_expectSuccessfulEnlist)
                        {
                            // Force rollback of the transaction because the second enlistment was unsuccessful.
                            Trace("MyEnlistment.Prepare - Force Rollback because second enlistment succeeded unexpectedly");
                            _aborted = true;
                            _outcomeReceived.Set();
                            preparingEnlistment.ForceRollback(new Exception("MyEnlistment voted ForceRollback"));
                            return;
                        }
                    }
                    catch (Exception ex)
                    {
                        if (_expectSuccessfulEnlist)
                        {
                            Trace(string.Format("MyEnlistment.Prepare - Force Rollback because second enlistment failed unexpectedly - {0}; {1}", ex.GetType().ToString(), ex.ToString()));
                            // Force rollback of the transaction because the second enlistment was unsuccessful.
                            _aborted = true;
                            _outcomeReceived.Set();
                            preparingEnlistment.ForceRollback(new Exception("MyEnlistment voted ForceRollback"));
                            return;
                        }
                    }
                }

                if (_votePrepared)
                {
                    Trace("MyEnlistment.Prepare voting Prepared");
                    preparingEnlistment.Prepared();
                }
                else
                {
                    Trace("MyEnlistment.Prepare - Force Rollback");
                    _aborted = true;
                    _outcomeReceived.Set();
                    preparingEnlistment.ForceRollback(new Exception("MyEnlistment voted ForceRollback"));
                }
            }
예제 #32
0
 public void Prepare(PreparingEnlistment preparingEnlistment)
 {
     byte[] recoveryInformation = preparingEnlistment.RecoveryInformation();
     database.PutStatic("transactions/recoveryInformation/" + txId, null, new MemoryStream(recoveryInformation), new RavenJObject());
     preparingEnlistment.Prepared();
 }
예제 #33
0
        public void Prepare(PreparingEnlistment preparingEnlistment)
        {
            resource.NumPrepare++;
            if (resource.IgnorePrepare)
                return;

            if (resource.FailPrepare)
            {
                if (resource.FailWithException)
                    preparingEnlistment.ForceRollback(resource.ThrowThisException ?? new NotSupportedException());
                else
                    preparingEnlistment.ForceRollback();
            }
            else
            {
                preparingEnlistment.Prepared();
            }
        }
예제 #34
0
        public void Prepare(PreparingEnlistment preparingEnlistment)
        {
            try
            {
                dtcControlEvent.Reset();

                Tracer.Debug("Prepare notification received for TX id: " + this.transactionId);

                BeforeEnd();

                // Before sending the request to the broker, log the recovery bits, if
                // this fails we can't prepare and the TX should be rolled back.
                RecoveryLogger.LogRecoveryInfo(this.transactionId as XATransactionId,
                                               preparingEnlistment.RecoveryInformation());

                // Inform the broker that work on the XA'sh TX Branch is complete.
                TransactionInfo info = new TransactionInfo();
                info.ConnectionId = this.connection.ConnectionId;
                info.TransactionId = this.transactionId;
                info.Type = (int) TransactionType.End;

                this.connection.CheckConnected();
                this.connection.SyncRequest(info);

                // Prepare the Transaction for commit.
                info.Type = (int) TransactionType.Prepare;
                IntegerResponse response = (IntegerResponse) this.connection.SyncRequest(info);
                if(response.Result == XA_READONLY)
                {
                    Tracer.Debug("Transaction Prepare done and doesn't need a commit, TX id: " + this.transactionId);

                    this.transactionId = null;
                    this.currentEnlistment = null;

                    // Read Only means there's nothing to recover because there was no
                    // change on the broker.
                    RecoveryLogger.LogRecovered(this.transactionId as XATransactionId);

                    // if server responds that nothing needs to be done, then reply prepared
                    // but clear the current state data so we appear done to the commit method.
                    preparingEnlistment.Prepared();

                    // Done so commit won't be called.
                    AfterCommit();
                }
                else
                {
                    Tracer.Debug("Transaction Prepare succeeded TX id: " + this.transactionId);

                    // If work finished correctly, reply prepared
                    preparingEnlistment.Prepared();
                }
            }
            catch(Exception ex)
            {
                Tracer.DebugFormat("Transaction[{0}] Prepare failed with error: {1}",
                                   this.transactionId, ex.Message);

                AfterRollback();
                preparingEnlistment.ForceRollback();
                try
                {
                    this.connection.OnException(ex);
                }
                catch (Exception error)
                {
                    Tracer.Error(error.ToString());
                }

                this.currentEnlistment = null;
                this.transactionId = null;
            }
            finally
            {
                this.dtcControlEvent.Set();
            }
        }