public override int GetHashCode() { unchecked { return((LatestGossip.GetHashCode() * 397) ^ SelfUniqueAddress.GetHashCode()); } }
public bool IsReachableExcludingDownedObservers(UniqueAddress toAddress) { if (!LatestGossip.HasMember(toAddress)) { return(false); } // TODO: check for multiple DCs return(LatestGossip.ReachabilityExcludingDownedObservers.Value.IsReachable(toAddress)); }
public bool Equals(MembershipState other) { if (ReferenceEquals(null, other)) { return(false); } if (ReferenceEquals(this, other)) { return(true); } return(SelfUniqueAddress.Equals(other.SelfUniqueAddress) && LatestGossip.Equals(other.LatestGossip)); }
/// <summary> /// First check that: /// 1. we don't have any members that are unreachable, or /// 2. all unreachable members in the set have status DOWN or EXITING /// Else we can't continue to check for convergence. When that is done /// we check that all members with a convergence status is in the seen /// table and has the latest vector clock version. /// </summary> /// <param name="exitingConfirmed">The set of nodes who have been confirmed to be exiting.</param> /// <returns><c>true</c> if convergence has been achieved. <c>false</c> otherwise.</returns> public bool Convergence(IImmutableSet <UniqueAddress> exitingConfirmed) { // If another member in the data center that is UP or LEAVING // and has not seen this gossip or is exiting // convergence cannot be reached bool MemberHinderingConvergenceExists() { return(Members.Any(x => ConvergenceMemberStatus.Contains(x.Status) && !(LatestGossip.SeenByNode(x.UniqueAddress) || exitingConfirmed.Contains(x.UniqueAddress)))); } // Find cluster members in the data center that are unreachable from other members of the data center // excluding observations from members outside of the data center, that have status DOWN or is passed in as confirmed exiting. var unreachable = DcReachabilityExcludingDownedObservers.AllUnreachableOrTerminated .Where(node => node != SelfUniqueAddress && !exitingConfirmed.Contains(node)) .Select(x => LatestGossip.GetMember(x)); // unreachables outside of the data center or with status DOWN or EXITING does not affect convergence var allUnreachablesCanBeIgnored = unreachable.All(m => ConvergenceSkipUnreachableWithMemberStatus.Contains(m.Status)); return(allUnreachablesCanBeIgnored && !MemberHinderingConvergenceExists()); }
/// <summary> /// Copies the current <see cref="MembershipState"/> and marks the <see cref="LatestGossip"/> as Seen /// by the <see cref="SelfUniqueAddress"/>. /// </summary> /// <returns>A new <see cref="MembershipState"/> instance with the updated seen records.</returns> public MembershipState Seen() => Copy(LatestGossip.Seen(SelfUniqueAddress));