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 MemberImpl[] |
EMPTY_MEMBERS |
protected MemberImpl |
local
The local member.
|
protected HashMap<MemberImpl,Membership.MbrEntry> |
map
A map of all the members in the cluster.
|
protected Comparator<Member> |
memberComparator
sort members by alive time
|
protected MemberImpl[] |
members
A list of all the members in the cluster.
|
Constructor and Description |
---|
Membership(MemberImpl local) |
Membership(MemberImpl local,
boolean includeLocal)
Constructs a new membership
|
Membership(MemberImpl local,
Comparator<Member> comp) |
Membership(MemberImpl local,
Comparator<Member> comp,
boolean includeLocal) |
Modifier and Type | Method and Description |
---|---|
Membership.MbrEntry |
addMember(MemberImpl member)
Add a member to this component and sort array with memberComparator
|
Membership |
clone() |
boolean |
contains(Member mbr) |
MemberImpl[] |
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
|
MemberImpl[] |
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(MemberImpl member)
Notify the membership that this member has announced itself.
|
void |
removeMember(MemberImpl member)
Remove a member from this component.
|
void |
reset()
Reset the membership and start over fresh.
|
protected static final MemberImpl[] EMPTY_MEMBERS
protected MemberImpl local
protected HashMap<MemberImpl,Membership.MbrEntry> map
protected MemberImpl[] members
protected Comparator<Member> memberComparator
public Membership(MemberImpl 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(MemberImpl local)
public Membership(MemberImpl local, Comparator<Member> comp)
public Membership(MemberImpl local, Comparator<Member> comp, boolean includeLocal)
public Membership clone()
public void reset()
public boolean memberAlive(MemberImpl member)
member
- - the member that just pinged uspublic Membership.MbrEntry addMember(MemberImpl member)
member
- The member to addpublic void removeMember(MemberImpl member)
member
- The member to removepublic MemberImpl[] 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 MemberImpl[] getMembers()
protected Membership.MbrEntry[] getMemberEntries()
Copyright © 2000-2021 Apache Software Foundation. All Rights Reserved.