Class Membership
java.lang.Object
org.apache.catalina.tribes.membership.Membership
- All Implemented Interfaces:
Cloneable
A membership implementation using simple multicast. This is the representation of a multicast membership. This
class is responsible for maintaining a list of active cluster nodes in the cluster. If a node fails to send out a
heartbeat, the node will be dismissed.
- Author:
- Peter Rossbach
-
Nested Class Summary
Modifier and TypeClassDescriptionprotected static class
Inner class that represents a member entry -
Field Summary
Modifier and TypeFieldDescriptionprotected static final Member[]
protected final Member
The local member.protected HashMap<Member,
Membership.MbrEntry> A map of all the members in the cluster.protected final Comparator<Member>
Comparator for sorting members by alive time.protected Member[]
A list of all the members in the cluster. -
Constructor Summary
ConstructorDescriptionMembership
(Member local) Membership
(Member local, boolean includeLocal) Constructs a new membershipMembership
(Member local, Comparator<Member> comp) Membership
(Member local, Comparator<Member> comp, boolean includeLocal) -
Method Summary
Modifier and TypeMethodDescriptionAdd a member to this component and sort array with memberComparatorclone()
boolean
Member[]
expire
(long maxtime) Runs a refresh cycle and returns a list of members that has expired.Member[]
Returning a list of all the members in the membership.boolean
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. i.e., delete all the members and wait for them to ping again and join this membership.
-
Field Details
-
EMPTY_MEMBERS
-
local
The local member. -
map
A map of all the members in the cluster. -
members
A list of all the members in the cluster. -
memberComparator
Comparator for sorting members by alive time.
-
-
Constructor Details
-
Membership
Constructs a new membership- Parameters:
local
- - has to be the name of the local member. Used to filter the local member from the cluster membershipincludeLocal
- - TBA
-
Membership
-
Membership
-
Membership
-
-
Method Details
-
clone
-
reset
public void reset()Reset the membership and start over fresh. i.e., delete all the members and wait for them to ping again and join this membership. -
memberAlive
Notify the membership that this member has announced itself.- Parameters:
member
- - the member that just pinged us- Returns:
- - true if this member is new to the cluster, false otherwise.
- false if this member is the local member or updated.
-
addMember
Add a member to this component and sort array with memberComparator- Parameters:
member
- The member to add- Returns:
- The member entry created for this new member.
-
removeMember
Remove a member from this component.- Parameters:
member
- The member to remove
-
expire
Runs a refresh cycle and returns a list of members that has expired. This also removes the members from the membership, in such a way that getMembers() = getMembers() - expire()- Parameters:
maxtime
- - the max time a member can remain unannounced before it is considered dead.- Returns:
- the list of expired members
-
hasMembers
public boolean hasMembers()Returning that service has members or not.- Returns:
true
if there are one or more members, otherwisefalse
-
getMember
-
contains
-
getMembers
Returning a list of all the members in the membership. We not need a copy: add and remove generate new arrays.- Returns:
- An array of the current members
-