Package spread

Class MembershipInfo


  • public class MembershipInfo
    extends java.lang.Object
    A MembershipInfo object represents information stored in a membership message. To check if a message is a membership message, use SpreadMessage.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 Detail

      • serviceType

        private int serviceType
      • members

        private java.util.Vector members
    • Constructor Detail

      • MembershipInfo

        protected MembershipInfo​(SpreadConnection connection,
                                 int serviceType,
                                 java.util.Vector groups,
                                 SpreadGroup sender,
                                 byte[] data,
                                 boolean daemonEndianMismatch)
    • Method Detail

      • 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 if isRegularMembership() 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 if isRegularMembership() is true. If it is not true, null is returned.
        Returns:
        the private groups for everyone in the new group membership