Class DistributedTree

java.lang.Object
org.jgroups.blocks.DistributedTree
All Implemented Interfaces:
MembershipListener, MessageListener

public class DistributedTree extends Object implements MessageListener, MembershipListener
A tree-like structure that is replicated across several members. Updates will be multicast to all group members reliably and in the same order.
Author:
Bela Ban, Alfonso Olias-Sanz
  • Field Details

    • channel

      protected Channel channel
    • disp

      protected RpcDispatcher disp
    • rc

      protected boolean rc
    • send_message

      protected boolean send_message
      Determines when the updates have to be sent across the network, avoids sending unnecessary messages when there are no member in the group
    • log

      protected static final org.apache.commons.logging.Log log
  • Constructor Details

  • Method Details

    • getLocalAddress

      public Object getLocalAddress()
    • setDeadlockDetection

      public void setDeadlockDetection(boolean flag)
    • start

      public void start() throws Exception
      Throws:
      Exception
    • start

      public void start(long timeout) throws Exception
      Throws:
      Exception
    • stop

      public void stop()
    • addDistributedTreeListener

      public void addDistributedTreeListener(DistributedTree.DistributedTreeListener listener)
    • removeDistributedTreeListener

      public void removeDistributedTreeListener(DistributedTree.DistributedTreeListener listener)
    • addViewListener

      public void addViewListener(DistributedTree.ViewListener listener)
    • removeViewListener

      public void removeViewListener(DistributedTree.ViewListener listener)
    • add

      public void add(String fqn)
    • add

      public void add(String fqn, Serializable element)
    • reset

      public void reset(String fqn, Serializable element)
      resets an existing node, useful after a merge when you want to tell other members of your state, but do not wish to remove and then add as two separate calls
    • remove

      public void remove(String fqn)
    • add

      public void add(String fqn, Serializable element, int timeout)
    • reset

      public void reset(String fqn, Serializable element, int timeout)
      resets an existing node, useful after a merge when you want to tell other members of your state, but do not wish to remove and then add as two separate calls
    • remove

      public void remove(String fqn, int timeout)
    • exists

      public boolean exists(String fqn)
    • get

      public Serializable get(String fqn)
    • set

      public void set(String fqn, Serializable element)
    • set

      public void set(String fqn, Serializable element, int timeout)
    • getChildrenNames

      public Vector getChildrenNames(String fqn)
      Returns all children of a Node as strings
    • print

      public String print()
    • getGroupName

      public String getGroupName()
      Returns the name of the group that the DistributedTree is connected to
      Returns:
      String
    • getChannel

      public Channel getChannel()
      Returns the Channel the DistributedTree is connected to
      Returns:
      Channel
    • getGroupMembersNumber

      public int getGroupMembersNumber()
      Returns the number of current members joined to the group
      Returns:
      int
    • _add

      public void _add(String fqn)
    • _add

      public void _add(String fqn, Serializable element)
    • _remove

      public void _remove(String fqn)
    • _set

      public void _set(String fqn, Serializable element)
    • _reset

      public void _reset(String fqn, Serializable element)
      similar to set, but does not error if node does not exist, but rather does an add instead
    • receive

      public void receive(Message msg)
      Description copied from interface: MessageListener
      Called when a message is received.
      Specified by:
      receive in interface MessageListener
      Parameters:
      msg -
    • getState

      public byte[] getState()
      Return a copy of the tree
      Specified by:
      getState in interface MessageListener
      Returns:
      byte[]
    • setState

      public void setState(byte[] data)
      Description copied from interface: MessageListener
      Sets the group state; e.g., when joining.
      Specified by:
      setState in interface MessageListener
      Parameters:
      data -
    • viewAccepted

      public void viewAccepted(View new_view)
      Description copied from interface: MembershipListener
      Called when a change in membership has occurred. No long running actions or sending of messages should be done in this callback. If some long running action needs to be performed, it should be done in a separate thread.

      Note that on reception of the first view (a new member just joined), the channel will not yet be in the connected state. This only happens when Channel.connect(String) returns.

      Specified by:
      viewAccepted in interface MembershipListener
    • suspect

      public void suspect(Address suspected_mbr)
      Called when a member is suspected
      Specified by:
      suspect in interface MembershipListener
    • block

      public void block()
      Block sending and receiving of messages until ViewAccepted is called
      Specified by:
      block in interface MembershipListener