public void MemberRemoved(MembershipEvent membershipEvent)
 {
     if (MemberRemovedAction != null)
     {
         MemberRemovedAction(membershipEvent);
     }
 }
예제 #2
0
        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);
        }
예제 #3
0
        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);
        }
예제 #4
0
        private void MemberAdded(IMember member)
        {
            _members.Add(member);
            Logger.Info(MembersString());
            var @event = new MembershipEvent(_client.GetCluster(), member, MembershipEvent.MemberAdded, ImmutableSetOfMembers());

            _clusterService.HandleMembershipEvent(@event);
        }
예제 #5
0
        private void MemberAdded(IMember member)
        {
            _members.Add(member);
            ApplyMemberListChanges();
            var @event = new MembershipEvent(_client.GetCluster(), member, MembershipEvent.MemberAdded, GetMembers());

            _clusterService.FireMembershipEvent(@event);
        }
예제 #6
0
 private void FireMembershipEvent(MembershipEvent @event)
 {
     foreach (var listener in _listeners.Values)
     {
         if (@event.GetEventType() == MembershipEvent.MemberAdded)
         {
             listener.MemberAdded(@event);
         }
         else
         {
             listener.MemberRemoved(@event);
         }
     }
 }
예제 #7
0
        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);
        }
예제 #8
0
        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);
        }
예제 #9
0
 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);
             }
         }
     }));
 }
예제 #10
0
            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);
                }
            }
예제 #11
0
 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();
 }
예제 #14
0
        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();
 }
예제 #16
0
 public void MemberRemoved(MembershipEvent membershipEvent)
 {
 }
예제 #17
0
 public void MemberAdded(MembershipEvent membershipEvent)
 {
 }