Class ReplicatedTree
java.lang.Object
org.jgroups.blocks.ReplicatedTree
- All Implemented Interfaces:
Runnable, 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 Jan 17 2002, Alfonso Olias-Sanz
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classstatic interface -
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionReplicatedTree(String groupname, String props, long state_fetch_timeout) Creates a channel with the given properties.ReplicatedTree(String groupname, String props, long state_fetch_timeout, boolean jmx) ReplicatedTree(JChannel channel) Expects an already connected channel. -
Method Summary
Modifier and TypeMethodDescriptionvoidvoidvoidvoidvoid_removeData(String fqn) voidvoidblock()Block sending and receiving of messages until viewAccepted() is calledbooleanChecks whether a given node exists in the treevoidfetchState(long timeout) Fetch the group state from the current coordinator.Finds a node given its name and returns the value associated with a given key in itsdatamap.Returns the Channel the DistributedTree is connected togetChildrenNames(String fqn) Returns all children of a given nodeintReturns the number of current members joined to the groupReturns the name of the group that the DistributedTree is connected toGets the keys of thedatamap.byte[]getState()Return a copy of the current cache (tree)static voidPrints a representation of the node defined byfqn.voidAdds a key and value to a given node.voidAdds a new node to the tree and sets its data.voidCallback.voidRemoves the node from the tree.voidRemoveskeyfrom the node's hashmapvoidvoidrun()Request handler threadvoidsetRemoteCalls(boolean flag) voidvoidsetState(byte[] new_state) Set the cache (tree) to this valuefinal voidstart()voidstop()voidCalled when a member is suspectedtoString()voidviewAccepted(View new_view) Called when a change in membership has occurred.
-
Field Details
-
SEPARATOR
- See Also:
-
log
protected final org.apache.commons.logging.Log log
-
-
Constructor Details
-
ReplicatedTree
-
ReplicatedTree
-
ReplicatedTree
public ReplicatedTree() -
ReplicatedTree
-
-
Method Details
-
setRemoteCalls
public void setRemoteCalls(boolean flag) -
setRootNode
-
getLocalAddress
-
getMembers
-
fetchState
Fetch the group state from the current coordinator. If successful, this will trigger setState(). -
addReplicatedTreeListener
-
removeReplicatedTreeListener
-
start
-
stop
public void stop() -
put
Adds a new node to the tree and sets its data. If the node doesn not yet exist, it will be created. Also, parent nodes will be created if not existent. If the node already has data, then the new data will override the old one. If the node already existed, a nodeModified() notification will be generated. Otherwise a nodeCreated() motification will be emitted.- Parameters:
fqn- The fully qualified name of the new nodedata- The new data. May be null if no data should be set in the node.
-
put
Adds a key and value to a given node. If the node doesn't exist, it will be created. If the node already existed, a nodeModified() notification will be generated. Otherwise a nodeCreated() motification will be emitted.- Parameters:
fqn- The fully qualified name of the nodekey- The keyvalue- The value
-
remove
Removes the node from the tree.- Parameters:
fqn- The fully qualified name of the node.
-
remove
-
exists
Checks whether a given node exists in the tree- Parameters:
fqn- The fully qualified name of the node- Returns:
- boolean Whether or not the node exists
-
getKeys
-
get
-
print
-
getChildrenNames
-
toString
-
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
-
_put
-
_put
-
_remove
-
_remove
-
_removeData
-
receive
Callback. Process the contents of the message; typically an _add() or _set() request- Specified by:
receivein interfaceMessageListener- Parameters:
msg-
-
getState
public byte[] getState()Return a copy of the current cache (tree)- Specified by:
getStatein interfaceMessageListener- Returns:
- byte[]
-
setState
public void setState(byte[] new_state) Set the cache (tree) to this value- Specified by:
setStatein interfaceMessageListener- Parameters:
new_state-
-
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
-
run
-
main
-