コード例 #1
0
 public void SendRollback(EndpointAddress sendTo)
 {
     if (sendTo != null)
     {
         TwoPhaseCommitParticipantProxy proxy = this.state.TryCreateTwoPhaseCommitParticipantProxy(sendTo);
         if (proxy != null)
         {
             try
             {
                 if (DebugTrace.Info)
                 {
                     DebugTrace.Trace(TraceLevel.Info, "Sending Rollback to unrecognized participant at {0}", Ports.TryGetAddress(proxy));
                 }
                 proxy.From = this.CreateForgottenSource();
                 IAsyncResult ar = proxy.BeginSendRollback(this.politeSendComplete, proxy);
                 if (ar.CompletedSynchronously)
                 {
                     this.OnPoliteSendComplete(ar, proxy);
                 }
             }
             finally
             {
                 proxy.Release();
             }
         }
     }
 }
コード例 #2
0
 private void OnPoliteSendComplete(IAsyncResult ar, TwoPhaseCommitParticipantProxy proxy)
 {
     try
     {
         proxy.EndSendMessage(ar);
     }
     catch (WsatSendFailureException exception)
     {
         Microsoft.Transactions.Bridge.DiagnosticUtility.ExceptionUtility.TraceHandledException(exception, TraceEventType.Warning);
         DebugTrace.TraceSendFailure(exception);
         this.state.Perf.MessageSendFailureCountPerInterval.Increment();
     }
 }
コード例 #3
0
        public ParticipantEnlistment(ProtocolState state, WsatRegistrationHeader header, Microsoft.Transactions.Wsat.Messaging.ControlProtocol protocol, TwoPhaseCommitParticipantProxy proxy) : base(state)
        {
            this.protocol = protocol;
            proxy.AddRef();
            this.participantProxy = proxy;
            this.ConfigureEnlistment(header);
            this.CreateCoordinatorService();
            switch (protocol)
            {
            case Microsoft.Transactions.Wsat.Messaging.ControlProtocol.Volatile2PC:
                base.stateMachine = new VolatileStateMachine(this);
                base.stateMachine.ChangeState(state.States.VolatileRegistering);
                return;

            case Microsoft.Transactions.Wsat.Messaging.ControlProtocol.Durable2PC:
                base.stateMachine = new DurableStateMachine(this);
                base.stateMachine.ChangeState(state.States.DurableRegistering);
                return;
            }
            Microsoft.Transactions.Bridge.DiagnosticUtility.FailFast("Invalid protocol");
        }
コード例 #4
0
 public ParticipantEnlistment(ProtocolState state, Enlistment enlistment, Guid enlistmentId, EndpointAddress service) : base(state, enlistmentId)
 {
     base.enlistment = enlistment;
     base.enlistment.ProtocolProviderContext = this;
     this.protocol         = Microsoft.Transactions.Wsat.Messaging.ControlProtocol.Durable2PC;
     base.stateMachine     = new DurableStateMachine(this);
     this.participantProxy = state.TryCreateTwoPhaseCommitParticipantProxy(service);
     if (this.participantProxy == null)
     {
         if (RecoveredParticipantInvalidMetadataRecord.ShouldTrace)
         {
             RecoveredParticipantInvalidMetadataRecord.Trace(base.enlistmentId, enlistment.RemoteTransactionId, service, base.state.ProtocolVersion);
         }
         base.stateMachine.ChangeState(state.States.DurableFailedRecovery);
     }
     else
     {
         base.stateMachine.ChangeState(state.States.DurableRecovering);
     }
     base.AddToLookupTable();
 }
コード例 #5
0
        public void Register(Message message, Microsoft.Transactions.Wsat.Messaging.RequestAsyncResult result)
        {
            Microsoft.Transactions.Wsat.Messaging.Register register = new Microsoft.Transactions.Wsat.Messaging.Register(message, this.state.ProtocolVersion);
            EndpointAddress        participantProtocolService       = register.ParticipantProtocolService;
            WsatRegistrationHeader header = WsatRegistrationHeader.ReadFrom(message);

            if (header == null)
            {
                if (DebugTrace.Warning)
                {
                    DebugTrace.Trace(TraceLevel.Warning, "Rejecting Register message with no registration header");
                }
                this.SendFault(result, this.state.Faults.InvalidParameters);
                return;
            }
            switch (register.Protocol)
            {
            case ControlProtocol.Completion:
            {
                CompletionEnlistment completion = this.state.Lookup.FindEnlistment(header.TransactionId) as CompletionEnlistment;
                if (completion != null)
                {
                    CompletionParticipantProxy proxy = this.state.TryCreateCompletionParticipantProxy(participantProtocolService);
                    if (proxy == null)
                    {
                        if (DebugTrace.Warning)
                        {
                            DebugTrace.Trace(TraceLevel.Warning, "Rejecting Register message for completion on no completion enlistment");
                        }
                        this.SendFault(result, this.state.Faults.InvalidParameters);
                        return;
                    }
                    try
                    {
                        completion.StateMachine.Enqueue(new MsgRegisterCompletionEvent(completion, ref register, result, proxy));
                        return;
                    }
                    finally
                    {
                        proxy.Release();
                    }
                    break;
                }
                if (DebugTrace.Warning)
                {
                    DebugTrace.Trace(TraceLevel.Warning, "Rejecting uncorrelated Register message for completion");
                }
                this.SendFault(result, this.state.Faults.UnknownCompletionEnlistment);
                return;
            }

            case ControlProtocol.Volatile2PC:
            case ControlProtocol.Durable2PC:
                break;

            default:
                goto Label_0222;
            }
            if (!this.state.TransactionManager.Settings.NetworkOutboundAccess)
            {
                if (DebugTrace.Warning)
                {
                    DebugTrace.Trace(TraceLevel.Warning, "Rejecting Register message because outbound transactions are disabled");
                }
                this.SendFault(result, this.state.Faults.ParticipantRegistrationNetAccessDisabled);
                return;
            }
            if (register.Loopback == this.state.ProcessId)
            {
                if (DebugTrace.Warning)
                {
                    DebugTrace.Trace(TraceLevel.Warning, "Rejecting recursive Register message from self");
                }
                this.SendFault(result, this.state.Faults.ParticipantRegistrationLoopback);
                return;
            }
            TwoPhaseCommitParticipantProxy proxy2 = this.state.TryCreateTwoPhaseCommitParticipantProxy(participantProtocolService);

            if (proxy2 == null)
            {
                if (DebugTrace.Warning)
                {
                    DebugTrace.Trace(TraceLevel.Warning, "Rejecting Register message because 2PC proxy could not be created");
                }
                this.SendFault(result, this.state.Faults.InvalidParameters);
                return;
            }
            try
            {
                ParticipantEnlistment participant = new ParticipantEnlistment(this.state, header, register.Protocol, proxy2);
                this.state.TransactionManagerSend.Register(participant, new MsgRegisterEvent(participant, ref register, result));
                return;
            }
            finally
            {
                proxy2.Release();
            }
Label_0222:
            Microsoft.Transactions.Bridge.DiagnosticUtility.FailFast("Registration protocol should have been validated");
        }