public virtual bool Equals(XATransactionId that) { if (!Equals(this.FormatId, that.FormatId)) { return(false); } if (!Equals(this.GlobalTransactionId, that.GlobalTransactionId)) { return(false); } if (!Equals(this.BranchQualifier, that.BranchQualifier)) { return(false); } return(true); }
public void LogRecoveryInfo(XATransactionId xid, byte[] recoveryInformation) { if (recoveryInformation == null || recoveryInformation.Length == 0) { return; } if (this.PreLogRecoveryInfoEvent != null) { this.PreLogRecoveryInfoEvent(xid, recoveryInformation); } this.containedLogger.LogRecoveryInfo(xid, recoveryInformation); if (this.PostLogRecoveryInfoEvent != null) { this.PostLogRecoveryInfoEvent(xid, recoveryInformation); } }
public void LogRecovered(XATransactionId xid) { if (this.PreLogRecoverdEvent != null) { this.PreLogRecoverdEvent(xid); } this.containedLogger.LogRecovered(xid); if (this.PostLogRecoverdEvent != null) { this.PostLogRecoverdEvent(xid); } }
public void FailOnPreLogRecoveryHook(XATransactionId xid, byte[] recoveryInformatio) { Tracer.Debug("Throwing Error before the Recovery Information is Logged."); throw new Exception("Intentional Error Logging Recovery Information"); }
public RecoveryInformation(XATransactionId xaId, byte[] recoveryInfo) { this.Xid = xaId; this.txRecoveryInfo = recoveryInfo; }
public void LogRecoveryInfo(XATransactionId xid, byte[] recoveryInformation) { if (recoveryInformation == null || recoveryInformation.Length == 0) { return; } try { lock (syncRoot) { RecoveryInformation info = new RecoveryInformation(xid, recoveryInformation); Tracer.Debug("Serializing Recovery Info to file: " + Filename); IFormatter formatter = new BinaryFormatter(); using (FileStream recoveryLog = new FileStream(Filename, FileMode.OpenOrCreate, FileAccess.Write)) { formatter.Serialize(recoveryLog, info); } } } catch (Exception ex) { Tracer.Error("Error while storing TX Recovery Info, message: " + ex.Message); throw; } }
public void LogRecovered(XATransactionId xid) { lock (syncRoot) { try { Tracer.Debug("Attempting to remove stale Recovery Info file: " + Filename); File.Delete(Filename); } catch(Exception ex) { Tracer.Debug("Caught Exception while removing stale RecoveryInfo file: " + ex.Message); return; } } }
public void Begin(Transaction transaction) { lock (syncObject) { this.netTxState = TxState.Active; dtcControlEvent.Reset(); Tracer.Debug("Begin notification received"); if (InNetTransaction) { throw new TransactionInProgressException("A Transaction is already in Progress"); } try { Guid rmId = ResourceManagerGuid; // Enlist this object in the transaction. this.currentEnlistment = transaction.EnlistDurable(rmId, this, EnlistmentOptions.None); Tracer.Debug("Enlisted in Durable Transaction with RM Id: " + rmId); TransactionInformation txInfo = transaction.TransactionInformation; XATransactionId xaId = new XATransactionId(); this.transactionId = xaId; if (txInfo.DistributedIdentifier != Guid.Empty) { xaId.GlobalTransactionId = txInfo.DistributedIdentifier.ToByteArray(); xaId.BranchQualifier = Encoding.UTF8.GetBytes(Guid.NewGuid().ToString()); } else { xaId.GlobalTransactionId = Encoding.UTF8.GetBytes(txInfo.LocalIdentifier); xaId.BranchQualifier = Encoding.UTF8.GetBytes(Guid.NewGuid().ToString()); } // Now notify the broker that a new XA'ish transaction has started. TransactionInfo info = new TransactionInfo(); info.ConnectionId = this.connection.ConnectionId; info.TransactionId = this.transactionId; info.Type = (int) TransactionType.Begin; this.session.Connection.Oneway(info); if (Tracer.IsDebugEnabled) { Tracer.Debug("Began XA'ish Transaction:" + xaId.GlobalTransactionId.ToString()); } } catch (Exception) { dtcControlEvent.Set(); throw; } } }
public void TestRecoverLoggedRecord() { RecoveryFileLogger logger = new RecoveryFileLogger(); byte[] globalId = new byte[32]; byte[] branchQ = new byte[32]; byte[] recoveryData = new byte[256]; Random gen = new Random(); gen.NextBytes(globalId); gen.NextBytes(branchQ); gen.NextBytes(recoveryData); logger.Location = nonDefaultLogLocation; logger.Initialize(rmId.ToString()); XATransactionId xid = new XATransactionId(); xid.GlobalTransactionId = globalId; xid.BranchQualifier = branchQ; logger.LogRecoveryInfo(xid, recoveryData); Assert.IsTrue(File.Exists(logger.Location + Path.DirectorySeparatorChar + rmId.ToString() + ".bin"), "Recovery File was not created"); Assert.IsTrue(logger.GetRecoverables().Length == 1, "Did not recover the logged record."); KeyValuePair<XATransactionId, byte[]>[] records = logger.GetRecoverables(); Assert.AreEqual(1, records.Length); Assert.AreEqual(globalId, records[0].Key.GlobalTransactionId, "Incorrect Global TX Id returned"); Assert.AreEqual(branchQ, records[0].Key.BranchQualifier, "Incorrect Branch Qualifier returned"); Assert.AreEqual(recoveryData, records[0].Value, "Incorrect Recovery Information returned"); }
public void TestPurgeTransactionRecord() { RecoveryFileLogger logger = new RecoveryFileLogger(); byte[] globalId = new byte[32]; byte[] branchQ = new byte[32]; byte[] recoveryData = new byte[256]; Random gen = new Random(); gen.NextBytes(globalId); gen.NextBytes(branchQ); gen.NextBytes(recoveryData); logger.Location = nonDefaultLogLocation; logger.Initialize(rmId.ToString()); XATransactionId xid = new XATransactionId(); xid.GlobalTransactionId = globalId; xid.BranchQualifier = branchQ; logger.LogRecoveryInfo(xid, recoveryData); Assert.IsTrue(File.Exists(logger.Location + Path.DirectorySeparatorChar + rmId.ToString() + ".bin"), "Recovery File was not created"); logger.Purge(); Assert.IsFalse(File.Exists(logger.Location + Path.DirectorySeparatorChar + rmId.ToString() + ".bin"), "Recovery File was not created"); }