V - tree node value type.public class DefaultDistributedDocumentTree<V> extends Object implements AsyncDocumentTree<V>
AsyncDocumentTree.
This implementation delegates execution to a backing tree implemented on top of Atomix framework.
DistributedPrimitive.Status, DistributedPrimitive.TypeDEFAULT_OPERTATION_TIMEOUT_MILLIS| Modifier and Type | Method and Description |
|---|---|
CompletableFuture<Void> |
addListener(DocumentPath path,
DocumentTreeListener<V> listener)
Registers a listener to be notified when the subtree rooted at the specified path
is modified.
|
CompletableFuture<Boolean> |
create(DocumentPath path,
V value)
Creates a document tree node if one does not exist already.
|
CompletableFuture<Boolean> |
createRecursive(DocumentPath path,
V value)
Creates a document tree node recursively by creating all missing intermediate nodes in the path.
|
CompletableFuture<Versioned<V>> |
get(DocumentPath path)
Returns the value of the tree node at specified path.
|
CompletableFuture<Map<String,Versioned<V>>> |
getChildren(DocumentPath path)
Returns the children of node at specified path in the form of a mapping from child name to child value.
|
String |
name()
Returns the name of this primitive.
|
DistributedPrimitive.Type |
primitiveType()
Returns the type of primitive.
|
CompletableFuture<Void> |
removeListener(DocumentTreeListener<V> listener)
Unregisters a previously added listener.
|
CompletableFuture<Versioned<V>> |
removeNode(DocumentPath path)
Removes the node with the specified path.
|
CompletableFuture<Boolean> |
replace(DocumentPath path,
V newValue,
long version)
Conditionally updates a tree node if the current version matches a specified version.
|
CompletableFuture<Boolean> |
replace(DocumentPath path,
V newValue,
V currentValue)
Conditionally updates a tree node if the current node value matches a specified version.
|
DocumentPath |
root()
Returns the
path to root of the tree. |
CompletableFuture<Versioned<V>> |
set(DocumentPath path,
V value)
Creates or updates a document tree node.
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitaddListeneraddStatusChangeListener, applicationId, destroy, removeStatusChangeListener, statusChangeListenerspublic String name()
DistributedPrimitivename in interface DistributedPrimitivepublic DistributedPrimitive.Type primitiveType()
DistributedPrimitiveprimitiveType in interface DistributedPrimitivepublic DocumentPath root()
AsyncDocumentTreepath to root of the tree.root in interface AsyncDocumentTree<V>public CompletableFuture<Map<String,Versioned<V>>> getChildren(DocumentPath path)
AsyncDocumentTreegetChildren in interface AsyncDocumentTree<V>path - path to the nodepublic CompletableFuture<Versioned<V>> get(DocumentPath path)
AsyncDocumentTreeget in interface AsyncDocumentTree<V>path - path to the nodeversioned value
or null if path does not point to a valid nodepublic CompletableFuture<Versioned<V>> set(DocumentPath path, V value)
AsyncDocumentTreeset in interface AsyncDocumentTree<V>path - path to the nodevalue - value to be associated with the node (null is a valid value)versioned
value or null if there was no node previously at that path.
Future will be completed with a IllegalDocumentModificationException
if the parent node (for the node to create/update) does not existpublic CompletableFuture<Boolean> create(DocumentPath path, V value)
AsyncDocumentTreecreate in interface AsyncDocumentTree<V>path - path to the nodevalue - the non-null value to be associated with the nodetrue if the new node was successfully
created. Future will be completed with false if a node already exists at the specified path.
Future will be completed exceptionally with a IllegalDocumentModificationException if the parent
node (for the node to create) does not existpublic CompletableFuture<Boolean> createRecursive(DocumentPath path, V value)
AsyncDocumentTreecreateRecursive in interface AsyncDocumentTree<V>path - path to the nodevalue - value to be associated with the node (null is a valid value)true if the new node was successfully
created. Future will be completed with false if a node already exists at the specified pathpublic CompletableFuture<Boolean> replace(DocumentPath path, V newValue, long version)
AsyncDocumentTreereplace in interface AsyncDocumentTree<V>path - path to the nodenewValue - value to associate with the node (null is a valid value)version - current version of the node for update to occurtrue if the update was made
or false if update did not happenpublic CompletableFuture<Boolean> replace(DocumentPath path, V newValue, V currentValue)
AsyncDocumentTreereplace in interface AsyncDocumentTree<V>path - path to the nodenewValue - value to associate with the node (null is a valid value)currentValue - current value of the node for update to occurtrue if the update was made
or false if update did not happenpublic CompletableFuture<Versioned<V>> removeNode(DocumentPath path)
AsyncDocumentTreeremoveNode in interface AsyncDocumentTree<V>path - path to the nodeIllegalDocumentModificationException if the node to be removed is either the root
node or has one or more children. Future will be completed with a
NoSuchDocumentPathException if the node to be removed does not existpublic CompletableFuture<Void> addListener(DocumentPath path, DocumentTreeListener<V> listener)
AsyncDocumentTreeaddListener in interface AsyncDocumentTree<V>path - path to the nodelistener - listener to be notifiedpublic CompletableFuture<Void> removeListener(DocumentTreeListener<V> listener)
AsyncDocumentTreeremoveListener in interface AsyncDocumentTree<V>listener - listener to unregister