public class ReplicatedTree extends ReceiverAdapter
| Modifier and Type | Class and Description |
|---|---|
static class |
ReplicatedTree.Node |
static interface |
ReplicatedTree.ReplicatedTreeListener |
| Modifier and Type | Field and Description |
|---|---|
protected Log |
log |
static String |
SEPARATOR |
| Constructor and Description |
|---|
ReplicatedTree() |
ReplicatedTree(JChannel channel)
Expects an already connected channel.
|
ReplicatedTree(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) |
| Modifier and Type | Method and Description |
|---|---|
void |
_put(String fqn,
HashMap data) |
void |
_put(String fqn,
String key,
Object value) |
void |
_remove(String fqn) |
void |
_remove(String fqn,
String key) |
void |
_removeData(String fqn) |
void |
addReplicatedTreeListener(ReplicatedTree.ReplicatedTreeListener listener) |
boolean |
exists(String fqn)
Checks whether a given node exists in the tree
|
void |
fetchState(long timeout)
Fetch the group state from the current coordinator.
|
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. |
Channel |
getChannel()
Returns the Channel the DistributedTree is connected to
|
Set |
getChildrenNames(String fqn)
Returns all children of a given node
|
int |
getGroupMembersNumber()
Returns the number of current members joined to the group
|
String |
getGroupName()
Returns the name of the group that the DistributedTree is connected to
|
Set |
getKeys(String fqn)
Gets the keys of the
data map. |
Address |
getLocalAddress() |
List<Address> |
getMembers() |
void |
getState(OutputStream ostream)
Allows an application to write a state through a provided OutputStream.
|
static void |
main(String[] args) |
String |
print(String fqn)
Prints a representation of the node defined by
fqn. |
void |
put(String fqn,
HashMap data)
Adds a new node to the tree and sets its data.
|
void |
put(String fqn,
String key,
Object value)
Adds a key and value to a given node.
|
void |
receive(Message msg)
Callback.
|
void |
remove(String fqn)
Removes the node from the tree.
|
void |
remove(String fqn,
String key)
Removes
key from the node's hashmap |
void |
removeReplicatedTreeListener(ReplicatedTree.ReplicatedTreeListener listener) |
void |
setRemoteCalls(boolean flag) |
void |
setRootNode(ReplicatedTree.Node n) |
void |
setState(InputStream istream)
Allows an application to read a state through a provided InputStream.
|
void |
start() |
void |
stop() |
String |
toString() |
void |
viewAccepted(View new_view)
Called when a change in membership has occurred.
|
block, suspect, unblockpublic static final String SEPARATOR
protected final Log log
public ReplicatedTree(String groupname, String props, long state_fetch_timeout) throws Exception
Exceptionpublic ReplicatedTree(String groupname, String props, long state_fetch_timeout, boolean jmx) throws Exception
Exceptionpublic ReplicatedTree()
public void setRemoteCalls(boolean flag)
public void setRootNode(ReplicatedTree.Node n)
public Address getLocalAddress()
public void fetchState(long timeout)
throws Exception
Exceptionpublic void addReplicatedTreeListener(ReplicatedTree.ReplicatedTreeListener listener)
public void removeReplicatedTreeListener(ReplicatedTree.ReplicatedTreeListener listener)
public void stop()
public void put(String fqn, HashMap data)
fqn - The fully qualified name of the new nodedata - The new data. May be null if no data should be set in the node.public void put(String fqn, String key, Object value)
fqn - The fully qualified name of the nodekey - The keyvalue - The valuepublic void remove(String fqn)
fqn - The fully qualified name of the node.public void remove(String fqn, String key)
key from the node's hashmapfqn - The fullly qualified name of the nodekey - The key to be removedpublic boolean exists(String fqn)
fqn - The fully qualified name of the nodepublic Set getKeys(String fqn)
data map. Returns all keys as Strings. Returns null if node
does not exist.fqn - The fully qualified name of the nodepublic Object get(String fqn, String key)
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.public String print(String fqn)
fqn. Output includes name, fqn and
data.public Set getChildrenNames(String fqn)
fqn - The fully qualified name of the nodepublic String getGroupName()
public Channel getChannel()
public int getGroupMembersNumber()
public void _remove(String fqn)
public void _removeData(String fqn)
public void receive(Message msg)
receive in interface MessageListenerreceive in class ReceiverAdapterpublic void getState(OutputStream ostream) throws Exception
ReceiverAdaptergetState in interface MessageListenergetState in class ReceiverAdapterostream - the OutputStreamException - if the streaming fails, any exceptions should be thrown so that the state requester
can re-throw them and let the caller know what happenedOutputStream.close()public void setState(InputStream istream) throws Exception
ReceiverAdaptersetState in interface MessageListenersetState in class ReceiverAdapteristream - the InputStreamException - if the streaming fails, any exceptions should be thrown so that the state requester
can catch them and thus know what happenedInputStream.close()public void viewAccepted(View new_view)
ReceiverAdapterChannel.connect(String) returns.viewAccepted in interface MembershipListenerviewAccepted in class ReceiverAdapterpublic static void main(String[] args)
Copyright © 2012 JBoss by Red Hat. All Rights Reserved.