internal static ImmutableHashSet <RoleLeaderChanged> DiffRolesLeader(Gossip oldGossip, Gossip newGossip, UniqueAddress selfUniqueAddress) { return(InternalDiffRolesLeader(oldGossip, newGossip, selfUniqueAddress).ToImmutableHashSet()); }
/// <summary> /// TBD /// </summary> /// <param name="from">TBD</param> public HeartbeatRsp(UniqueAddress from) { From = from; }
/// <summary> /// Check to see if a node with the given address exists inside the heartbeat sender state. /// </summary> /// <param name="node">The node to check</param> /// <returns><c>true</c> if the heartbeat sender is already aware of this node. <c>false</c> otherwise.</returns> public bool Contains(UniqueAddress node) { return(Ring.Nodes.Contains(node)); }
public UniqueAddress Leader(UniqueAddress selfUniqueAddress) { return(LeaderOf(_members, selfUniqueAddress)); }
public bool HasMember(UniqueAddress node) { return(_membersMap.Value.ContainsKey(node)); }
/// <summary> /// TBD /// </summary> /// <param name="node">TBD</param> /// <returns>TBD</returns> public ClusterHeartbeatSenderState ReachableMember(UniqueAddress node) { return(MembershipChange(Ring.Copy(unreachable: Ring.Unreachable.Remove(node)))); }
/// <summary> /// Has this Gossip been seen by this node. /// </summary> public bool SeenByNode(UniqueAddress node) { return(_overview.Seen.Contains(node)); }
/// <summary> /// TBD /// </summary> /// <param name="observer">TBD</param> /// <param name="subject">TBD</param> /// <returns>TBD</returns> public Reachability Terminated(UniqueAddress observer, UniqueAddress subject) { return(Change(observer, subject, ReachabilityStatus.Terminated)); }
long CurrentVersion(UniqueAddress observer) { long version; return(_versions.TryGetValue(observer, out version) ? version : 0); }
public HeartbeatNodeRing(UniqueAddress selfAddress, IEnumerable <UniqueAddress> nodes, int monitoredByNumberOfNodes) : this(selfAddress, ImmutableSortedSet.Create(nodes.ToArray()), monitoredByNumberOfNodes) { }
/// <summary> /// TBD /// </summary> /// <param name="observer">TBD</param> /// <param name="subject">TBD</param> /// <returns>TBD</returns> public Reachability Reachable(UniqueAddress observer, UniqueAddress subject) { return(Change(observer, subject, ReachabilityStatus.Reachable)); }
private void DoHeartbeatRsp(UniqueAddress from) { _log.Debug("Cluster Node [{0}] - Heartbeat response from [{1}]", _cluster.SelfAddress, from.Address); _state = _state.HeartbeatRsp(from); }
internal static ImmutableList <SeenChanged> DiffSeen(Gossip oldGossip, Gossip newGossip, UniqueAddress selfUniqueAddress) { if (newGossip.Equals(oldGossip)) { return(ImmutableList <SeenChanged> .Empty); } var newConvergence = newGossip.Convergence(selfUniqueAddress); var newSeenBy = newGossip.SeenBy; if (!newConvergence.Equals(oldGossip.Convergence(selfUniqueAddress)) || !newSeenBy.SequenceEqual(oldGossip.SeenBy)) { return(ImmutableList.Create(new SeenChanged(newConvergence, newSeenBy.Select(s => s.Address).ToImmutableHashSet()))); } return(ImmutableList <SeenChanged> .Empty); }
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)); } } }
/// <summary> /// Creates a new <see cref="Member"/>. /// </summary> /// <param name="uniqueAddress">The address of the member.</param> /// <param name="upNumber">The upNumber of the member, as assigned by the leader at the time the node joined the cluster.</param> /// <param name="status">The status of this member.</param> /// <param name="roles">The roles for this member. Can be empty.</param> /// <param name="appVersion">Application version</param> /// <returns>A new member instance.</returns> internal static Member Create(UniqueAddress uniqueAddress, int upNumber, MemberStatus status, ImmutableHashSet <string> roles, AppVersion appVersion) { return(new Member(uniqueAddress, upNumber, status, roles, appVersion)); }
long NextVersion(UniqueAddress observer) { return(CurrentVersion(observer) + 1); }
public HeartbeatRsp(UniqueAddress from, long sequenceNr, long creationTimeNanos) { From = from; SequenceNr = sequenceNr; CreationTimeNanos = creationTimeNanos; }
/// <summary> /// TBD /// </summary> /// <param name="node">TBD</param> /// <returns>TBD</returns> public bool IsReachable(UniqueAddress node) { return(IsAllReachable || !AllUnreachableOrTerminated.Contains(node)); }
/// <summary> /// Marks the gossip as seen by only this node (address) by replacing the 'gossip.overview.seen' /// </summary> public Gossip OnlySeen(UniqueAddress node) { return(Copy(overview: _overview.Copy(seen: ImmutableHashSet.Create(node)))); }
/// <summary> /// TBD /// </summary> /// <param name="observer">TBD</param> /// <param name="subject">TBD</param> /// <returns>TBD</returns> public bool IsReachable(UniqueAddress observer, UniqueAddress subject) { return(Status(observer, subject) == ReachabilityStatus.Reachable); }
public bool IsLeader(UniqueAddress node, UniqueAddress selfUniqueAddress) { return(Leader(selfUniqueAddress) == node && node != null); }
internal Member(UniqueAddress uniqueAddress, int upNumber, MemberStatus status, IEnumerable <string> roles, AppVersion appVersion) : this(uniqueAddress, upNumber, status, roles.ToImmutableHashSet(), appVersion) { }
public Member GetMember(UniqueAddress node) { return(_membersMap.Value.GetOrElse(node, Member.Removed(node))); // placeholder for removed member }
/// <inheritdoc cref="object.GetHashCode"/> public override int GetHashCode() { return(UniqueAddress.GetHashCode()); }
public GossipStatus(UniqueAddress from, VectorClock version) { _from = from; _version = version; }
/// <summary> /// TBD /// </summary> /// <param name="uniqueAddress">TBD</param> /// <param name="roles">TBD</param> /// <param name="appVersion">Application version</param> /// <returns>TBD</returns> internal static Member Create(UniqueAddress uniqueAddress, ImmutableHashSet <string> roles, AppVersion appVersion) { return(new Member(uniqueAddress, int.MaxValue, MemberStatus.Joining, roles, appVersion)); }
/// <summary> /// TBD /// </summary> /// <param name="from">TBD</param> public ExpectedFirstHeartbeat(UniqueAddress from) { From = from; }
/// <summary> /// TBD /// </summary> /// <param name="node">TBD</param> /// <returns>TBD</returns> internal static Member Removed(UniqueAddress node) { return(new Member(node, int.MaxValue, MemberStatus.Removed, ImmutableHashSet.Create <string>(), Util.AppVersion.Zero)); }
/// <summary> /// Adds a new <see cref="UniqueAddress"/> to the heartbeat sender's state. /// </summary> /// <param name="node">The node to add.</param> /// <returns>An updated copy of the state now including this member.</returns> public ClusterHeartbeatSenderState AddMember(UniqueAddress node) { return(MembershipChange(Ring + node)); }
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))); }