Example #1
0
        public static MembershipTableSnapshot Create(MembershipEntry localSiloEntry, MembershipTableData table)
        {
            if (table is null)
            {
                throw new ArgumentNullException(nameof(table));
            }

            var entries = ImmutableDictionary.CreateBuilder <SiloAddress, MembershipEntry>();

            if (table.Members != null)
            {
                foreach (var item in table.Members)
                {
                    var entry = item.Item1;
                    entries.Add(entry.SiloAddress, entry);
                }
            }

            if (entries.TryGetValue(localSiloEntry.SiloAddress, out var existing))
            {
                entries[localSiloEntry.SiloAddress] = existing.WithStatus(localSiloEntry.Status);
            }
            else
            {
                entries[localSiloEntry.SiloAddress] = localSiloEntry;
            }

            var version = new MembershipVersion(table.Version.Version);

            return(new MembershipTableSnapshot(version, entries.ToImmutable()));
        }
Example #2
0
 public MembershipTableSnapshot(
     MembershipVersion version,
     ImmutableDictionary <SiloAddress, MembershipEntry> entries)
 {
     this.Version = version;
     this.Entries = entries;
 }
Example #3
0
 public ValueTask Refresh(MembershipVersion targetVersion)
 {
     if (targetVersion != default && targetVersion != MembershipVersion.MinValue && this.snapshot.Version >= targetVersion)
     {
         return(default);
 /// <summary>
 /// Initializes a new instance of the <see cref="ClusterMembershipSnapshot"/> class.
 /// </summary>
 /// <param name="members">The cluster members.</param>
 /// <param name="version">The cluster membership version.</param>
 public ClusterMembershipSnapshot(ImmutableDictionary <SiloAddress, ClusterMember> members, MembershipVersion version)
 {
     this.Members = members;
     this.Version = version;
 }