/// <summary> /// TBD /// </summary> /// <param name="node">TBD</param> /// <exception cref="InvalidOperationException"> /// This exception is thrown when a non-leader tries to down the specified <paramref name="node"/>. /// </exception> public override void Down(Address node) { if (!_leader) { throw new InvalidOperationException("Must be leader to down node"); } _cluster.LogInfo("Leader is auto-downing unreachable node [{0}]", node); _cluster.Down(node); }
protected override void PreStart() { _cluster.Subscribe(Self, new [] { typeof(ClusterEvent.IMemberEvent), typeof(ClusterEvent.ReachabilityEvent) }); _cluster.LogInfo("Metrics collection has started successfully."); }
public EventBusListener(Cluster cluster, ClusterReadView readView) { _cluster = cluster; _readView = readView; Receive <ClusterEvent.IClusterDomainEvent>(clusterDomainEvent => { clusterDomainEvent.Match() .With <ClusterEvent.SeenChanged>(changed => { State = State.Copy(seenBy: changed.SeenBy); }) .With <ClusterEvent.ReachabilityChanged>(changed => { _readView._reachability = changed.Reachability; }) .With <ClusterEvent.MemberRemoved>(removed => { State = State.Copy(members: State.Members.Remove(removed.Member), unreachable: State.Unreachable.Remove(removed.Member)); }) .With <ClusterEvent.UnreachableMember>(member => { // replace current member with new member (might have different status, only address is used in == comparison) State = State.Copy(unreachable: State.Unreachable.Remove(member.Member).Add(member.Member)); }) .With <ClusterEvent.ReachableMember>(member => { State = State.Copy(unreachable: State.Unreachable.Remove(member.Member)); }) .With <ClusterEvent.IMemberEvent>(memberEvent => { var newUnreachable = State.Unreachable; // replace current member with new member (might have different status, only address is used in == comparison) if (State.Unreachable.Contains(memberEvent.Member)) { newUnreachable = State.Unreachable.Remove(memberEvent.Member).Add(memberEvent.Member); } State = State.Copy( members: State.Members.Remove(memberEvent.Member).Add(memberEvent.Member), unreachable: newUnreachable); }) .With <ClusterEvent.LeaderChanged>(changed => { State = State.Copy(leader: changed.Leader); }) .With <ClusterEvent.RoleLeaderChanged>(changed => { State = State.Copy(roleLeaderMap: State.RoleLeaderMap.SetItem(changed.Role, changed.Leader)); }) .With <ClusterEvent.CurrentInternalStats>(stats => { readView._latestStats = stats; }) .With <ClusterEvent.ClusterShuttingDown>(_ => { }); // once captured, optional verbose logging of event if (!(clusterDomainEvent is ClusterEvent.SeenChanged) && _cluster.Settings.LogInfoVerbose) { _cluster.LogInfo("event {0}", clusterDomainEvent.GetType().Name); } }); Receive <ClusterEvent.CurrentClusterState>(state => { State = state; }); }