Package com.hazelcast.cluster
Class MembershipEvent
java.lang.Object
java.util.EventObject
com.hazelcast.cluster.MembershipEvent
- All Implemented Interfaces:
Serializable
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:
-
Field Summary
Modifier and TypeFieldDescriptionprotected Member
static final int
This event type is fired when a new member joins the cluster.static final int
This event type is fired if a member left the cluster or was decided to be unresponsive by other members for a extended time.Fields inherited from class java.util.EventObject
source
-
Constructor Summary
ConstructorDescriptionMembershipEvent
(Cluster cluster, Member member, int eventType, Set<Member> members) -
Method Summary
Modifier and TypeMethodDescriptionReturns the cluster of the event.int
Returns the membership event type; #MEMBER_ADDED #MEMBER_REMOVEDReturns the removed or added member.Returns a consistent view of the the members immediately after this MembershipEvent has been processed.toString()
Methods inherited from class java.util.EventObject
getSource
-
Field Details
-
MEMBER_ADDED
public static final int MEMBER_ADDEDThis event type is fired when a new member joins the cluster.- See Also:
-
MEMBER_REMOVED
public static final int MEMBER_REMOVEDThis 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:
-
member
-
members
-
-
Constructor Details
-
MembershipEvent
-
-
Method Details
-
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
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
Returns the removed or added member.- Returns:
- member which is removed or added
-
toString
- Overrides:
toString
in classEventObject
-