com.hazelcast.core
Class MembershipEvent
java.lang.Object
java.util.EventObject
com.hazelcast.core.MembershipEvent
- All Implemented Interfaces:
- Serializable
public class MembershipEvent
- extends EventObject
Membership event fired when a new member is added
to the cluster and/or when a member leaves the cluster.
If you also need to receive the initial members of the cluster, you can have a look at the InitialMembershipListener.
- See Also:
MembershipListener,
InitialMembershipEvent,
InitialMembershipListener,
Serialized Form
MEMBER_ADDED
public static final int MEMBER_ADDED
- See Also:
- Constant Field Values
MEMBER_REMOVED
public static final int MEMBER_REMOVED
- See Also:
- Constant Field Values
MembershipEvent
public MembershipEvent(Cluster cluster,
Member member,
int eventType,
Set<Member> members)
getMembers
public Set<Member> getMembers()
- Returns a consistent view of the the members exactly after this MembershipEvent has been processed. So if a
member is removed, the returned set will not include this member. And if a member is added it will include
this member.
The problem with calling the
Cluster.getMembers() is that the content could already
have changed while processing this event so it becomes very difficult to write a deterministic algorithm since
you can't get a deterministic view of the members. This method solves that problem.
The set is immutable and ordered. For more information see Cluster.getMembers().
On the client null is returned to indicate that this functionality is not implemented.
- Returns:
- the members at the moment after this event. Or null if this event is send on the client side.
getCluster
public Cluster getCluster()
- Returns the cluster of the event.
- Returns:
getEventType
public int getEventType()
- Returns the membership event type; #MEMBER_ADDED or #MEMBER_REMOVED
- Returns:
- the membeship event type
getMember
public Member getMember()
- Returns the removed or added member.
- Returns:
- member which is removed/added
toString
public String toString()
- Overrides:
toString in class EventObject
Copyright .0; 2008-2011 Hazel Ltd. All Rights Reserved.