/// <summary> /// TBD /// </summary> /// <param name="oldGossip">TBD</param> /// <param name="newGossip">TBD</param> /// <param name="selfUniqueAddress">TBD</param> /// <returns>TBD</returns> internal static ImmutableList<LeaderChanged> DiffLeader(Gossip oldGossip, Gossip newGossip, UniqueAddress selfUniqueAddress) { var newLeader = newGossip.Leader(selfUniqueAddress); if ((newLeader == null && oldGossip.Leader(selfUniqueAddress) == null) || newLeader != null && newLeader.Equals(oldGossip.Leader(selfUniqueAddress))) return ImmutableList<LeaderChanged>.Empty; return ImmutableList.Create(newLeader == null ? new LeaderChanged(null) : new LeaderChanged(newLeader.Address)); }
/// <summary> /// The current snapshot state corresponding to latest gossip /// to mimic what you would have seen if you were listening to the events. /// </summary> private void SendCurrentClusterState(IActorRef receiver) { var unreachable = _latestGossip.Overview.Reachability.AllUnreachableOrTerminated .Where(node => !node.Equals(_selfUniqueAddress)) .Select(node => _latestGossip.GetMember(node)) .ToImmutableHashSet(); var state = new ClusterEvent.CurrentClusterState( members: _latestGossip.Members, unreachable: unreachable, seenBy: _latestGossip.SeenBy.Select(s => s.Address).ToImmutableHashSet(), leader: _latestGossip.Leader(_selfUniqueAddress) == null ? null : _latestGossip.Leader(_selfUniqueAddress).Address, roleLeaderMap: _latestGossip.AllRoles.ToImmutableDictionary(r => r, r => { var leader = _latestGossip.RoleLeader(r, _selfUniqueAddress); return leader == null ? null : leader.Address; })); receiver.Tell(state); }
internal static ImmutableList<LeaderChanged> DiffLeader(Gossip oldGossip, Gossip newGossip, UniqueAddress selfUniqueAddress) { var newLeader = newGossip.Leader(selfUniqueAddress); if ((newLeader == null && oldGossip.Leader(selfUniqueAddress) == null) || newLeader != null && newLeader.Equals(oldGossip.Leader(selfUniqueAddress))) return ImmutableList.Create<LeaderChanged>(); return ImmutableList.Create(newLeader == null ? new LeaderChanged(null) : new LeaderChanged(newLeader.Address)); }