public class AtomixDocumentTree extends io.atomix.resource.AbstractResource<AtomixDocumentTree> implements AsyncDocumentTree<byte[]>
AsyncDocumentTree primitive.DistributedPrimitive.Status, DistributedPrimitive.Type| Modifier and Type | Field and Description |
|---|---|
static String |
CHANGE_SUBJECT |
DEFAULT_OPERTATION_TIMEOUT_MILLIS| Modifier | Constructor and Description |
|---|---|
protected |
AtomixDocumentTree(io.atomix.copycat.client.CopycatClient client,
Properties options) |
| Modifier and Type | Method and Description |
|---|---|
CompletableFuture<Void> |
addListener(DocumentPath path,
DocumentTreeListener<byte[]> listener)
Registers a listener to be notified when the subtree rooted at the specified path
is modified.
|
CompletableFuture<Boolean> |
create(DocumentPath path,
byte[] value)
Creates a document tree node if one does not exist already.
|
CompletableFuture<Boolean> |
createRecursive(DocumentPath path,
byte[] value)
Creates a document tree node recursively by creating all missing intermediate nodes in the path.
|
CompletableFuture<Void> |
destroy()
Purges state associated with this primitive.
|
CompletableFuture<Versioned<byte[]>> |
get(DocumentPath path)
Returns the value of the tree node at specified path.
|
CompletableFuture<Map<String,Versioned<byte[]>>> |
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.
|
CompletableFuture<AtomixDocumentTree> |
open() |
DistributedPrimitive.Type |
primitiveType()
Returns the type of primitive.
|
CompletableFuture<Void> |
removeListener(DocumentTreeListener<byte[]> listener)
Unregisters a previously added listener.
|
CompletableFuture<Versioned<byte[]>> |
removeNode(DocumentPath path)
Removes the node with the specified path.
|
CompletableFuture<Boolean> |
replace(DocumentPath path,
byte[] newValue,
byte[] currentValue)
Conditionally updates a tree node if the current node value matches a specified version.
|
CompletableFuture<Boolean> |
replace(DocumentPath path,
byte[] newValue,
long version)
Conditionally updates a tree node if the current version matches a specified version.
|
DocumentPath |
root()
Returns the
path to root of the tree. |
CompletableFuture<Versioned<byte[]>> |
set(DocumentPath path,
byte[] value)
Creates or updates a document tree node.
|
close, config, context, delete, equals, hashCode, isClosed, isOpen, onEvent, onRecovery, onStateChange, options, recover, serializer, state, toString, typeclone, finalize, getClass, notify, notifyAll, wait, wait, waitaddListeneraddStatusChangeListener, applicationId, removeStatusChangeListener, statusChangeListenerspublic static final String CHANGE_SUBJECT
protected AtomixDocumentTree(io.atomix.copycat.client.CopycatClient client,
Properties options)
public CompletableFuture<AtomixDocumentTree> open()
open in interface io.atomix.catalyst.util.Managed<AtomixDocumentTree>open in interface io.atomix.resource.Resource<AtomixDocumentTree>open in class io.atomix.resource.AbstractResource<AtomixDocumentTree>public String name()
DistributedPrimitivename in interface DistributedPrimitivepublic DistributedPrimitive.Type primitiveType()
DistributedPrimitiveprimitiveType in interface DistributedPrimitivepublic CompletableFuture<Void> destroy()
DistributedPrimitiveImplementations can override and provide appropriate clean up logic for purging any state state associated with the primitive. Whether modifications made within the destroy method have local or global visibility is left unspecified.
destroy in interface DistributedPrimitiveCompletableFuture that is completed when the operation completespublic DocumentPath root()
AsyncDocumentTreepath to root of the tree.root in interface AsyncDocumentTree<byte[]>public CompletableFuture<Map<String,Versioned<byte[]>>> getChildren(DocumentPath path)
AsyncDocumentTreegetChildren in interface AsyncDocumentTree<byte[]>path - path to the nodepublic CompletableFuture<Versioned<byte[]>> get(DocumentPath path)
AsyncDocumentTreeget in interface AsyncDocumentTree<byte[]>path - path to the nodeversioned value
or null if path does not point to a valid nodepublic CompletableFuture<Versioned<byte[]>> set(DocumentPath path, byte[] value)
AsyncDocumentTreeset in interface AsyncDocumentTree<byte[]>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, byte[] value)
AsyncDocumentTreecreate in interface AsyncDocumentTree<byte[]>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, byte[] value)
AsyncDocumentTreecreateRecursive in interface AsyncDocumentTree<byte[]>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, byte[] newValue, long version)
AsyncDocumentTreereplace in interface AsyncDocumentTree<byte[]>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, byte[] newValue, byte[] currentValue)
AsyncDocumentTreereplace in interface AsyncDocumentTree<byte[]>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<byte[]>> removeNode(DocumentPath path)
AsyncDocumentTreeremoveNode in interface AsyncDocumentTree<byte[]>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<byte[]> listener)
AsyncDocumentTreeaddListener in interface AsyncDocumentTree<byte[]>path - path to the nodelistener - listener to be notifiedpublic CompletableFuture<Void> removeListener(DocumentTreeListener<byte[]> listener)
AsyncDocumentTreeremoveListener in interface AsyncDocumentTree<byte[]>listener - listener to unregister