Esempio n. 1
0
 internal static ImmutableList <ReachableMember> DiffReachable(Gossip oldGossip, Gossip newGossip)
 {
     if (newGossip.Equals(oldGossip))
     {
         return(ImmutableList.Create <ReachableMember>());
     }
     return
         (oldGossip.Overview.Reachability.AllUnreachable
          .Where(a => newGossip.HasMember(a) && newGossip.Overview.Reachability.IsReachable(a))
          .Select(a => new ReachableMember(newGossip.GetMember(a)))
          .ToImmutableList());
 }
Esempio n. 2
0
        /// <summary>
        /// TBD
        /// </summary>
        /// <param name="oldGossip">TBD</param>
        /// <param name="newGossip">TBD</param>
        /// <param name="selfUniqueAddress">TBD</param>
        /// <returns>TBD</returns>
        internal static ImmutableList <ReachableMember> DiffReachable(Gossip oldGossip, Gossip newGossip, UniqueAddress selfUniqueAddress)
        {
            if (newGossip.Equals(oldGossip))
            {
                return(ImmutableList <ReachableMember> .Empty);
            }

            return(oldGossip.Overview.Reachability.AllUnreachable
                   .Where(node => newGossip.HasMember(node) && newGossip.Overview.Reachability.IsReachable(node) && !node.Equals(selfUniqueAddress))
                   .Select(node => new ReachableMember(newGossip.GetMember(node)))
                   .ToImmutableList());
        }
Esempio n. 3
0
        /// <summary>
        /// TBD
        /// </summary>
        /// <param name="oldGossip">TBD</param>
        /// <param name="newGossip">TBD</param>
        /// <param name="selfUniqueAddress">TBD</param>
        /// <returns>TBD</returns>
        internal static ImmutableList<UnreachableMember> DiffUnreachable(Gossip oldGossip, Gossip newGossip, UniqueAddress selfUniqueAddress)
        {
            if (newGossip.Equals(oldGossip))
            {
                return ImmutableList<UnreachableMember>.Empty;
            }

            var oldUnreachableNodes = oldGossip.Overview.Reachability.AllUnreachableOrTerminated;
            return newGossip.Overview.Reachability.AllUnreachableOrTerminated
                    .Where(node => !oldUnreachableNodes.Contains(node) && !node.Equals(selfUniqueAddress))
                    .Select(node => new UnreachableMember(newGossip.GetMember(node)))
                    .ToImmutableList();
        }
Esempio n. 4
0
        internal static ImmutableList <UnreachableMember> DiffUnreachable(Gossip oldGossip, Gossip newGossip)
        {
            if (newGossip.Equals(oldGossip))
            {
                return(ImmutableList.Create <UnreachableMember>());
            }
            var oldUnreachableNodes = oldGossip.Overview.Reachability.AllUnreachableOrTerminated;

            return
                (newGossip.Overview.Reachability.AllUnreachableOrTerminated
                 .Where(a => !oldUnreachableNodes.Contains(a))
                 .Select(a => new UnreachableMember(newGossip.GetMember(a)))
                 .ToImmutableList());
        }
Esempio n. 5
0
        /// <summary>
        /// TBD
        /// </summary>
        /// <param name="oldGossip">TBD</param>
        /// <param name="newGossip">TBD</param>
        /// <param name="selfUniqueAddress">TBD</param>
        /// <returns>TBD</returns>
        internal static ImmutableList<SeenChanged> DiffSeen(Gossip oldGossip, Gossip newGossip, UniqueAddress selfUniqueAddress)
        {
            if (newGossip.Equals(oldGossip))
            {
                return ImmutableList<SeenChanged>.Empty;
            }

            var newConvergence = newGossip.Convergence(selfUniqueAddress, EmptySet);
            var newSeenBy = newGossip.SeenBy;
            if (!newConvergence.Equals(oldGossip.Convergence(selfUniqueAddress, EmptySet)) || !newSeenBy.SequenceEqual(oldGossip.SeenBy))
            {
                return ImmutableList.Create(new SeenChanged(newConvergence, newSeenBy.Select(s => s.Address).ToImmutableHashSet()));
            }

            return ImmutableList<SeenChanged>.Empty;
        }
