RoleLeader() публичный Метод

public RoleLeader ( string role, UniqueAddress selfUniqueAddress ) : UniqueAddress
role string
selfUniqueAddress UniqueAddress
Результат UniqueAddress
Пример #1
0
 private static IEnumerable<RoleLeaderChanged> InternalDiffRolesLeader(Gossip oldGossip, Gossip newGossip, UniqueAddress selfUniqueAddress)
 {
     foreach (var role in oldGossip.AllRoles.Union(newGossip.AllRoles))
     {
         var newLeader = newGossip.RoleLeader(role, selfUniqueAddress);
         if (newLeader == null && oldGossip.RoleLeader(role, selfUniqueAddress) != null)
             yield return new RoleLeaderChanged(role, null);
         if (newLeader != null && !newLeader.Equals(oldGossip.RoleLeader(role, selfUniqueAddress)))
             yield return new RoleLeaderChanged(role, newLeader.Address);
     }
 }
Пример #2
0
        /// <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(ActorRef receiver)
        {
            var state = new ClusterEvent.CurrentClusterState(
                _latestGossip.Members,
                _latestGossip.Overview.Reachability.AllUnreachableOrTerminated.Select(_latestGossip.GetMember)
                .ToImmutableHashSet(),
                _latestGossip.SeenBy.Select(s => s.Address).ToImmutableHashSet(),
                _latestGossip.Leader == null ? null : _latestGossip.Leader.Address,
                _latestGossip.AllRoles.ToImmutableDictionary(r => r, r => _latestGossip.RoleLeader(r).Address)
                );

            receiver.Tell(state);
        }
Пример #3
0
        /// <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);
        }
Пример #4
0
 private static IEnumerable<RoleLeaderChanged> InternalDiffRolesLeader(Gossip oldGossip, Gossip newGossip, UniqueAddress selfUniqueAddress)
 {
     foreach (var role in oldGossip.AllRoles.Union(newGossip.AllRoles))
     {
         var newLeader = newGossip.RoleLeader(role, selfUniqueAddress);
         if(newLeader == null && oldGossip.RoleLeader(role, selfUniqueAddress) != null)
             yield return new RoleLeaderChanged(role, null);
         if(newLeader != null && !newLeader.Equals(oldGossip.RoleLeader(role, selfUniqueAddress))) 
             yield return new RoleLeaderChanged(role, newLeader.Address);
     }
 }