static public void RecoveryComplete( Guid resourceManagerIdentifier ) { if (resourceManagerIdentifier == Guid.Empty) { throw new ArgumentException(SR.GetString(SR.BadResourceManagerId), "resourceManagerIdentifier"); } if (DiagnosticTrace.Verbose) { MethodEnteredTraceRecord.Trace(SR.GetString(SR.TraceSourceBase), "TransactionManager.RecoveryComplete" ); } if (DiagnosticTrace.Information) { RecoveryCompleteTraceRecord.Trace(SR.GetString(SR.TraceSourceBase), resourceManagerIdentifier ); } DistributedTransactionManager.ResourceManagerRecoveryComplete(resourceManagerIdentifier); if (DiagnosticTrace.Verbose) { MethodExitedTraceRecord.Trace(SR.GetString(SR.TraceSourceBase), "TransactionManager.RecoveryComplete" ); } }
public static Transaction GetTransactionFromExportCookie(byte[] cookie) { if (null == cookie) { throw new ArgumentNullException(nameof(cookie)); } if (cookie.Length < 32) { throw new ArgumentException(SR.InvalidArgument, nameof(cookie)); } TransactionsEtwProvider etwLog = TransactionsEtwProvider.Log; if (etwLog.IsEnabled()) { etwLog.MethodEnter(TraceSourceType.TraceSourceDistributed, "TransactionInterop.GetTransactionFromExportCookie"); } var cookieCopy = new byte[cookie.Length]; Buffer.BlockCopy(cookie, 0, cookieCopy, 0, cookie.Length); cookie = cookieCopy; // Extract the transaction guid from the propagation token to see if we already have a // transaction object for the transaction. byte[] guidByteArray = new byte[16]; for (int i = 0; i < guidByteArray.Length; i++) { // In a cookie, the transaction guid is preceeded by a signature guid. guidByteArray[i] = cookie[i + 16]; } Guid txId = new Guid(guidByteArray); // First check to see if there is a promoted LTM transaction with the same ID. If there // is, just return that. Transaction transaction = TransactionManager.FindPromotedTransaction(txId); if (transaction != null) { if (etwLog.IsEnabled()) { etwLog.MethodExit(TraceSourceType.TraceSourceDistributed, "TransactionInterop.GetTransactionFromExportCookie"); } return(transaction); } // Find or create the promoted transaction. DistributedTransaction dTx = DistributedTransactionManager.GetTransactionFromExportCookie(cookieCopy, txId); transaction = TransactionManager.FindOrCreatePromotedTransaction(txId, dTx); if (etwLog.IsEnabled()) { etwLog.MethodExit(TraceSourceType.TraceSourceDistributed, "TransactionInterop.GetTransactionFromExportCookie"); } return(transaction); }
private static DistributedTransactionManager CheckTransactionManager(string?nodeName) { DistributedTransactionManager tm = DistributedTransactionManager; if (!((tm.NodeName == null && (nodeName == null || nodeName.Length == 0)) || (tm.NodeName != null && tm.NodeName.Equals(nodeName)))) { throw new ArgumentException(SR.InvalidRecoveryInformation, "recoveryInformation"); } return(tm); }
internal static DistributedTransaction GetDistributedTransactionFromTransmitterPropagationToken(byte[] propagationToken) { ArgumentNullException.ThrowIfNull(propagationToken); if (propagationToken.Length < 24) { throw new ArgumentException(SR.InvalidArgument, nameof(propagationToken)); } byte[] propagationTokenCopy = new byte[propagationToken.Length]; Array.Copy(propagationToken, propagationTokenCopy, propagationToken.Length); return(DistributedTransactionManager.GetDistributedTransactionFromTransmitterPropagationToken(propagationTokenCopy)); }
public static byte[] GetWhereabouts() { TransactionsEtwProvider etwLog = TransactionsEtwProvider.Log; if (etwLog.IsEnabled()) { etwLog.MethodEnter(TraceSourceType.TraceSourceDistributed, "TransactionInterop.GetWhereabouts"); } byte[] returnValue = DistributedTransactionManager.GetWhereabouts(); if (etwLog.IsEnabled()) { etwLog.MethodExit(TraceSourceType.TraceSourceDistributed, "TransactionInterop.GetWhereabouts"); } return(returnValue); }
public static byte[] GetWhereabouts() { if (DiagnosticTrace.Verbose) { MethodEnteredTraceRecord.Trace(SR.TraceSourceDistributed, "TransactionInterop.GetWhereabouts"); } DistributedTransactionManager dTm = TransactionManager.DistributedTransactionManager; byte[] returnValue = dTm.GetWhereabouts(); if (DiagnosticTrace.Verbose) { MethodExitedTraceRecord.Trace(SR.TraceSourceDistributed, "TransactionInterop.GetWhereabouts"); } return(returnValue); }
public static Transaction GetTransactionFromDtcTransaction(IDtcTransaction transactionNative) { ArgumentNullException.ThrowIfNull(transactionNative); TransactionsEtwProvider etwLog = TransactionsEtwProvider.Log; if (etwLog.IsEnabled()) { etwLog.MethodEnter(TraceSourceType.TraceSourceDistributed, "TransactionInterop.GetTransactionFromDtcTransaction"); } Transaction transaction = DistributedTransactionManager.GetTransactionFromDtcTransaction(transactionNative); if (etwLog.IsEnabled()) { etwLog.MethodExit(TraceSourceType.TraceSourceDistributed, "TransactionInterop.GetTransactionFromDtcTransaction"); } return(transaction); }
public static Transaction GetTransactionFromDtcTransaction(IDtcTransaction transactionNative) { if (null == transactionNative) { throw new ArgumentNullException(nameof(transactionNative)); } if (DiagnosticTrace.Verbose) { MethodEnteredTraceRecord.Trace(SR.TraceSourceDistributed, "TransactionInterop.GetTransactionFromDtc"); } Transaction transaction = DistributedTransactionManager.GetTransactionFromDtcTransaction(transactionNative); if (DiagnosticTrace.Verbose) { MethodExitedTraceRecord.Trace(SR.TraceSourceDistributed, "TransactionInterop.GetTransactionFromDtc"); } return(transaction); }
public static void RecoveryComplete(Guid resourceManagerIdentifier) { if (resourceManagerIdentifier == Guid.Empty) { throw new ArgumentException(SR.BadResourceManagerId, nameof(resourceManagerIdentifier)); } TransactionsEtwProvider etwLog = TransactionsEtwProvider.Log; if (etwLog.IsEnabled()) { etwLog.MethodEnter(TraceSourceType.TraceSourceBase, "TransactionManager.RecoveryComplete"); etwLog.TransactionManagerRecoveryComplete(resourceManagerIdentifier); } DistributedTransactionManager.ResourceManagerRecoveryComplete(resourceManagerIdentifier); if (etwLog.IsEnabled()) { etwLog.MethodExit(TraceSourceType.TraceSourceBase, "TransactionManager.RecoveryComplete"); } }
public static Enlistment Reenlist( Guid resourceManagerIdentifier, byte[] recoveryInformation, IEnlistmentNotification enlistmentNotification) { if (resourceManagerIdentifier == Guid.Empty) { throw new ArgumentException(SR.BadResourceManagerId, nameof(resourceManagerIdentifier)); } if (null == recoveryInformation) { throw new ArgumentNullException(nameof(recoveryInformation)); } if (null == enlistmentNotification) { throw new ArgumentNullException(nameof(enlistmentNotification)); } TransactionsEtwProvider etwLog = TransactionsEtwProvider.Log; if (etwLog.IsEnabled()) { etwLog.MethodEnter(TraceSourceType.TraceSourceBase, "TransactionManager.Reenlist"); etwLog.TransactionManagerReenlist(resourceManagerIdentifier); } // Put the recovery information into a stream. MemoryStream stream = new MemoryStream(recoveryInformation); int recoveryInformationVersion = 0; string? nodeName = null; byte[]? resourceManagerRecoveryInformation = null; try { BinaryReader reader = new BinaryReader(stream); recoveryInformationVersion = reader.ReadInt32(); if (recoveryInformationVersion == TransactionManager.RecoveryInformationVersion1) { nodeName = reader.ReadString(); resourceManagerRecoveryInformation = reader.ReadBytes(recoveryInformation.Length - checked ((int)stream.Position)); } else { if (etwLog.IsEnabled()) { etwLog.TransactionExceptionTrace(TraceSourceType.TraceSourceBase, TransactionExceptionType.UnrecognizedRecoveryInformation, nameof(recoveryInformation), string.Empty); } throw new ArgumentException(SR.UnrecognizedRecoveryInformation, nameof(recoveryInformation)); } } catch (EndOfStreamException e) { if (etwLog.IsEnabled()) { etwLog.TransactionExceptionTrace(TraceSourceType.TraceSourceBase, TransactionExceptionType.UnrecognizedRecoveryInformation, nameof(recoveryInformation), e.ToString()); } throw new ArgumentException(SR.UnrecognizedRecoveryInformation, nameof(recoveryInformation), e); } catch (FormatException e) { if (etwLog.IsEnabled()) { etwLog.TransactionExceptionTrace(TraceSourceType.TraceSourceBase, TransactionExceptionType.UnrecognizedRecoveryInformation, nameof(recoveryInformation), e.ToString()); } throw new ArgumentException(SR.UnrecognizedRecoveryInformation, nameof(recoveryInformation), e); } finally { stream.Dispose(); } DistributedTransactionManager transactionManager = CheckTransactionManager(nodeName); // Now ask the Transaction Manager to reenlist. object syncRoot = new object(); Enlistment returnValue = new Enlistment(enlistmentNotification, syncRoot); EnlistmentState.EnlistmentStatePromoted.EnterState(returnValue.InternalEnlistment); returnValue.InternalEnlistment.PromotedEnlistment = transactionManager.ReenlistTransaction( resourceManagerIdentifier, resourceManagerRecoveryInformation, (RecoveringInternalEnlistment)returnValue.InternalEnlistment ); if (etwLog.IsEnabled()) { etwLog.MethodExit(TraceSourceType.TraceSourceBase, "TransactionManager.Reenlist"); } return(returnValue); }