private void ProcessTableUpdate(MembershipTableData table, string caller) { if (table is null) { throw new ArgumentNullException(nameof(table)); } if (this.log.IsEnabled(LogLevel.Debug)) { this.log.LogDebug(nameof(ProcessTableUpdate) + " (called from {Caller}) membership table {Table}", caller, table.ToString()); } // Update the current membership snapshot. var(localSiloEntry, _) = this.GetOrCreateLocalSiloEntry(table, this.CurrentStatus); var updated = MembershipTableSnapshot.Create(localSiloEntry, table); if (this.updates.TryPublish(updated)) { this.LogMissedIAmAlives(table); this.log.LogInformation( (int)ErrorCode.MembershipReadAll_2, nameof(ProcessTableUpdate) + " (called from {Caller}) membership table: {Table}", caller, table.WithoutDuplicateDeads().ToString()); } }
public async Task RefreshFromSnapshot(MembershipTableSnapshot snapshot) { // Check if a refresh is underway var pending = this.pendingRefresh; if (pending != null && !pending.IsCompleted) { await pending; } this.log.LogInformation("Received cluster membership snapshot via gossip: {Snapshot}", snapshot); if (snapshot.Entries.TryGetValue(this.myAddress, out var localSiloEntry)) { if (localSiloEntry.Status == SiloStatus.Dead && this.CurrentStatus != SiloStatus.Dead) { var msg = $"I should be Dead according to membership table (in RefreshFromSnapshot). Local entry: {(localSiloEntry.ToFullString(full: true))}."; this.log.Warn(ErrorCode.MembershipFoundMyselfDead1, msg); this.KillMyselfLocally(msg); } snapshot = MembershipTableSnapshot.Create(localSiloEntry.WithStatus(this.CurrentStatus), snapshot); } else { snapshot = MembershipTableSnapshot.Create(this.CreateLocalSiloEntry(this.CurrentStatus), snapshot); } // If we are behind, let's take directly the snapshot in param this.updates.TryPublish(snapshot); }