Class Membership

java.lang.Object
org.apache.catalina.tribes.membership.Membership
All Implemented Interfaces:
Cloneable

public class Membership extends Object implements 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
  • Field Details

    • EMPTY_MEMBERS

      protected static final Member[] EMPTY_MEMBERS
    • local

      protected final Member local
      The local member.
    • map

      A map of all the members in the cluster.
    • members

      protected volatile Member[] members
      A list of all the members in the cluster.
    • memberComparator

      protected final Comparator<Member> memberComparator
      Comparator for sorting members by alive time.
  • Constructor Details

    • Membership

      public Membership(Member local, boolean includeLocal)
      Constructs a new membership
      Parameters:
      local - - has to be the name of the local member. Used to filter the local member from the cluster membership
      includeLocal - - TBA
    • Membership

      public Membership(Member local)
    • Membership

      public Membership(Member local, Comparator<Member> comp)
    • Membership

      public Membership(Member local, Comparator<Member> comp, boolean includeLocal)
  • Method Details

    • clone

      public Membership clone()
      Overrides:
      clone in class Object
    • 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

      public boolean memberAlive(Member 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.
    • addMember

      public Membership.MbrEntry addMember(Member member)
      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

      public void removeMember(Member member)
      Remove a member from this component.
      Parameters:
      member - The member to remove
    • expire

      public Member[] 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.
      Returns:
      true if there are one or more members, otherwise false
    • getMember

      public Member getMember(Member mbr)
    • contains

      public boolean contains(Member mbr)
    • getMembers

      public Member[] 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