org.jgroups.blocks
Class DistributedTree

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

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

Nested Class Summary
static interface DistributedTree.DistributedTreeListener
           
static interface DistributedTree.ViewListener
           
 
Field Summary
protected  Channel channel
           
protected  RpcDispatcher disp
           
protected static Log log
           
protected  boolean rc
           
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
 
Constructor Summary
DistributedTree()
           
DistributedTree(PullPushAdapter adapter, java.io.Serializable id, long state_timeout)
           
DistributedTree(java.lang.String groupname, java.lang.String channel_properties)
           
 
Method Summary
 void _add(java.lang.String fqn)
           
 void _add(java.lang.String fqn, java.io.Serializable element)
           
 void _remove(java.lang.String fqn)
           
 void _reset(java.lang.String fqn, java.io.Serializable element)
          similar to set, but does not error if node does not exist, but rather does an add instead
 void _set(java.lang.String fqn, java.io.Serializable element)
           
 void add(java.lang.String fqn)
           
 void add(java.lang.String fqn, java.io.Serializable element)
           
 void add(java.lang.String fqn, java.io.Serializable element, int timeout)
           
 void addDistributedTreeListener(DistributedTree.DistributedTreeListener listener)
           
 void addViewListener(DistributedTree.ViewListener listener)
           
 void block()
          Block sending and receiving of messages until ViewAccepted is called
 boolean exists(java.lang.String fqn)
           
 java.io.Serializable get(java.lang.String fqn)
           
 Channel getChannel()
          Returns the Channel the DistributedTree is connected to
 java.util.Vector getChildrenNames(java.lang.String fqn)
          Returns all children of a Node as strings
 int getGroupMembersNumber()
          Returns the number of current members joined to the group
 java.lang.String getGroupName()
          Returns the name of the group that the DistributedTree is connected to
 java.lang.Object getLocalAddress()
           
 byte[] getState()
          Return a copy of the tree
 java.lang.String print()
           
 void receive(Message msg)
          Called when a message is received.
 void remove(java.lang.String fqn)
           
 void remove(java.lang.String fqn, int timeout)
           
 void removeDistributedTreeListener(DistributedTree.DistributedTreeListener listener)
           
 void removeViewListener(DistributedTree.ViewListener listener)
           
 void reset(java.lang.String fqn, java.io.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
 void reset(java.lang.String fqn, java.io.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
 void set(java.lang.String fqn, java.io.Serializable element)
           
 void set(java.lang.String fqn, java.io.Serializable element, int timeout)
           
 void setDeadlockDetection(boolean flag)
           
 void setState(byte[] data)
          Sets the group state; e.g., when joining.
 void start()
           
 void start(long timeout)
           
 void stop()
           
 void suspect(Address suspected_mbr)
          Called when a member is suspected
 void viewAccepted(View new_view)
          Called when a change in membership has occurred.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

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 Log log
Constructor Detail

DistributedTree

public DistributedTree()

DistributedTree

public DistributedTree(java.lang.String groupname,
                       java.lang.String channel_properties)

DistributedTree

public DistributedTree(PullPushAdapter adapter,
                       java.io.Serializable id,
                       long state_timeout)
                throws ChannelException
Throws:
ChannelException
Method Detail

getLocalAddress

public java.lang.Object getLocalAddress()

setDeadlockDetection

public void setDeadlockDetection(boolean flag)

start

public void start()
           throws java.lang.Exception
Throws:
java.lang.Exception

start

public void start(long timeout)
           throws java.lang.Exception
Throws:
java.lang.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(java.lang.String fqn)

add

public void add(java.lang.String fqn,
                java.io.Serializable element)

reset

public void reset(java.lang.String fqn,
                  java.io.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(java.lang.String fqn)

add

public void add(java.lang.String fqn,
                java.io.Serializable element,
                int timeout)

reset

public void reset(java.lang.String fqn,
                  java.io.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(java.lang.String fqn,
                   int timeout)

exists

public boolean exists(java.lang.String fqn)

get

public java.io.Serializable get(java.lang.String fqn)

set

public void set(java.lang.String fqn,
                java.io.Serializable element)

set

public void set(java.lang.String fqn,
                java.io.Serializable element,
                int timeout)

getChildrenNames

public java.util.Vector getChildrenNames(java.lang.String fqn)
Returns all children of a Node as strings


print

public java.lang.String print()

getGroupName

public java.lang.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(java.lang.String fqn)

_add

public void _add(java.lang.String fqn,
                 java.io.Serializable element)

_remove

public void _remove(java.lang.String fqn)

_set

public void _set(java.lang.String fqn,
                 java.io.Serializable element)

_reset

public void _reset(java.lang.String fqn,
                   java.io.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

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

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


Copyright © 1998-2009 Bela Ban / Red Hat. All Rights Reserved.