Package spread
Class MembershipInfo
- java.lang.Object
-
- spread.MembershipInfo
-
public class MembershipInfo extends java.lang.ObjectA MembershipInfo object represents information stored in a membership message. To check if a message is a membership message, useSpreadMessage.isMembership():if(message.isMembership() == true) System.out.println("Membership message.");To get the MembershipInfo object from a membership message, use
SpreadMessage.getMembershipInfo():MembershipInfo membershipInfo = message.getMembershipInfo();
A MembershipInfo object can be used to get information on what caused the membership change (the is*() methods) and extra information about the change (the get*() methods). Which get*() methods are valid for a particular membership message depends on what caused the message.
-
-
Field Summary
Fields Modifier and Type Field Description private SpreadGroupgroupprivate GroupIDgroupIDprivate SpreadGroup[]groupsprivate java.util.Vectormembersprivate intserviceType
-
Constructor Summary
Constructors Modifier Constructor Description protectedMembershipInfo(SpreadConnection connection, int serviceType, java.util.Vector groups, SpreadGroup sender, byte[] data, boolean daemonEndianMismatch)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description SpreadGroupgetDisconnected()Gets the private group of the member who disconnected.SpreadGroupgetGroup()Gets a SpreadGroup object representing the group that caused this message.GroupIDgetGroupID()Gets the GroupID for this group membership at this point in time.SpreadGroupgetJoined()Gets the private group of the member who joined.SpreadGroupgetLeft()Gets the private group of the member who left.SpreadGroup[]getMembers()Gets the private groups for all the members in the new group membership.SpreadGroup[]getStayed()Gets the private groups of the members who were not partitioned.booleanisCausedByDisconnect()Check if this message was caused by a disconnect.booleanisCausedByJoin()Check if this message was caused by a join.booleanisCausedByLeave()Check if this message was caused by a leave.booleanisCausedByNetwork()Check if this message was caused by a network partition.booleanisRegularMembership()Check if this is a regular membership message.booleanisSelfLeave()Check if this is a self-leave message.booleanisTransition()Check if this is a transition message.
-
-
-
Field Detail
-
serviceType
private int serviceType
-
group
private SpreadGroup group
-
groupID
private GroupID groupID
-
members
private java.util.Vector members
-
groups
private SpreadGroup[] groups
-
-
Constructor Detail
-
MembershipInfo
protected MembershipInfo(SpreadConnection connection, int serviceType, java.util.Vector groups, SpreadGroup sender, byte[] data, boolean daemonEndianMismatch)
-
-
Method Detail
-
isRegularMembership
public boolean isRegularMembership()
Check if this is a regular membership message. If true,getGroup(),getGroupID(), andgetMembers()are valid. One ofgetJoined(),getLeft(),getDisconnected(), orgetStayed()are valid depending on the type of message.- Returns:
- true if this is a regular membership message
- See Also:
getGroup(),getGroupID(),getMembers(),getJoined(),getLeft(),getDisconnected(),getStayed()
-
isTransition
public boolean isTransition()
Check if this is a transition message. If true,getGroup()is the only valid get*() function.- Returns:
- true if this is a transition message
- See Also:
getGroup()
-
isCausedByJoin
public boolean isCausedByJoin()
Check if this message was caused by a join. If true,getJoined()can be used to get the group member who joined.- Returns:
- true if this message was caused by a join
- See Also:
getJoined()
-
isCausedByLeave
public boolean isCausedByLeave()
Check if this message was caused by a leave. If true,getLeft()can be used to get the group member who left.- Returns:
- true if this message was caused by a leave
- See Also:
getLeft()
-
isCausedByDisconnect
public boolean isCausedByDisconnect()
Check if this message was caused by a disconnect. If true,getDisconnected()can be used to get the group member who left.- Returns:
- true if this message was caused by a disconnect
- See Also:
getDisconnected()
-
isCausedByNetwork
public boolean isCausedByNetwork()
Check if this message was caused by a network partition. If true,getStayed()can be used to get the members who are still in the group.- Returns:
- true if this message was caused by a network partition
- See Also:
getStayed()
-
isSelfLeave
public boolean isSelfLeave()
Check if this is a self-leave message. If true,getGroup()is the only valid get*() function.- Returns:
- true if this is a self-leave message
- See Also:
getGroup()
-
getGroup
public SpreadGroup getGroup()
Gets a SpreadGroup object representing the group that caused this message.- Returns:
- the group that caused this message
-
getGroupID
public GroupID getGroupID()
Gets the GroupID for this group membership at this point in time. This is only valid ifisRegularMembership()is true. If it is not true, null is returned.- Returns:
- the GroupID for this group memebership at this point in time
-
getMembers
public SpreadGroup[] getMembers()
Gets the private groups for all the members in the new group membership. This list will be in the same order everywhere it is received. This is only valid ifisRegularMembership()is true. If it is not true, null is returned.- Returns:
- the private groups for everyone in the new group membership
-
getJoined
public SpreadGroup getJoined()
Gets the private group of the member who joined. This is only valid if bothisRegularMembership()andisCausedByJoin()are true. If either or both are false, null is returned.- Returns:
- the private group of the member who joined
- See Also:
isCausedByJoin()
-
getLeft
public SpreadGroup getLeft()
Gets the private group of the member who left. This is only valid if bothisRegularMembership()and (isCausedByLeave()orisCausedByDisconnect()) are true. If either or both are false, null is returned.- Returns:
- the private group of the member who left
- See Also:
MembershipInfo#isCausedByDisconnect()
-
getDisconnected
public SpreadGroup getDisconnected()
Gets the private group of the member who disconnected. This is only valid if bothisRegularMembership()andisCausedByDisconnect()are true. If either or both are false, null is returned.- Returns:
- the private group of the member who disconnected
- See Also:
isCausedByDisconnect()
-
getStayed
public SpreadGroup[] getStayed()
Gets the private groups of the members who were not partitioned. This is only valid if bothisRegularMembership()andisCausedByNetwork()are true. If either or both are false, null is returned.- Returns:
- the private groups of the members who were not partitioned
- See Also:
isCausedByNetwork()
-
-