Class MembershipEvent

  • All Implemented Interfaces:
    java.io.Serializable

    public class MembershipEvent
    extends java.util.EventObject
    Membership event fired when a new member is added to the cluster and/or when a member leaves the cluster and similar methods.
    See Also:
    MembershipListener, Serialized Form
    • Field Summary

      Fields 
      Modifier and Type Field Description
      protected Member member  
      static int MEMBER_ADDED
      This event type is fired when a new member joins the cluster.
      static int MEMBER_REMOVED
      This event type is fired if a member left the cluster or was decided to be unresponsive by other members for a extended time.
      protected java.util.Set<Member> members  
      • Fields inherited from class java.util.EventObject

        source
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      Cluster getCluster()
      Returns the cluster of the event.
      int getEventType()
      Returns the membership event type; #MEMBER_ADDED #MEMBER_REMOVED
      Member getMember()
      Returns the removed or added member.
      java.util.Set<Member> getMembers()
      Returns a consistent view of the the members immediately after this MembershipEvent has been processed.
      java.lang.String toString()  
      • Methods inherited from class java.util.EventObject

        getSource
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
    • Field Detail

      • MEMBER_ADDED

        public static final int MEMBER_ADDED
        This event type is fired when a new member joins the cluster.
        See Also:
        Constant Field Values
      • MEMBER_REMOVED

        public static final int MEMBER_REMOVED
        This event type is fired if a member left the cluster or was decided to be unresponsive by other members for a extended time.
        See Also:
        Constant Field Values
      • member

        protected Member member
      • members

        protected java.util.Set<Member> members
    • Constructor Detail

      • MembershipEvent

        public MembershipEvent​(Cluster cluster,
                               Member member,
                               int eventType,
                               java.util.Set<Member> members)
    • Method Detail

      • getMembers

        public java.util.Set<Member> getMembers()
        Returns a consistent view of the the members immediately after this MembershipEvent has been processed. If a member is removed, the returned set will not include this member. If a member is added, it will include this member.

        The problem with calling the Cluster.getMembers() method is that the content could already have changed while processing this event, so it becomes very difficult to write a deterministic algorithm since you cannot get a deterministic view of the members. This method solves that problem.

        The set is immutable and ordered. For more information see Cluster.getMembers().

        Returns:
        the members at the moment after this event.
      • getCluster

        public Cluster getCluster()
        Returns the cluster of the event.
        Returns:
        the current cluster instance
      • getEventType

        public int getEventType()
        Returns the membership event type; #MEMBER_ADDED #MEMBER_REMOVED
        Returns:
        the membership event type
      • getMember

        public Member getMember()
        Returns the removed or added member.
        Returns:
        member which is removed or added
      • toString

        public java.lang.String toString()
        Overrides:
        toString in class java.util.EventObject