private void StopListeners() { DebugTrace.TraceEnter(this, "StopListeners"); if (this.twoPhaseCommitCoordinatorListener != null) { this.twoPhaseCommitCoordinatorListener.Stop(); this.twoPhaseCommitCoordinatorListener = null; } if (this.twoPhaseCommitParticipantListener != null) { this.twoPhaseCommitParticipantListener.Stop(); this.twoPhaseCommitParticipantListener = null; } if (this.completionCoordinatorListener != null) { this.completionCoordinatorListener.Stop(); this.completionCoordinatorListener = null; } if (this.registrationCoordinatorListener != null) { this.registrationCoordinatorListener.Stop(); this.registrationCoordinatorListener = null; } if (this.activationCoordinatorListener != null) { this.activationCoordinatorListener.Stop(); this.activationCoordinatorListener = null; } if (this.coordination != null) { this.coordination.Cleanup(); this.coordination = null; } DebugTrace.TraceLeave(this, "StopListeners"); }
public void Add(ITimerRecipient recipient, object token) { int count; DebugTrace.TraceEnter(this, "Add"); TimeSpan span = recipient.NextNotification - this.state.ElapsedTime; if ((span <= TimeSpan.Zero) || (span >= this.maxNotificationTime)) { DiagnosticUtility.FailFast("The timer object has an invalid notification time"); } lock (this.timerList.SyncRoot) { this.AssertState(); this.timerList.Add(recipient, token); count = this.timerList.Count; if (count == 1) { this.ActivateTimer(); } } if (DebugTrace.Verbose) { DebugTrace.Trace(TraceLevel.Verbose, "Added timer recipient to be reminded in {0} ms", (long)span.TotalMilliseconds); DebugTrace.Trace(TraceLevel.Verbose, "Timer list depth at {0}", count); } DebugTrace.TraceLeave(this, "Add"); }
public void Rejoin(Enlistment enlistment, ProtocolProviderCallback callback, object obj) { DebugTrace.TraceEnter(this, "Rejoin"); ParticipantEnlistment participant = null; try { participant = this.state.LogEntrySerialization.DeserializeParticipant(enlistment); } catch (SerializationException exception) { DiagnosticUtility.ExceptionUtility.TraceHandledException(exception, TraceEventType.Critical); if (DebugTrace.Error) { DebugTrace.Trace(TraceLevel.Error, "Failed to deserialize log entry for participant: {0}", exception); } ParticipantRecoveryLogEntryCorruptRecord.TraceAndLog(enlistment.LocalTransactionId, enlistment.RemoteTransactionId, enlistment.GetRecoveryData(), exception); DiagnosticUtility.FailFast("A participant recovery log entry could not be deserialized. This is a fatal condition."); } if (ParticipantRecoveredRecord.ShouldTrace) { ParticipantRecoveredRecord.Trace(participant.EnlistmentId, participant.Enlistment.RemoteTransactionId, (participant.ParticipantProxy != null) ? participant.ParticipantProxy.To : null, this.state.ProtocolVersion); } participant.StateMachine.Enqueue(new TmRejoinEvent(participant, callback, obj)); DebugTrace.TraceLeave(this, "Rejoin"); }
private void StartListeners() { DebugTrace.TraceEnter(this, "StartListeners"); try { this.twoPhaseCommitCoordinatorListener.Start(); this.twoPhaseCommitParticipantListener.Start(); this.completionCoordinatorListener.Start(); this.registrationCoordinatorListener.Start(); this.activationCoordinatorListener.Start(); } catch (MessagingInitializationException exception) { if (DebugTrace.Error) { DebugTrace.Trace(TraceLevel.Error, "Error starting a listener: {0}", exception); } this.CleanupOnFailure(); throw Microsoft.Transactions.Bridge.DiagnosticUtility.ExceptionUtility.ThrowHelperError(new PluggableProtocolException(exception.Message, exception)); } catch (Exception exception2) { Microsoft.Transactions.Bridge.DiagnosticUtility.ExceptionUtility.TraceHandledException(exception2, TraceEventType.Error); if (DebugTrace.Error) { DebugTrace.Trace(TraceLevel.Error, "Unknown exception starting a listener: {0}", exception2); } this.CleanupOnFailure(); throw; } DebugTrace.TraceLeave(this, "StartListeners"); }
public void Replay(Enlistment enlistment, ProtocolProviderCallback callback, object obj) { DebugTrace.TraceEnter(this, "Replay"); CoordinatorEnlistment coordinator = null; try { coordinator = this.state.LogEntrySerialization.DeserializeCoordinator(enlistment); } catch (SerializationException exception) { DiagnosticUtility.ExceptionUtility.TraceHandledException(exception, TraceEventType.Critical); if (DebugTrace.Error) { DebugTrace.Trace(TraceLevel.Error, "Failed to deserialize log entry for coordinator: {0}", exception); } CoordinatorRecoveryLogEntryCorruptRecord.TraceAndLog(enlistment.LocalTransactionId, enlistment.RemoteTransactionId, enlistment.GetRecoveryData(), exception); DiagnosticUtility.FailFast("A coordinator recovery log entry could not be deserialized. This is a fatal condition."); } if (CoordinatorRecoveredRecord.ShouldTrace) { CoordinatorRecoveredRecord.Trace(coordinator.EnlistmentId, coordinator.Enlistment.RemoteTransactionId, (coordinator.CoordinatorProxy != null) ? coordinator.CoordinatorProxy.To : null, this.state.ProtocolVersion); } coordinator.StateMachine.Enqueue(new TmReplayEvent(coordinator, callback, obj)); DebugTrace.TraceLeave(this, "Replay"); }
public void Remove(ITimerRecipient recipient) { int count; int num2; DebugTrace.TraceEnter(this, "Remove"); lock (this.timerList.SyncRoot) { this.AssertState(); count = this.timerList.Count; this.timerList.Remove(recipient); num2 = this.timerList.Count; if ((count != num2) && (this.timerList.Count == 0)) { this.DeactivateTimer(); } } if (DebugTrace.Verbose) { if (count == num2) { DebugTrace.Trace(TraceLevel.Verbose, "Timer recipient was not present. Timer list depth is still {0}", num2); } else { DebugTrace.Trace(TraceLevel.Verbose, "Removed timer recipient. Timer list depth is now {0}", num2); } } DebugTrace.TraceLeave(this, "Remove"); }
public void RecoveryBeginning() { DebugTrace.TraceEnter(this, "RecoveryBeginning"); if (this.config.NetworkEndpointsEnabled) { try { this.coordination = new CoordinationService(this.config.PortConfiguration, this.protocolVersion); this.activationCoordinatorListener = this.coordination.Add(this.activationCoordinator); this.registrationCoordinatorListener = this.coordination.Add(this.registrationCoordinator); this.completionCoordinatorListener = this.coordination.Add(this.completionCoordinator); this.twoPhaseCommitCoordinatorListener = this.coordination.Add(this.twoPhaseCommitCoordinator); this.twoPhaseCommitParticipantListener = this.coordination.Add(this.twoPhaseCommitParticipant); } catch (MessagingInitializationException exception) { if (DebugTrace.Error) { DebugTrace.Trace(TraceLevel.Error, "Error initializing CoordinationService: {0}", exception); } this.CleanupOnFailure(); throw Microsoft.Transactions.Bridge.DiagnosticUtility.ExceptionUtility.ThrowHelperError(new PluggableProtocolException(exception.Message, exception)); } catch (Exception exception2) { if (DebugTrace.Error) { DebugTrace.Trace(TraceLevel.Error, "Unknown exception initializing CoordinationService: {0}", exception2); } this.CleanupOnFailure(); throw; } } DebugTrace.TraceLeave(this, "RecoveryBeginning"); }
public Configuration(ProtocolState state) { DebugTrace.TraceEnter(this, "Configuration"); this.state = state; this.overrideSection = this.GetOverrideSectionConfiguration(); using (ConfigurationProvider provider = this.GetConfigurationProvider()) { this.ReadDiagnosticTracingConfiguration(provider); this.ReadTimeoutConfiguration(provider); this.ReadTimerPolicyConfiguration(provider); this.ReadPortConfiguration(provider); } this.TraceConfiguration(); DebugTrace.TraceLeave(this, "Configuration"); }
public override byte[] GetProtocolInformation() { DebugTrace.TraceEnter(this, "GetProtocolInformation"); byte[] protocolInformation = null; if (base.state.Config.NetworkEndpointsEnabled) { DebugTrace.Trace(TraceLevel.Verbose, "Generating protocol information"); protocolInformation = new ProtocolInformationWriter(base.state).GetProtocolInformation(); } else { DebugTrace.Trace(TraceLevel.Verbose, "Generating null protocol information"); } DebugTrace.TraceLeave(this, "GetProtocolInformation"); return(protocolInformation); }
public void RecoveryBeginning() { DebugTrace.TraceEnter(this, "RecoveryBeginning"); try { this.state.RecoveryBeginning(); } catch (Exception exception) { DebugTrace.Trace(TraceLevel.Error, "RecoveryBeginning failed: {0}", exception); ProtocolRecoveryBeginningFailureRecord.TraceAndLog(PluggableProtocol.Id(this.state.ProtocolVersion), PluggableProtocol.Name(this.state.ProtocolVersion), exception); throw; } finally { DebugTrace.TraceLeave(this, "RecoveryBeginning"); } }
public void RecoveryComplete() { DebugTrace.TraceEnter(this, "RecoveryComplete"); if (this.config.NetworkEndpointsEnabled) { this.StartListeners(); } lock (this.recoveryLock) { this.recovering = false; this.ProcessPendingRecoveryEvents(); if (this.recoveryQueue.Count != 0) { Microsoft.Transactions.Bridge.DiagnosticUtility.FailFast("Recovery queue should be empty"); } this.recoveryQueue = null; } DebugTrace.TraceLeave(this, "RecoveryComplete"); }
public void Stop() { DebugTrace.TraceEnter(this, "Stop"); try { this.protocolProviderState = ProtocolProviderState.Stopping; this.state.Stop(); this.protocolProviderState = ProtocolProviderState.Stopped; ProtocolStoppedRecord.TraceAndLog(this.protocolId, this.name); } catch (Exception exception) { DebugTrace.Trace(TraceLevel.Error, "Could not stop protocol: {0}", exception); ProtocolStopFailureRecord.TraceAndLog(this.protocolId, this.name, exception); throw; } finally { DebugTrace.TraceLeave(this, "Stop"); } }
private void ProcessPendingRecoveryEvents() { DebugTrace.TraceEnter(this, "ProcessPendingRecoveryEvents"); if (this.recovering) { Microsoft.Transactions.Bridge.DiagnosticUtility.FailFast("Cannot process recovery events while recovering"); } if (this.recoveryQueue.Count == 0) { DebugTrace.Trace(TraceLevel.Verbose, "No events were queued during recovery"); } else { DebugTrace.Trace(TraceLevel.Verbose, "Processing events queued during recovery"); while (this.recoveryQueue.Count > 0) { SynchronizationEvent e = this.recoveryQueue.Dequeue(); e.Enlistment.StateMachine.Enqueue(e); } } DebugTrace.TraceLeave(this, "ProcessPendingRecoveryEvents"); }
public void Initialize(TransactionManager transactionManager) { DebugTrace.TraceEnter(this, "Initialize"); try { this.state = new ProtocolState(transactionManager, this.protocolVersion); this.protocolProviderState = ProtocolProviderState.Initialized; if (ProtocolInitializedRecord.ShouldTrace) { ProtocolInitializedRecord.Trace(this.protocolId, this.name); } } catch (Exception exception) { DebugTrace.Trace(TraceLevel.Error, "Could not initialize protocol: {0}", exception); ProtocolInitializationFailureRecord.TraceAndLog(this.protocolId, this.name, exception); throw; } finally { DebugTrace.TraceLeave(this, "Initialize"); } }
private void ExecuteTimer() { DebugTrace.TraceEnter(this, "OnTimer"); ArrayList list = null; TimeSpan elapsedTime = this.state.ElapsedTime; lock (this.timerList.SyncRoot) { int count = this.timerList.Count; DebugTrace.Trace(TraceLevel.Verbose, "Timer list depth at {0}", count); for (int i = count - 1; i >= 0; i--) { ITimerRecipient key = (ITimerRecipient)this.timerList.GetKey(i); TimeSpan span2 = key.NextNotification - elapsedTime; if (span2 > this.reminderTolerance) { if (DebugTrace.Verbose) { DebugTrace.Trace(TraceLevel.Verbose, "Timer list found entry scheduled for {0} ms in the future", (long)span2.TotalMilliseconds); } break; } if (DebugTrace.Verbose) { DebugTrace.Trace(TraceLevel.Verbose, "Timer list dispatching to recipient scheduled for {0} ms in the {1}", (long)span2.Duration().TotalMilliseconds, (span2 > TimeSpan.Zero) ? "future" : "past"); } object byIndex = this.timerList.GetByIndex(i); this.timerList.RemoveAt(i); if (list == null) { list = new ArrayList(0x20); } list.Add(key); list.Add(byIndex); } if ((list != null) && (this.timerList.Count == 0)) { this.DeactivateTimer(); } } if (list != null) { int num3 = list.Count; if ((num3 % 2) != 0) { DiagnosticUtility.FailFast("Recipient list count must be even"); } if (DebugTrace.Verbose) { int num4 = num3 / 2; DebugTrace.Trace(TraceLevel.Verbose, "Dispatching timer notification to {0} recipient{1}", num4, (num4 != 1) ? "s" : string.Empty); } for (int j = 0; j < num3; j += 2) { ITimerRecipient recipient2 = (ITimerRecipient)list[j]; object token = list[j + 1]; recipient2.OnTimerNotification(token); } } DebugTrace.TraceLeave(this, "OnTimer"); }
protected override void SerializeExtended() { Guid guid; DebugTrace.TraceEnter(this, "SerializeExtended"); WsATv1LogEntryFlags flags = 0; WsATv1LogEntryFlags pathFlags = 0; EndpointAddress endpoint = base.logEntry.Endpoint; Uri uri = endpoint.Uri; if (GetRemoteEnlistmentId(endpoint, out guid)) { flags = (WsATv1LogEntryFlags)((byte)(flags | WsATv1LogEntryFlags.OptimizedEndpointRepresentation)); if (string.Compare(uri.Scheme, Uri.UriSchemeHttps, StringComparison.OrdinalIgnoreCase) != 0) { Microsoft.Transactions.Bridge.DiagnosticUtility.FailFast("Endpoints must use the HTTPS scheme"); } if (0x944 == uri.Port) { flags = (WsATv1LogEntryFlags)((byte)(flags | WsATv1LogEntryFlags.UsesDefaultPort)); } pathFlags = GetPathFlags(endpoint, this.protocolVersion); flags = (WsATv1LogEntryFlags)((byte)(flags | pathFlags)); } if (DebugTrace.Verbose) { DebugTrace.Trace(TraceLevel.Verbose, "SerializeExtended flags: {0}", flags); } byte num = 0; ProtocolVersionHelper.AssertProtocolVersion(this.protocolVersion, base.GetType(), "SerializeExtended"); switch (this.protocolVersion) { case ProtocolVersion.Version10: num = 1; break; case ProtocolVersion.Version11: num = 2; break; } base.mem.WriteByte(num); if (DebugTrace.Verbose) { DebugTrace.Trace(TraceLevel.Verbose, "Wrote version: {0} bytes", base.mem.Length); } base.mem.WriteByte((byte)flags); if (DebugTrace.Verbose) { DebugTrace.Trace(TraceLevel.Verbose, "Wrote flags: {0} bytes", base.mem.Length); } if (((byte)(flags & WsATv1LogEntryFlags.OptimizedEndpointRepresentation)) == 0) { SerializationUtils.WriteEndpointAddress(base.mem, endpoint, this.protocolVersion); } else { SerializationUtils.WriteGuid(base.mem, ref guid); if (DebugTrace.Verbose) { DebugTrace.Trace(TraceLevel.Verbose, "Wrote enlistmentId: {0} bytes", base.mem.Length); } SerializationUtils.WriteString(base.mem, uri.Host); if (DebugTrace.Verbose) { DebugTrace.Trace(TraceLevel.Verbose, "Wrote hostName: {0} bytes", base.mem.Length); } if (((byte)(flags & WsATv1LogEntryFlags.UsesDefaultPort)) == 0) { if ((uri.Port < 0) || (uri.Port > 0xffff)) { Microsoft.Transactions.Bridge.DiagnosticUtility.FailFast("TCP port must be valid"); } SerializationUtils.WriteInt(base.mem, uri.Port); if (DebugTrace.Verbose) { DebugTrace.Trace(TraceLevel.Verbose, "Wrote port: {0} bytes", base.mem.Length); } } if (((int)pathFlags) == 0) { SerializationUtils.WriteString(base.mem, uri.AbsolutePath); if (DebugTrace.Verbose) { DebugTrace.Trace(TraceLevel.Verbose, "Wrote address path: {0} bytes", base.mem.Length); } } } DebugTrace.TraceLeave(this, "DeserializeExtended"); }
protected override void DeserializeExtended() { DebugTrace.TraceEnter(this, "DeserializeExtended"); WsATv1LogEntryVersion version = (WsATv1LogEntryVersion)SerializationUtils.ReadByte(base.mem); if (!Enum.IsDefined(typeof(WsATv1LogEntryVersion), version)) { Microsoft.Transactions.Bridge.DiagnosticUtility.FailFast("Unsupported WsATv1LogEntryVersion"); } WsATv1LogEntryFlags flags = (WsATv1LogEntryFlags)SerializationUtils.ReadByte(base.mem); if (DebugTrace.Verbose) { DebugTrace.Trace(TraceLevel.Verbose, "DeserializeExtended flags: {0}", flags); } this.CheckFlags(flags); if (((byte)(flags & WsATv1LogEntryFlags.OptimizedEndpointRepresentation)) == 0) { base.entry.Endpoint = SerializationUtils.ReadEndpointAddress(base.mem, this.protocolVersion); if (DebugTrace.Verbose) { DebugTrace.Trace(TraceLevel.Verbose, "Read endpoint address: {0}", base.entry.Endpoint.Uri); } } else { int num; string str2; Guid guid = SerializationUtils.ReadGuid(base.mem); if (DebugTrace.Verbose) { DebugTrace.Trace(TraceLevel.Verbose, "Read remote EnlistmentId: {0}", guid); } string str = SerializationUtils.ReadString(base.mem); if (DebugTrace.Verbose) { DebugTrace.Trace(TraceLevel.Verbose, "Read hostName: {0}", str); } if (((byte)(flags & WsATv1LogEntryFlags.UsesDefaultPort)) != 0) { num = 0x944; } else { num = SerializationUtils.ReadInt(base.mem); if (DebugTrace.Verbose) { DebugTrace.Trace(TraceLevel.Verbose, "Read port: {0}", num); } } if (((byte)(flags & WsATv1LogEntryFlags.UsesStandardCoordinatorAddressPath)) != 0) { str2 = WsATv1LogEntrySerializer.StandardCoordinatorAddressPath(this.protocolVersion); } else if (((byte)(flags & WsATv1LogEntryFlags.UsesStandardParticipantAddressPath)) != 0) { str2 = WsATv1LogEntrySerializer.StandardParticipantAddressPath(this.protocolVersion); } else { str2 = SerializationUtils.ReadString(base.mem); if (DebugTrace.Verbose) { DebugTrace.Trace(TraceLevel.Verbose, "Read address path: {0}", str2); } } UriBuilder builder = new UriBuilder(Uri.UriSchemeHttps, str, num, str2); EnlistmentHeader header = new EnlistmentHeader(guid, ControlProtocol.Durable2PC); base.entry.Endpoint = new EndpointAddress(builder.Uri, new AddressHeader[] { header }); } DebugTrace.TraceLeave(this, "DeserializeExtended"); }
public override byte[] GetProtocolInformation() { DebugTrace.TraceEnter(this, "GetProtocolInformation"); DebugTrace.TraceLeave(this, "GetProtocolInformation"); return(null); }
public void Start() { DebugTrace.TraceEnter(this, "Start"); DebugTrace.TraceLeave(this, "Start"); }
public void Stop() { DebugTrace.TraceEnter(this, "Stop"); this.StopListeners(); DebugTrace.TraceLeave(this, "Stop"); }