Package org.jgroups
Class Membership
- java.lang.Object
- 
- org.jgroups.Membership
 
- 
 public class Membership extends java.lang.ObjectRepresents a membership of a cluster group. Membership is not exposed to clients and is used by JGroups internally. The membership object holds a list of Address objects that are in the same membership. Each unique address can only exist once.- Since:
- 2.0
- Author:
- Bela Ban
 
- 
- 
Constructor SummaryConstructors Constructor Description Membership()Creates a member ship object with zero membersMembership(java.util.Collection<Address> initial_members)Creates a Membership with a given initial members.Membership(Address... initial_members)
 - 
Method SummaryAll Methods Instance Methods Concrete Methods Modifier and Type Method Description Membershipadd(java.util.Collection<Address> v)Adds a list of members to this membershipMembershipadd(Address new_member)Adds a new member to this membership.Membershipadd(Address... mbrs)Membershipclear()Removes all the members from this membershipbooleancontains(Address member)Returns true if the provided member belongs to this membershipMembershipcopy()Returns a copy of this membershipAddresselementAt(int index)Returns the component at the specified indexAddressgetFirst()java.util.List<Address>getMembers()Returns a copy (clone) of the members in this membership.AddressgetNext(Address mbr)Returns the members next to mbr.AddressgetPrevious(Address mbr)Returns the members to the left of mbrbooleanisCoord(Address mbr)booleanisEmpty()Membershipmerge(java.util.Collection<Address> new_mems, java.util.Collection<Address> suspects)Merges membership with the new members and removes suspects.AddressnextCoord()Membershipremove(java.util.Collection<Address> v)Removes all the members contained in v from this membershipMembershipremove(Address old_member)Removes a member from the membership.MembershipretainAll(java.util.Collection<Address> v)Membershipset(java.util.Collection<Address> v)Clears the membership and adds all members of v This method will clear out all the old members of this membership by invoking theClearmethod.Membershipset(Membership m)Clears the membership and adds all members of a given membership parameter.intsize()Returns the number of addresses in this membershipMembershipsort()java.lang.StringtoString()
 
- 
- 
- 
Field Detail- 
membersprotected final java.util.List<Address> members 
 
- 
 - 
Constructor Detail- 
Membershippublic Membership() Creates a member ship object with zero members
 - 
Membershippublic Membership(java.util.Collection<Address> initial_members) Creates a Membership with a given initial members. The Address references are copied out of the list, so that the list passed in as parameters is not the same reference as the list that the membership class uses- Parameters:
- initial_members- a list of members that belong to this membership
 
 - 
Membershippublic Membership(Address... initial_members) 
 
- 
 - 
Method Detail- 
getMemberspublic java.util.List<Address> getMembers() Returns a copy (clone) of the members in this membership. The vector returned is immutable in reference to this object. ie, modifying the vector that is being returned in this method will not modify this membership object.- Returns:
- a list of members
 
 - 
addpublic Membership add(Address new_member) Adds a new member to this membership. If the member already exist (Address.equals(Object) returns true then the member will not be added to the membership
 - 
addpublic Membership add(Address... mbrs) 
 - 
addpublic Membership add(java.util.Collection<Address> v) Adds a list of members to this membership- Parameters:
- v- - a listof addresses
- Throws:
- java.lang.ClassCastException- if v contains objects that don't implement the Address interface
 
 - 
removepublic Membership remove(Address old_member) Removes a member from the membership. If this member doesn't exist, no action will be performed on the existing membership- Parameters:
- old_member- The member to be removed
 
 - 
removepublic Membership remove(java.util.Collection<Address> v) Removes all the members contained in v from this membership- Parameters:
- v- a list of all the members to be removed
 
 - 
retainAllpublic Membership retainAll(java.util.Collection<Address> v) 
 - 
clearpublic Membership clear() Removes all the members from this membership
 - 
setpublic Membership set(java.util.Collection<Address> v) Clears the membership and adds all members of v This method will clear out all the old members of this membership by invoking theClearmethod. Then it will add all the all members provided in the vector v- Parameters:
- v- List containing all the members this membership will contain
 
 - 
setpublic Membership set(Membership m) Clears the membership and adds all members of a given membership parameter. Prior to setting membership this method will clear out all the old members of this membership by invoking theclearmethod.- Parameters:
- m- a membership containing all the members this membership will contain
 
 - 
mergepublic Membership merge(java.util.Collection<Address> new_mems, java.util.Collection<Address> suspects) Merges membership with the new members and removes suspects. The Merge method will remove all the suspects and add in the new members. It will do it in the order 1. Remove suspects 2. Add new members the order is very important to notice.- Parameters:
- new_mems- - a vector containing a list of members (Address) to be added to this membership
- suspects- - a vector containing a list of members (Address) to be removed from this membership
 
 - 
containspublic boolean contains(Address member) Returns true if the provided member belongs to this membership- Parameters:
- member-
- Returns:
- true if the member belongs to this membership
 
 - 
sortpublic Membership sort() 
 - 
copypublic Membership copy() Returns a copy of this membership- Returns:
- an exact copy of this membership
 
 - 
sizepublic int size() Returns the number of addresses in this membership
 - 
isEmptypublic boolean isEmpty() 
 - 
elementAtpublic Address elementAt(int index) Returns the component at the specified index- Parameters:
- index- 0..size()-1
- Throws:
- java.lang.ArrayIndexOutOfBoundsException- If the index is negative or not less than the current size of this object
 
 - 
getFirstpublic Address getFirst() 
 - 
isCoordpublic boolean isCoord(Address mbr) 
 - 
nextCoordpublic Address nextCoord() 
 - 
getPreviouspublic Address getPrevious(Address mbr) Returns the members to the left of mbr- Parameters:
- mbr- The member whose neighbor to the left should be returned
- Returns:
- The neighbor to the left, or null if mbr is null, or the size is less than 2.
 
 - 
getNextpublic Address getNext(Address mbr) Returns the members next to mbr.- Parameters:
- mbr- The member whose neighbor to the right should be returned
- Returns:
- The neighbor to the right, or null if mbr is null, or the size is less than 2.
 
 - 
toStringpublic java.lang.String toString() - Overrides:
- toStringin class- java.lang.Object
 
 
- 
 
-