org.jgroups.blocks

Class DistributedTree

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.
Authors:
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

Constructor Summary

DistributedTree()
DistributedTree(String groupname, String channel_properties)
DistributedTree(PullPushAdapter adapter, Serializable id, long state_timeout)

Method Summary

void
_add(String fqn)
void
_add(String fqn, Serializable element)
void
_remove(String fqn)
void
_reset(String fqn, Serializable element)
similar to set, but does not error if node does not exist, but rather does an add instead
void
_set(String fqn, Serializable element)
void
add(String fqn)
void
add(String fqn, Serializable element)
void
add(String fqn, 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(String fqn)
Serializable
get(String fqn)
Channel
getChannel()
Returns the Channel the DistributedTree is connected to
Vector
getChildrenNames(String fqn)
Returns all children of a Node as strings
int
getGroupMembersNumber()
Returns the number of current members joined to the group
String
getGroupName()
Returns the name of the group that the DistributedTree is connected to
Object
getLocalAddress()
byte[]
getState()
Return a copy of the tree
String
print()
void
receive(Message msg)
Called when a message is received.
void
remove(String fqn)
void
remove(String fqn, int timeout)
void
removeDistributedTreeListener(DistributedTree.DistributedTreeListener listener)
void
removeViewListener(DistributedTree.ViewListener listener)
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
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
void
set(String fqn, Serializable element)
void
set(String fqn, 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.

Field Details

channel

protected Channel channel

disp

protected RpcDispatcher disp

log

protected static final Log log

Constructor Details

DistributedTree

public DistributedTree()

DistributedTree

public DistributedTree(String groupname,
                       String channel_properties)

DistributedTree

public DistributedTree(PullPushAdapter adapter,
                       Serializable id,
                       long state_timeout)
            throws ChannelException

Method Details

_add

public void _add(String fqn)

_add

public void _add(String fqn,
                 Serializable element)

_remove

public void _remove(String fqn)

_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

_set

public void _set(String fqn,
                 Serializable element)

add

public void add(String fqn)

add

public void add(String fqn,
                Serializable element)

add

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

addDistributedTreeListener

public void addDistributedTreeListener(DistributedTree.DistributedTreeListener listener)

addViewListener

public void addViewListener(DistributedTree.ViewListener listener)

block

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

exists

public boolean exists(String fqn)

get

public Serializable get(String fqn)

getChannel

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

getChildrenNames

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

getGroupMembersNumber

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

getGroupName

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

getLocalAddress

public Object getLocalAddress()

getState

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

print

public String print()

receive

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

remove

public void remove(String fqn)

remove

public void remove(String fqn,
                   int timeout)

removeDistributedTreeListener

public void removeDistributedTreeListener(DistributedTree.DistributedTreeListener listener)

removeViewListener

public void removeViewListener(DistributedTree.ViewListener listener)

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

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

set

public void set(String fqn,
                Serializable element)

set

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

setDeadlockDetection

public void setDeadlockDetection(boolean flag)

setState

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

start

public void start()
            throws Exception

start

public void start(long timeout)
            throws Exception

stop

public void stop()

suspect

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

viewAccepted

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

Copyright B) 1998-2005 Bela Ban. All Rights Reserved.