Example #1
0
        public override void ClearInfo()
        {
            PartitionSelector ps       = this.Info.PartitionSelector;
            QuorumLossMode    mode     = this.Info.QuorumLossMode;
            TimeSpan          duration = this.Info.QuorumLossDuration;

            this.Info = new InvokeQuorumLossInfo(ps, mode, duration);
        }
        // test only
        internal bool VerifyEquals(InvokeQuorumLossInfo other)
        {
            TestabilityTrace.TraceSource.WriteInfo("InvokeQuorumLossInfo", "Enter VerifyEquals in InvokeQuorumLossInfo");
            bool eq = this.PartitionSelector.Equals(other.PartitionSelector);

            if (!eq)
            {
                TestabilityTrace.TraceSource.WriteError("InvokeQuorumLossInfo", "PartitionSelector does not match this:{0} other:{1}", this.PartitionSelector.ToString(), other.PartitionSelector.ToString());
            }

            eq = this.QuorumLossMode.Equals(other.QuorumLossMode) &&
                 (this.PartitionId == other.PartitionId);
            if (!eq)
            {
                TestabilityTrace.TraceSource.WriteError("InvokeQuorumLossInfo", "QuorumLossMode or PartitionId do not match");
                return(false);
            }

            if (this.NodesApplied.Count != other.NodesApplied.Count)
            {
                TestabilityTrace.TraceSource.WriteError("InvokeQuorumLossInfo", "Size of NodesApplied does not match {0} vs {1}", this.NodesApplied.Count, other.NodesApplied.Count);
                return(false);
            }

            for (int i = 0; i < this.NodesApplied.Count; i++)
            {
                if (this.NodesApplied[i] != other.NodesApplied[i])
                {
                    TestabilityTrace.TraceSource.WriteError("InvokeQuorumLossInfo", "NodesApplied was expected to match: '{0}' vs '{1}'", this.NodesApplied[i], other.NodesApplied[i]);
                    return(false);
                }
            }

            if (this.ReplicaIds.Count != other.ReplicaIds.Count)
            {
                TestabilityTrace.TraceSource.WriteError("InvokeQuorumLossInfo", "Size of ReplicaIds does not match {0} vs {1}", this.ReplicaIds.Count, other.ReplicaIds.Count);
                return(false);
            }

            for (int i = 0; i < this.ReplicaIds.Count; i++)
            {
                if (this.ReplicaIds[i] != other.ReplicaIds[i])
                {
                    TestabilityTrace.TraceSource.WriteError("InvokeQuorumLossInfo", "ReplicaIds was expected to match: '{0}' vs '{1}'", this.ReplicaIds[i], other.ReplicaIds[i]);
                    return(false);
                }
            }

            if (this.UnreliableTransportInfo.Count != other.UnreliableTransportInfo.Count)
            {
                TestabilityTrace.TraceSource.WriteError("InvokeQuorumLossInfo", "Size of UnreliableTransportInfo does not match {0} vs {1}", this.UnreliableTransportInfo.Count, other.UnreliableTransportInfo.Count);
                return(false);
            }

            for (int i = 0; i < this.UnreliableTransportInfo.Count; i++)
            {
                if ((this.UnreliableTransportInfo[i].Item1 != other.UnreliableTransportInfo[i].Item1) &&
                    (this.UnreliableTransportInfo[i].Item2 != other.UnreliableTransportInfo[i].Item2))
                {
                    TestabilityTrace.TraceSource.WriteError("InvokeQuorumLossInfo", "UT behavior was expected to match: '{0}', '{1}'", this.UnreliableTransportInfo[i], other.UnreliableTransportInfo[i]);
                    return(false);
                }
            }

            return(true);
        }