Esempio n. 6
0
        internal static ImmutableList <SeenChanged> DiffSeen(Gossip oldGossip, Gossip newGossip, UniqueAddress selfUniqueAddres)
        {
            if (newGossip.Equals(oldGossip))
            {
                return(ImmutableList.Create <SeenChanged>());
            }

            var newConvergence = newGossip.Convergence(selfUniqueAddres);
            var newSeenBy      = newGossip.SeenBy;

            if (newConvergence != oldGossip.Convergence(selfUniqueAddres) || newSeenBy != oldGossip.SeenBy)
            {
                return(ImmutableList.Create(new SeenChanged(newConvergence,
                                                            newSeenBy.Select(s => s.Address).ToImmutableHashSet())));
            }
            return(ImmutableList.Create <SeenChanged>());
        }
Esempio n. 7
0
        internal static ImmutableList <IMemberEvent> DiffMemberEvents(Gossip oldGossip, Gossip newGossip)
        {
            if (newGossip.Equals(oldGossip))
            {
                return(ImmutableList.Create <IMemberEvent>());
            }
            var newMembers = newGossip.Members.Except(oldGossip.Members);

            var membersGroupedByAddress = newGossip.Members
                                          .Concat(oldGossip.Members)
                                          .GroupBy(m => m.UniqueAddress);
            var changedMembers = membersGroupedByAddress
                                 .Where(g => g.Count() == 2 && g.First().Status != g.Skip(1).First().Status)
                                 .Select(g => g.First());
            var memberEvents = CollectMemberEvents(newMembers.Union(changedMembers));

            var removedMembers = oldGossip.Members.Except(newGossip.Members);
            var removedEvents  = removedMembers.Select(m => new MemberRemoved(m.Copy(status: MemberStatus.Removed), m.Status));

            return(memberEvents.Concat(removedEvents).ToImmutableList());
        }
 private bool Equals(MetricsGossipEnvelope other)
 {
     return(From.Equals(other.From) && Gossip.Equals(other.Gossip) && Reply.Equals(other.Reply));
 }
Esempio n. 9
0
        internal static ImmutableList<SeenChanged> DiffSeen(Gossip oldGossip, Gossip newGossip, UniqueAddress selfUniqueAddres)
        {
            if (newGossip.Equals(oldGossip)) 
                return ImmutableList.Create<SeenChanged>();

            var newConvergence = newGossip.Convergence(selfUniqueAddres);
            var newSeenBy = newGossip.SeenBy;
            if (newConvergence != oldGossip.Convergence(selfUniqueAddres) || newSeenBy != oldGossip.SeenBy)
                return ImmutableList.Create(new SeenChanged(newConvergence,
                        newSeenBy.Select(s => s.Address).ToImmutableHashSet()));
            return ImmutableList.Create<SeenChanged>();
        }
Esempio n. 10
0
        internal static ImmutableList<IMemberEvent> DiffMemberEvents(Gossip oldGossip, Gossip newGossip)
        {
            if (newGossip.Equals(oldGossip)) return ImmutableList.Create<IMemberEvent>();
            var newMembers = newGossip.Members.Except(oldGossip.Members);

            var membersGroupedByAddress = newGossip.Members
                .Concat(oldGossip.Members)
                .GroupBy(m => m.UniqueAddress);
            var changedMembers = membersGroupedByAddress
                .Where(g => g.Count() == 2 && g.First().Status != g.Skip(1).First().Status)
                .Select(g => g.First());
            var memberEvents = CollectMemberEvents(newMembers.Union(changedMembers));

            var removedMembers = oldGossip.Members.Except(newGossip.Members);
            var removedEvents = removedMembers.Select(m => new MemberRemoved(m.Copy(status: MemberStatus.Removed), m.Status));

            return memberEvents.Concat(removedEvents).ToImmutableList();
        }
Esempio n. 11
0
 internal static ImmutableList<ReachableMember> DiffReachable(Gossip oldGossip, Gossip newGossip)
 {
     if (newGossip.Equals(oldGossip)) return ImmutableList.Create<ReachableMember>();
     return
         oldGossip.Overview.Reachability.AllUnreachable
             .Where(a => newGossip.HasMember(a) && newGossip.Overview.Reachability.IsReachable(a))
             .Select(a => new ReachableMember(newGossip.GetMember(a)))
             .ToImmutableList();
 }
Esempio n. 12
0
 internal static ImmutableList<UnreachableMember> DiffUnreachable(Gossip oldGossip, Gossip newGossip)
 {
     if (newGossip.Equals(oldGossip)) return ImmutableList.Create<UnreachableMember>();
     var oldUnreachableNodes = oldGossip.Overview.Reachability.AllUnreachableOrTerminated;
     return
         newGossip.Overview.Reachability.AllUnreachableOrTerminated
             .Where(a => !oldUnreachableNodes.Contains(a))
             .Select(a => new UnreachableMember(newGossip.GetMember(a)))
             .ToImmutableList();
 }