public void MemberRemoved(MembershipEvent membershipEvent) { if (MemberRemovedAction != null) { MemberRemovedAction(membershipEvent); } }
public void MemberRemovedEvent() { var node = Cluster.AddNode(); Client.GetCluster().AddMembershipListener(new MembershipListener { OnMemberAdded = memberAddedEvent => { Cluster.RemoveNode(node); } }); var reset = new ManualResetEventSlim(); MembershipEvent memberRemovedEvent = null; Client.GetCluster().AddMembershipListener(new MembershipListener { OnMemberRemoved = memberRemoved => { memberRemovedEvent = memberRemoved; reset.Set(); } }); Assert.IsTrue(reset.Wait(30 * 1000)); Assert.IsInstanceOf <ICluster>(memberRemovedEvent.Source); Assert.IsInstanceOf <ICluster>(memberRemovedEvent.GetCluster()); Assert.AreEqual(MembershipEvent.MemberRemoved, memberRemovedEvent.GetEventType()); Assert.IsNotNull(memberRemovedEvent.GetMember()); Assert.AreEqual(1, memberRemovedEvent.GetMembers().Count); }
public void MemberRemovedEvent() { var reset = new ManualResetEventSlim(); _client.GetCluster().AddMembershipListener(new MembershipListener { OnMemberAdded = memberAddedEvent => { reset.Set(); } }); var member = StartMember(_remoteController, _cluster); Assert.IsTrue(reset.Wait(30 * 1000)); reset.Reset(); MembershipEvent memberRemovedEvent = null; _client.GetCluster().AddMembershipListener(new MembershipListener { OnMemberRemoved = memberRemoved => { memberRemovedEvent = memberRemoved; reset.Set(); } }); StopMember(_remoteController, _cluster, member); Assert.IsTrue(reset.Wait(30 * 1000)); Assert.IsInstanceOf <ICluster>(memberRemovedEvent.Source); Assert.IsInstanceOf <ICluster>(memberRemovedEvent.GetCluster()); Assert.AreEqual(MembershipEvent.MemberRemoved, memberRemovedEvent.GetEventType()); Assert.IsNotNull(memberRemovedEvent.GetMember()); Assert.AreEqual(1, memberRemovedEvent.GetMembers().Count); }
private void MemberAdded(IMember member) { _members.Add(member); Logger.Info(MembersString()); var @event = new MembershipEvent(_client.GetCluster(), member, MembershipEvent.MemberAdded, ImmutableSetOfMembers()); _clusterService.HandleMembershipEvent(@event); }
private void MemberAdded(IMember member) { _members.Add(member); ApplyMemberListChanges(); var @event = new MembershipEvent(_client.GetCluster(), member, MembershipEvent.MemberAdded, GetMembers()); _clusterService.FireMembershipEvent(@event); }
private void FireMembershipEvent(MembershipEvent @event) { foreach (var listener in _listeners.Values) { if (@event.GetEventType() == MembershipEvent.MemberAdded) { listener.MemberAdded(@event); } else { listener.MemberRemoved(@event); } } }
private void MemberRemoved(IMember member) { _members.Remove(member); ApplyMemberListChanges(); var connection = _connectionManager.GetConnection(member.GetAddress()); if (connection != null) { _connectionManager.DestroyConnection(connection); } var @event = new MembershipEvent(_client.GetCluster(), member, MembershipEvent.MemberRemoved, GetMembers()); _clusterService.FireMembershipEvent(@event); }
private void MemberRemoved(IMember member) { _members.Remove(member); Logger.Info(MembersString()); var connection = _connectionManager.GetConnection(member.GetAddress()); if (connection != null) { _connectionManager.DestroyConnection(connection, new TargetDisconnectedException(member.GetAddress(), "member left the cluster.")); } var @event = new MembershipEvent(_client.GetCluster(), member, MembershipEvent.MemberRemoved, ImmutableSetOfMembers()); _clusterService.HandleMembershipEvent(@event); }
internal virtual void FireMembershipEvent(MembershipEvent @event) { _client.GetClientExecutionService().Submit((() => { foreach (var listener in _listeners.Values) { if (@event.GetEventType() == MembershipEvent.MemberAdded) { listener.MemberAdded(@event); } else { listener.MemberRemoved(@event); } } })); }
public override void MemberRemoved(MembershipEvent membershipEvent) { if (!membershipEvent.Member.localMember()) { Address address = membershipEvent.Member.Address; outerInstance.monitor.LostMember(new SocketAddress(address.Host, address.Port)); } try { outerInstance.refreshTopology(); } catch (InterruptedException e) { throw new Exception(e); } }
internal void HandleMembershipEvent(MembershipEvent @event) { lock (_initialMembershipListenerMutex) { var member = @event.GetMember(); var dictionary = _membersRef.Get(); var newMap = new Dictionary <Address, IMember>(dictionary); if (@event.GetEventType() == MembershipEvent.MemberAdded) { newMap.Add(member.GetAddress(), member); } else { newMap.Remove(member.GetAddress()); } _membersRef.Set(newMap); FireMembershipEvent(@event); } }
public void MemberAdded(MembershipEvent membershipEvent) { reset.Set(); }
public void MemberRemoved(MembershipEvent membershipEvent) { reset.Set(); }
private object ConvertPayload() { switch (Event) { case PingEvent.EventString: return(PingEvent.FromJson(PayloadText)); case CommitCommentEvent.EventString: return(CommitCommentEvent.FromJson(PayloadText)); case CreateEvent.EventString: return(CreateEvent.FromJson(PayloadText)); case DeleteEvent.EventString: return(DeleteEvent.FromJson(PayloadText)); case DeploymentEvent.EventString: return(DeploymentEvent.FromJson(PayloadText)); case DeploymentStatusEvent.EventString: return(DeploymentStatusEvent.FromJson(PayloadText)); case ForkEvent.EventString: return(ForkEvent.FromJson(PayloadText)); case GollumEvent.EventString: return(GollumEvent.FromJson(PayloadText)); case InstallationEvent.EventString: return(InstallationEvent.FromJson(PayloadText)); case InstallationRepositoriesEvent.EventString: return(InstallationRepositoriesEvent.FromJson(PayloadText)); case IssueCommentEvent.EventString: return(IssueCommentEvent.FromJson(PayloadText)); case IssuesEvent.EventString: return(IssuesEvent.FromJson(PayloadText)); case LabelEvent.EventString: return(LabelEvent.FromJson(PayloadText)); case MemberEvent.EventString: return(MemberEvent.FromJson(PayloadText)); case MembershipEvent.EventString: return(MembershipEvent.FromJson(PayloadText)); case MilestoneEvent.EventString: return(MilestoneEvent.FromJson(PayloadText)); case OrganizationEvent.EventString: return(OrganizationEvent.FromJson(PayloadText)); case OrgBlockEvent.EventString: return(OrgBlockEvent.FromJson(PayloadText)); case PageBuildEvent.EventString: return(PageBuildEvent.FromJson(PayloadText)); case ProjectCardEvent.EventString: return(ProjectCardEvent.FromJson(PayloadText)); case ProjectColumnEvent.EventString: return(ProjectColumnEvent.FromJson(PayloadText)); case ProjectEvent.EventString: return(ProjectEvent.FromJson(PayloadText)); case PublicEvent.EventString: return(PublicEvent.FromJson(PayloadText)); case PullRequestEvent.EventString: return(PullRequestEvent.FromJson(PayloadText)); case PullRequestReviewEvent.EventString: return(PullRequestReviewEvent.FromJson(PayloadText)); case PullRequestReviewCommentEvent.EventString: return(PullRequestReviewCommentEvent.FromJson(PayloadText)); case PushEvent.EventString: return(PushEvent.FromJson(PayloadText)); case ReleaseEvent.EventString: return(ReleaseEvent.FromJson(PayloadText)); case RepositoryEvent.EventString: return(RepositoryEvent.FromJson(PayloadText)); case StatusEvent.EventString: return(StatusEvent.FromJson(PayloadText)); case WatchEvent.EventString: return(WatchEvent.FromJson(PayloadText)); default: throw new NotImplementedException( $"Event Type: `{Event}` is not implemented. Want it added? Open an issue at https://github.com/promofaux/GithubWebhooks"); } }
public void MemberRemoved(MembershipEvent membershipEvent) { SetMembersFromCluster(); }
public void MemberRemoved(MembershipEvent membershipEvent) { }
public void MemberAdded(MembershipEvent membershipEvent) { }