Apache Tomcat 6.0.53

org.apache.catalina.tribes.membership
Class Membership

java.lang.Object
  extended by org.apache.catalina.tribes.membership.Membership

public class Membership
extends java.lang.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.

Author:
Filip Hanik, Peter Rossbach

Nested Class Summary
protected static class Membership.MbrEntry
          Inner class that represents a member entry
 
Field Summary
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 map
          A map of all the members in the cluster.
protected  java.util.Comparator memberComparator
          sort members by alive time
protected  MemberImpl[] members
          A list of all the members in the cluster.
 
Constructor Summary
Membership(MemberImpl local)
           
Membership(MemberImpl local, boolean includeLocal)
          Constructs a new membership
Membership(MemberImpl local, java.util.Comparator comp)
           
Membership(MemberImpl local, java.util.Comparator comp, boolean includeLocal)
           
 
Method Summary
 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.
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

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 java.util.HashMap map
A map of all the members in the cluster.


members

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


memberComparator

protected java.util.Comparator memberComparator
sort members by alive time

Constructor Detail

Membership

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


Membership

public Membership(MemberImpl local)

Membership

public Membership(MemberImpl local,
                  java.util.Comparator comp)

Membership

public Membership(MemberImpl local,
                  java.util.Comparator comp,
                  boolean includeLocal)
Method Detail

clone

public java.lang.Object clone()
Overrides:
clone in class java.lang.Object

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


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.

addMember

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

Parameters:
member - The member to add

removeMember

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

Parameters:
member - The member to remove

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

hasMembers

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


getMember

public MemberImpl getMember(Member mbr)

contains

public boolean contains(Member mbr)

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.


getMemberEntries

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


Apache Tomcat 6.0.53

Copyright © 2000-2017 Apache Software Foundation. All Rights Reserved.