org.apache.catalina.tribes.membership

Class Membership

public class Membership extends Object

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.

Version: $Revision: 771009 $, $Date: 2009-05-03 03:15:41 +0200 (Sun, 03 May 2009) $

Author: Filip Hanik Peter Rossbach

Nested Class Summary
protected static classMembership.MbrEntry
Inner class that represents a member entry
Field Summary
protected static MemberImpl[]EMPTY_MEMBERS
protected MemberImpllocal
The name of this membership, has to be the same as the name for the local member
protected HashMapmap
A map of all the members in the cluster.
protected ComparatormemberComparator
sort members by alive time
protected MemberImpl[]members
A list of all the members in the cluster.
Constructor Summary
Membership(MemberImpl local, boolean includeLocal)
Constructs a new membership
Membership(MemberImpl local)
Membership(MemberImpl local, Comparator comp)
Membership(MemberImpl local, Comparator comp, boolean includeLocal)
Method Summary
Membership.MbrEntryaddMember(MemberImpl member)
Add a member to this component and sort array with memberComparator
Objectclone()
booleancontains(Member mbr)
MemberImpl[]expire(long maxtime)
Runs a refresh cycle and returns a list of members that has expired.
MemberImplgetMember(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.
booleanhasMembers()
Returning that service has members or not
booleanmemberAlive(MemberImpl member)
Notify the membership that this member has announced itself.
voidremoveMember(MemberImpl member)
Remove a member from this component.
voidreset()
Reset the membership and start over fresh.

Field Detail

EMPTY_MEMBERS

protected static final MemberImpl[] EMPTY_MEMBERS

local

protected MemberImpl local
The name of this membership, has to be the same as the name for the local member

map

protected HashMap map
A map of all the members in the cluster.

memberComparator

protected Comparator memberComparator
sort members by alive time

members

protected MemberImpl[] members
A list of all the members in the cluster.

Constructor Detail

Membership

public Membership(MemberImpl local, boolean includeLocal)
Constructs a new membership

Parameters: name - has to be the name of the local member. Used to filter the local member from the cluster membership

Membership

public Membership(MemberImpl local)

Membership

public Membership(MemberImpl local, Comparator comp)

Membership

public Membership(MemberImpl local, Comparator comp, boolean includeLocal)

Method Detail

addMember

public Membership.MbrEntry addMember(MemberImpl member)
Add a member to this component and sort array with memberComparator

Parameters: member The member to add

clone

public Object clone()

contains

public boolean contains(Member mbr)

expire

public MemberImpl[] expire(long maxtime)
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

getMember

public MemberImpl getMember(Member mbr)

getMemberEntries

protected Membership.MbrEntry[] getMemberEntries()
get a copy from all member entries

getMembers

public MemberImpl[] getMembers()
Returning a list of all the members in the membership We not need a copy: add and remove generate new arrays.

hasMembers

public boolean hasMembers()
Returning that service has members or not

memberAlive

public boolean memberAlive(MemberImpl member)
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.

removeMember

public void removeMember(MemberImpl member)
Remove a member from this component.

Parameters: member The member to remove

reset

public void reset()
Reset the membership and start over fresh. Ie, delete all the members and wait for them to ping again and join this membership
Copyright © 2000-2011 Apache Software Foundation. All Rights Reserved.