Package com.yahoo.vespa.curator
Class CuratorWrapper
java.lang.Object
com.yahoo.component.AbstractComponent
com.yahoo.vespa.curator.CuratorWrapper
- All Implemented Interfaces:
com.yahoo.component.Component
,com.yahoo.component.Deconstructable
,VespaCurator
,Comparable<com.yahoo.component.Component>
Implementation of
VespaCurator
which delegates to a Curator
.
This prefixes all paths with "/user"
, to ensure separation with system ZK usage.- Author:
- jonmv
-
Nested Class Summary
Nested classes/interfaces inherited from interface com.yahoo.vespa.curator.api.VespaCurator
VespaCurator.Data, VespaCurator.Meta, VespaCurator.SingletonWorker
-
Field Summary
Fields inherited from class com.yahoo.component.AbstractComponent
isDeconstructable
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionvoid
void
delete
(com.yahoo.path.Path path) Deletes the node at the given path.boolean
delete
(com.yahoo.path.Path path, int expectedVersion) Atomically compares the version in the stat of the node at the given path, with the expected version, and then: if they are equal, attempts the delete operation (seeVespaCurator.delete(Path)
), and returns true; otherwise, returnsfalse
.void
deleteAll
(com.yahoo.path.Path path) Recursively deletes any node at the given path, and any children it may have.boolean
Whether this container currently holds the exclusive lease for activation of singletons with this ID.list
(com.yahoo.path.Path path) Lists the children of the node at the given path, or throws if there is no node at that path.Creates and acquires a re-entrant lock with the given path.read
(com.yahoo.path.Path path) Returns the content and stat for the node at the given path, or empty if no node exists at that path.registerSingleton
(String singletonId, VespaCurator.SingletonWorker singleton) Register the singleton with the framework, so it may become active, and returns a synchronisation handle to any deactivations or activations triggered by this.stat
(com.yahoo.path.Path path) Returns the stat for the node at the given path, or empty if no node exists at that path.unregisterSingleton
(VespaCurator.SingletonWorker singleton) Unregister with the framework, so this singleton may no longer be active, and returns a synchronisation handle to any deactivation or activation triggered by this.write
(com.yahoo.path.Path path, byte[] data) Writes the given data to a node at the given path, creating it and its parents as needed, and returns the stat of the modified node.write
(com.yahoo.path.Path path, byte[] data, int expectedVersion) Atomically compares the version in the stat of the node at the given path, with the expected version, and then: if they are equal, attempts the write operation (seeVespaCurator.write(Path, byte[])
); otherwise, return empty.Methods inherited from class com.yahoo.component.AbstractComponent
clone, compareTo, getClassName, getId, getIdString, hasInitializedId, initId, isDeconstructable, setIsDeconstructable, toString
-
Constructor Details
-
CuratorWrapper
-
-
Method Details
-
stat
Description copied from interface:VespaCurator
Returns the stat for the node at the given path, or empty if no node exists at that path.- Specified by:
stat
in interfaceVespaCurator
-
read
Description copied from interface:VespaCurator
Returns the content and stat for the node at the given path, or empty if no node exists at that path.- Specified by:
read
in interfaceVespaCurator
-
write
Description copied from interface:VespaCurator
Writes the given data to a node at the given path, creating it and its parents as needed, and returns the stat of the modified node. Failure to write, due to connection loss, is retried a limited number of times.- Specified by:
write
in interfaceVespaCurator
-
write
public Optional<VespaCurator.Meta> write(com.yahoo.path.Path path, byte[] data, int expectedVersion) Description copied from interface:VespaCurator
Atomically compares the version in the stat of the node at the given path, with the expected version, and then: if they are equal, attempts the write operation (seeVespaCurator.write(Path, byte[])
); otherwise, return empty.- Specified by:
write
in interfaceVespaCurator
-
deleteAll
public void deleteAll(com.yahoo.path.Path path) Description copied from interface:VespaCurator
Recursively deletes any node at the given path, and any children it may have.- Specified by:
deleteAll
in interfaceVespaCurator
-
delete
public void delete(com.yahoo.path.Path path) Description copied from interface:VespaCurator
Deletes the node at the given path. Failres due to connection loss are retried a limited number of times.- Specified by:
delete
in interfaceVespaCurator
-
delete
public boolean delete(com.yahoo.path.Path path, int expectedVersion) Description copied from interface:VespaCurator
Atomically compares the version in the stat of the node at the given path, with the expected version, and then: if they are equal, attempts the delete operation (seeVespaCurator.delete(Path)
), and returns true; otherwise, returnsfalse
.- Specified by:
delete
in interfaceVespaCurator
-
list
Description copied from interface:VespaCurator
Lists the children of the node at the given path, or throws if there is no node at that path.- Specified by:
list
in interfaceVespaCurator
-
lock
Description copied from interface:VespaCurator
Creates and acquires a re-entrant lock with the given path. This blocks until the lock is acquired or timeout elapses.- Specified by:
lock
in interfaceVespaCurator
-
registerSingleton
public CompletableFuture<?> registerSingleton(String singletonId, VespaCurator.SingletonWorker singleton) Description copied from interface:VespaCurator
Register the singleton with the framework, so it may become active, and returns a synchronisation handle to any deactivations or activations triggered by this. If there is already another active singleton with the given ID (in this JVM), that will be deactivated before the new one is activated.- Specified by:
registerSingleton
in interfaceVespaCurator
-
unregisterSingleton
Description copied from interface:VespaCurator
Unregister with the framework, so this singleton may no longer be active, and returns a synchronisation handle to any deactivation or activation triggered by this. If this is the last singleton registered with its ID, then this container immediately releases the activation lease for that ID, so another container may acquire it.- Specified by:
unregisterSingleton
in interfaceVespaCurator
-
isActive
Description copied from interface:VespaCurator
Whether this container currently holds the exclusive lease for activation of singletons with this ID.- Specified by:
isActive
in interfaceVespaCurator
-
deconstruct
public void deconstruct()- Specified by:
deconstruct
in interfacecom.yahoo.component.Deconstructable
- Overrides:
deconstruct
in classcom.yahoo.component.AbstractComponent
-