A tree-like structure that is replicated across several members. Updates will be multicast to all group
members reliably and in the same order.
_put
public void _put(String fqn,
HashMap data)
_put
public void _put(String fqn,
String key,
Object value)
_remove
public void _remove(String fqn)
_remove
public void _remove(String fqn,
String key)
_removeData
public void _removeData(String fqn)
block
public void block()
Block sending and receiving of messages until viewAccepted() is called
- block in interface MembershipListener
exists
public boolean exists(String fqn)
Checks whether a given node exists in the tree
fqn
- The fully qualified name of the node
- boolean Whether or not the node exists
get
public Object get(String fqn,
String key)
Finds a node given its name and returns the value associated with a given key in its data
map. Returns null if the node was not found in the tree or the key was not found in the hashmap.
fqn
- The fully qualified name of the node.key
- The key.
getChannel
public Channel getChannel()
Returns the Channel the DistributedTree is connected to
getChildrenNames
public Set getChildrenNames(String fqn)
Returns all children of a given node
fqn
- The fully qualified name of the node
- Set A list of child names (as Strings)
getGroupMembersNumber
public int getGroupMembersNumber()
Returns the number of current members joined to the group
getGroupName
public String getGroupName()
Returns the name of the group that the DistributedTree is connected to
getKeys
public Set getKeys(String fqn)
Gets the keys of the data
map. Returns all keys as Strings. Returns null if node
does not exist.
fqn
- The fully qualified name of the node
- Set A set of keys (as Strings)
getLocalAddress
public Address getLocalAddress()
getMembers
public Vector getMembers()
main
public static void main(String[] args)
print
public String print(String fqn)
Prints a representation of the node defined by fqn
. Output includes name, fqn and
data.
put
public void put(String fqn,
HashMap data)
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.
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
public void put(String fqn,
String key,
Object value)
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.
fqn
- The fully qualified name of the nodekey
- The keyvalue
- The value
receive
public void receive(Message msg)
Callback. Process the contents of the message; typically an _add() or _set() request
- receive in interface MessageListener
remove
public void remove(String fqn)
Removes the node from the tree.
fqn
- The fully qualified name of the node.
remove
public void remove(String fqn,
String key)
Removes key
from the node's hashmap
fqn
- The fullly qualified name of the nodekey
- The key to be removed
run
public void run()
Request handler thread
setRemoteCalls
public void setRemoteCalls(boolean flag)
setState
public void setState(byte[] new_state)
Set the cache (tree) to this value
- setState in interface MessageListener
start
public void start()
throws Exception
toString
public String toString()
viewAccepted
public void viewAccepted(View new_view)
Called by JGroups to notify the target object of a change of membership.
No long running actions should be done in this callback in the case of Ensemble,
as this would block Ensemble. If some long running action needs to be performed,
it should be done in a separate thread (cf. ../Tests/QuoteServer.java
).
- viewAccepted in interface MembershipListener