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 interfacestatic interface -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected Channelprotected RpcDispatcherprotected static final org.apache.commons.logging.Logprotected booleanprotected booleanDetermines 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 TypeMethodDescriptionvoidvoid_add(String fqn, Serializable element) voidvoid_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) voidvoidadd(String fqn, Serializable element) voidadd(String fqn, Serializable element, int timeout) voidvoidaddViewListener(DistributedTree.ViewListener listener) voidblock()Block sending and receiving of messages until ViewAccepted is calledbooleanReturns the Channel the DistributedTree is connected togetChildrenNames(String fqn) Returns all children of a Node as stringsintReturns 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()voidCalled when a message is received.voidvoidvoidvoidvoidreset(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 callsvoidreset(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 callsvoidset(String fqn, Serializable element) voidset(String fqn, Serializable element, int timeout) voidsetDeadlockDetection(boolean flag) voidsetState(byte[] data) Sets the group state; e.g., when joining.voidstart()voidstart(long timeout) voidstop()voidCalled when a member is suspectedvoidviewAccepted(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:MessageListenerCalled when a message is received.- Specified by:
receivein interfaceMessageListener- Parameters:
msg-
-
getState
public byte[] getState()Return a copy of the tree- Specified by:
getStatein interfaceMessageListener- Returns:
- byte[]
-
setState
public void setState(byte[] data) Description copied from interface:MessageListenerSets the group state; e.g., when joining.- Specified by:
setStatein interfaceMessageListener- Parameters:
data-
-
viewAccepted
Description copied from interface:MembershipListenerCalled 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:
viewAcceptedin interfaceMembershipListener
-
suspect
Called when a member is suspected- Specified by:
suspectin interfaceMembershipListener
-
block
public void block()Block sending and receiving of messages until ViewAccepted is called- Specified by:
blockin interfaceMembershipListener
-