コード例 #1
0
        private CompletionEnlistment CheckMessage(Message message, bool reply)
        {
            Guid guid;

            if (!Ports.TryGetEnlistment(message, out guid))
            {
                DebugTrace.Trace(TraceLevel.Warning, "Could not read enlistment header from message");
                if (reply)
                {
                    this.SendFault(message, this.state.Faults.InvalidParameters);
                }
                return(null);
            }
            Microsoft.Transactions.Wsat.Protocol.TransactionEnlistment enlistment = this.state.Lookup.FindEnlistment(guid);
            if (enlistment == null)
            {
                DebugTrace.Trace(TraceLevel.Warning, "Could not find enlistment {0}", guid);
                if (reply)
                {
                    this.SendFault(message, this.state.Faults.InvalidState);
                }
                return(null);
            }
            CompletionEnlistment enlistment2 = enlistment as CompletionEnlistment;

            if (enlistment2 == null)
            {
                DebugTrace.Trace(TraceLevel.Warning, "Completion message received for non-completion enlistment {0}", guid);
                if (reply)
                {
                    this.SendFault(message, this.state.Faults.InvalidParameters);
                }
                return(null);
            }
            if (this.state.Service.Security.CheckIdentity(enlistment2.ParticipantProxy, message))
            {
                return(enlistment2);
            }
            if (EnlistmentIdentityCheckFailedRecord.ShouldTrace)
            {
                EnlistmentIdentityCheckFailedRecord.Trace(enlistment2.EnlistmentId);
            }
            return(null);
        }
コード例 #2
0
        private bool CheckMessage(Message message, bool fault, out CoordinatorEnlistment durableCoordinator, out VolatileCoordinatorEnlistment volatileCoordinator)
        {
            Guid guid;
            TwoPhaseCommitCoordinatorProxy coordinatorProxy;

            durableCoordinator  = null;
            volatileCoordinator = null;
            if (!Ports.TryGetEnlistment(message, out guid))
            {
                DebugTrace.Trace(TraceLevel.Warning, "Could not read enlistment header from message");
                if (fault)
                {
                    this.SendFault(message, this.state.Faults.InvalidParameters);
                }
                return(false);
            }
            Microsoft.Transactions.Wsat.Protocol.TransactionEnlistment enlistment = this.state.Lookup.FindEnlistment(guid);
            if (enlistment == null)
            {
                DebugTrace.Trace(TraceLevel.Warning, "Could not find enlistment {0}", guid);
                return(true);
            }
            durableCoordinator = enlistment as CoordinatorEnlistment;
            if (durableCoordinator == null)
            {
                volatileCoordinator = enlistment as VolatileCoordinatorEnlistment;
                if (volatileCoordinator == null)
                {
                    DebugTrace.Trace(TraceLevel.Warning, "2PC message received for non-2PC enlistment {0}", guid);
                    if (fault)
                    {
                        this.SendFault(message, this.state.Faults.InvalidParameters);
                    }
                    return(false);
                }
                coordinatorProxy = volatileCoordinator.CoordinatorProxy;
            }
            else
            {
                coordinatorProxy = durableCoordinator.CoordinatorProxy;
            }
            if (coordinatorProxy == null)
            {
                if ((durableCoordinator != null) && object.ReferenceEquals(durableCoordinator.StateMachine.State, this.state.States.CoordinatorFailedRecovery))
                {
                    DebugTrace.TxTrace(TraceLevel.Warning, enlistment.EnlistmentId, "Coordinator enlistment was not correctly recovered");
                    if (fault)
                    {
                        this.SendFault(message, this.state.Faults.InvalidPolicy);
                    }
                    return(false);
                }
                if (DebugTrace.Warning)
                {
                    DebugTrace.TxTrace(TraceLevel.Warning, enlistment.EnlistmentId, "Received premature message with action {0}", message.Headers.Action);
                }
                if (fault)
                {
                    this.SendFault(message, this.state.Faults.InvalidState);
                }
                return(false);
            }
            if (this.state.Service.Security.CheckIdentity(coordinatorProxy, message))
            {
                return(true);
            }
            if (EnlistmentIdentityCheckFailedRecord.ShouldTrace)
            {
                EnlistmentIdentityCheckFailedRecord.Trace(enlistment.EnlistmentId);
            }
            return(false);
        }
コード例 #3
0
        private ParticipantEnlistment CheckMessage(Message message, bool fault, bool preparedOrReplay)
        {
            Guid            guid;
            ControlProtocol protocol;

            if (!Ports.TryGetEnlistment(message, out guid, out protocol))
            {
                DebugTrace.Trace(TraceLevel.Warning, "Could not read enlistment header from message");
                if (fault)
                {
                    this.SendFault(message, this.state.Faults.InvalidParameters);
                }
                return(null);
            }
            Microsoft.Transactions.Wsat.Protocol.TransactionEnlistment enlistment = this.state.Lookup.FindEnlistment(guid);
            if (enlistment == null)
            {
                DebugTrace.Trace(TraceLevel.Verbose, "Enlistment {0} could not be found", guid);
                if (preparedOrReplay)
                {
                    if (protocol == ControlProtocol.Volatile2PC)
                    {
                        if (DebugTrace.Warning)
                        {
                            DebugTrace.Trace(TraceLevel.Warning, "Received Prepared or Replay from unrecognized volatile participant at {0}", Ports.TryGetFromAddress(message));
                        }
                        if (VolatileParticipantInDoubtRecord.ShouldTrace)
                        {
                            VolatileParticipantInDoubtRecord.Trace(guid, Library.GetReplyToHeader(message.Headers), this.state.ProtocolVersion);
                        }
                        this.SendFault(message, this.state.Faults.UnknownTransaction);
                    }
                    else if (protocol == ControlProtocol.Durable2PC)
                    {
                        this.SendRollback(message);
                    }
                    else
                    {
                        this.SendFault(message, this.state.Faults.InvalidParameters);
                    }
                }
                else if (DebugTrace.Info)
                {
                    DebugTrace.Trace(TraceLevel.Info, "Ignoring message from unrecognized participant at {0}", Ports.TryGetFromAddress(message));
                }
                return(null);
            }
            ParticipantEnlistment enlistment2 = enlistment as ParticipantEnlistment;

            if ((enlistment2 == null) || (protocol != enlistment2.ControlProtocol))
            {
                DebugTrace.Trace(TraceLevel.Warning, "Enlistment state does not match message for {0}", guid);
                if (fault)
                {
                    this.SendFault(message, this.state.Faults.InvalidParameters);
                }
                return(null);
            }
            if (enlistment2.ParticipantProxy == null)
            {
                DebugTrace.TxTrace(TraceLevel.Warning, enlistment2.EnlistmentId, "Participant enlistment was not correctly recovered");
                if (fault)
                {
                    this.SendFault(message, this.state.Faults.InvalidPolicy);
                }
                return(null);
            }
            if (this.state.Service.Security.CheckIdentity(enlistment2.ParticipantProxy, message))
            {
                return(enlistment2);
            }
            if (EnlistmentIdentityCheckFailedRecord.ShouldTrace)
            {
                EnlistmentIdentityCheckFailedRecord.Trace(enlistment2.EnlistmentId);
            }
            return(null);
        }