public class Membership
extends java.lang.Object
implements java.lang.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 name of this membership, has to be the same as the name for the local
member
|
protected java.util.HashMap<MemberImpl,Membership.MbrEntry> |
map
A map of all the members in the cluster.
|
protected java.util.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,
java.util.Comparator<Member> comp) |
Membership(MemberImpl local,
java.util.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
|
java.lang.Object |
clone() |
boolean |
contains(Member mbr) |
MemberImpl[] |
expire(long maxtime)
Runs a refresh cycle and returns a list of members that has expired.
|
MemberImpl |
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 java.util.HashMap<MemberImpl,Membership.MbrEntry> map
protected MemberImpl[] members
protected java.util.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, java.util.Comparator<Member> comp)
public Membership(MemberImpl local, java.util.Comparator<Member> comp, boolean includeLocal)
public java.lang.Object clone()
clone
in class java.lang.Object
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 MemberImpl getMember(Member mbr)
public boolean contains(Member mbr)
public MemberImpl[] getMembers()
protected Membership.MbrEntry[] getMemberEntries()
Copyright © 2000-2015 Apache Software Foundation. All Rights Reserved.