Package org.jgroups.blocks
Class DistributedTree
java.lang.Object
org.jgroups.blocks.DistributedTree
- All Implemented Interfaces:
MembershipListener
,MessageListener
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
Nested ClassesModifier and TypeClassDescriptionstatic interface
static interface
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected Channel
protected RpcDispatcher
protected static final org.apache.commons.logging.Log
protected boolean
protected boolean
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
ConstructorsConstructorDescriptionDistributedTree
(String groupname, String channel_properties) DistributedTree
(PullPushAdapter adapter, Serializable id, long state_timeout) -
Method Summary
Modifier and TypeMethodDescriptionvoid
void
_add
(String fqn, Serializable element) void
void
_reset
(String fqn, Serializable element) similar to set, but does not error if node does not exist, but rather does an add insteadvoid
_set
(String fqn, Serializable element) void
void
add
(String fqn, Serializable element) void
add
(String fqn, Serializable element, int timeout) void
void
addViewListener
(DistributedTree.ViewListener listener) void
block()
Block sending and receiving of messages until ViewAccepted is calledboolean
Returns the Channel the DistributedTree is connected togetChildrenNames
(String fqn) Returns all children of a Node as stringsint
Returns the number of current members joined to the groupReturns the name of the group that the DistributedTree is connected tobyte[]
getState()
Return a copy of the treeprint()
void
Called when a message is received.void
void
void
void
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 callsvoid
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 callsvoid
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
Called when a member is suspectedvoid
viewAccepted
(View new_view) Called when a change in membership has occurred.
-
Field Details
-
channel
-
disp
-
rc
protected boolean rc -
send_message
protected boolean send_messageDetermines 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
-
DistributedTree
public DistributedTree() -
DistributedTree
-
DistributedTree
public DistributedTree(PullPushAdapter adapter, Serializable id, long state_timeout) throws ChannelException - Throws:
ChannelException
-
-
Method Details
-
getLocalAddress
-
setDeadlockDetection
public void setDeadlockDetection(boolean flag) -
start
- Throws:
Exception
-
start
- Throws:
Exception
-
stop
public void stop() -
addDistributedTreeListener
-
removeDistributedTreeListener
-
addViewListener
-
removeViewListener
-
add
-
add
-
reset
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
-
add
-
reset
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
-
exists
-
get
-
set
-
set
-
getChildrenNames
Returns all children of a Node as strings -
print
-
getGroupName
Returns the name of the group that the DistributedTree is connected to- Returns:
- String
-
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
-
_add
-
_remove
-
_set
-
_reset
similar to set, but does not error if node does not exist, but rather does an add instead -
receive
Description copied from interface:MessageListener
Called when a message is received.- Specified by:
receive
in interfaceMessageListener
- Parameters:
msg
-
-
getState
public byte[] getState()Return a copy of the tree- Specified by:
getState
in interfaceMessageListener
- 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 interfaceMessageListener
- Parameters:
data
-
-
viewAccepted
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 whenChannel.connect(String)
returns.- Specified by:
viewAccepted
in interfaceMembershipListener
-
suspect
Called when a member is suspected- Specified by:
suspect
in interfaceMembershipListener
-
block
public void block()Block sending and receiving of messages until ViewAccepted is called- Specified by:
block
in interfaceMembershipListener
-