public class Membership extends Object implements Cloneable
Modifier and Type | Class and Description |
---|---|
protected static class |
Membership.MbrEntry
Inner class that represents a member entry
|
Modifier and Type | Field and Description |
---|---|
protected static Member[] |
EMPTY_MEMBERS |
protected Member |
local
The name of this membership, has to be the same as the name for the local
member
|
protected HashMap<Member,Membership.MbrEntry> |
map
A map of all the members in the cluster.
|
protected Comparator<Member> |
memberComparator
sort members by alive time
|
protected Member[] |
members
A list of all the members in the cluster.
|
Constructor and Description |
---|
Membership(Member local) |
Membership(Member local,
boolean includeLocal)
Constructs a new membership
|
Membership(Member local,
Comparator<Member> comp) |
Membership(Member local,
Comparator<Member> comp,
boolean includeLocal) |
Modifier and Type | Method and Description |
---|---|
Membership.MbrEntry |
addMember(Member member)
Add a member to this component and sort array with memberComparator
|
Object |
clone() |
boolean |
contains(Member mbr) |
Member[] |
expire(long maxtime)
Runs a refresh cycle and returns a list of members that has expired.
|
Member |
getMember(Member mbr) |
protected Membership.MbrEntry[] |
getMemberEntries()
get a copy from all member entries
|
Member[] |
getMembers()
Returning a list of all the members in the membership
We not need a copy: add and remove generate new arrays.
|
boolean |
hasMembers()
Returning that service has members or not
|
boolean |
memberAlive(Member member)
Notify the membership that this member has announced itself.
|
void |
removeMember(Member member)
Remove a member from this component.
|
void |
reset()
Reset the membership and start over fresh.
|
protected static final Member[] EMPTY_MEMBERS
protected final Member local
protected HashMap<Member,Membership.MbrEntry> map
protected Member[] members
protected final Comparator<Member> memberComparator
public Membership(Member local, boolean includeLocal)
local
- - has to be the name of the local member. Used to filter the local member from the cluster membershipincludeLocal
- - TBApublic Membership(Member local)
public Membership(Member local, Comparator<Member> comp)
public Membership(Member local, Comparator<Member> comp, boolean includeLocal)
public void reset()
public boolean memberAlive(Member member)
member
- - the member that just pinged uspublic Membership.MbrEntry addMember(Member member)
member
- The member to addpublic void removeMember(Member member)
member
- The member to removepublic Member[] expire(long maxtime)
maxtime
- - the max time a member can remain unannounced before it is considered dead.public boolean hasMembers()
public boolean contains(Member mbr)
public Member[] getMembers()
protected Membership.MbrEntry[] getMemberEntries()
Copyright © 2000-2014 Apache Software Foundation. All Rights Reserved.