Class ReplicatedTree
java.lang.Object
org.jgroups.blocks.ReplicatedTree
- All Implemented Interfaces:
Receiver
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 final 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) voidbooleanChecks 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.voidgetState(OutputStream ostream) Allows an application to write the state to an OutputStream.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 hashmapvoidvoidsetRemoteCalls(boolean flag) voidvoidsetState(InputStream istream) Allows an application to read the state from an InputStream.final voidstart()voidstop()toString()voidviewAccepted(View new_view) Called when a change in membership has occurred.
-
Field Details
-
SEPARATOR
- See Also:
-
log
-
-
Constructor Details
-
ReplicatedTree
-
ReplicatedTree
-
ReplicatedTree
public ReplicatedTree() -
ReplicatedTree
-
-
Method Details
-
setRemoteCalls
public void setRemoteCalls(boolean flag) -
setRootNode
-
getLocalAddress
-
getMembers
-
fetchState
-
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
-
getState
Description copied from interface:ReceiverAllows an application to write the state to an OutputStream. After the state has been written, the OutputStream doesn't need to be closed as stream closing is automatically done when a calling thread returns from this callback. -
setState
Description copied from interface:ReceiverAllows an application to read the state from an InputStream. After the state has been read, the InputStream doesn't need to be closed as stream closing is automatically done when a calling thread returns from this callback. -
viewAccepted
Description copied from interface:ReceiverCalled when a change in membership has occurred. No long running actions, sending of messages or anything that could block 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 whenJChannel.connect(String)returns.- Specified by:
viewAcceptedin interfaceReceiver
-
main
-