Package com.yahoo.vespa.curator
Class Curator
java.lang.Object
com.yahoo.component.AbstractComponent
com.yahoo.vespa.curator.Curator
- All Implemented Interfaces:
com.yahoo.component.Component
,com.yahoo.component.Deconstructable
,AutoCloseable
,Comparable<com.yahoo.component.Component>
- Direct Known Subclasses:
MockCurator
Curator interface for Vespa.
This contains method for constructing common recipes and utilities as well as
a small wrapper API for common operations which uses typed paths and avoids throwing checked exceptions.
There is a mock implementation in MockCurator.
- Author:
- vegardh, bratseth
-
Nested Class Summary
Modifier and TypeClassDescriptionstatic interface
Interface for waiting for completion of an operationstatic interface
A listenable cache of all the immediate children of a curator path.static interface
A listenable cache of the content of a single curator path. -
Field Summary
Fields inherited from class com.yahoo.component.AbstractComponent
isDeconstructable
-
Constructor Summary
ModifierConstructorDescriptionCurator
(com.yahoo.cloud.config.CuratorConfig curatorConfig, com.yahoo.vespa.zookeeper.server.VespaZooKeeperServer server) protected
Curator
(String connectionSpec, String zooKeeperEnsembleConnectionSpec, Function<org.apache.curator.RetryPolicy, org.apache.curator.framework.CuratorFramework> curatorFactory) -
Method Summary
Modifier and TypeMethodDescriptionvoid
close()
boolean
create
(com.yahoo.path.Path path) boolean
Creates an empty node at a path, creating any parents as necessary.static Curator
Creates a curator instance from a comma-separated string of ZooKeeper host:port stringsstatic Curator
void
createAtomically
(com.yahoo.path.Path... paths) Creates all the given paths in a single transaction.org.apache.curator.framework.recipes.atomic.DistributedAtomicLong
createAtomicCounter
(String path) For internal use; prefer creating aCuratorCounter
createCompletionWaiter
(com.yahoo.path.Path barrierPath, String id, Duration waitForAll) createDirectoryCache
(String path, boolean cacheData, boolean dataIsCompressed, ExecutorService executorService) Creates a listenable cache which keeps in sync with changes to all the immediate children of a pathcreateFileCache
(String path, boolean dataIsCompressed) Creates a listenable cache which keeps in sync with changes to a given nodeorg.apache.curator.framework.recipes.locks.InterProcessLock
createMutex
(String lockPath) For internal use; prefer creating aLock
void
void
delete
(com.yahoo.path.Path path) Deletes the path and any children it may have.void
delete
(com.yahoo.path.Path path, boolean recursive) Deletes the path and any children it may have.void
delete
(com.yahoo.path.Path path, int expectedVersion, boolean recursive) boolean
exists
(com.yahoo.path.Path path) A convenience method which returns whether the given path existsorg.apache.curator.framework.CuratorFramework
Returns the curator framework APIgetChildren
(com.yahoo.path.Path path) Returns the names of the children at the given path.getCompletionWaiter
(com.yahoo.path.Path barrierPath, String id, Duration waitForAll) Optional<byte[]>
getData
(com.yahoo.path.Path path) Returns the data at the given path, which may be a zero-length buffer if the node exists but have no data.Optional<byte[]>
getData
(com.yahoo.path.Path path, org.apache.zookeeper.data.Stat stat) Optional<org.apache.zookeeper.data.Stat>
getStat
(com.yahoo.path.Path path) Returns the stat data at the given path.Create and acquire a re-entrant lock in given pathCreate and acquire a re-entrant lock in given path with a TTLorg.apache.zookeeper.data.Stat
set
(com.yahoo.path.Path path, byte[] data) A convenience method which sets some content at a path.org.apache.zookeeper.data.Stat
set
(com.yahoo.path.Path path, byte[] data, int expectedVersion) int
Returns the number of zooKeeper servers in this ensemble.Methods inherited from class com.yahoo.component.AbstractComponent
clone, compareTo, getClassName, getId, getIdString, hasInitializedId, initId, isDeconstructable, setIsDeconstructable, toString
-
Constructor Details
-
Curator
@Inject public Curator(com.yahoo.cloud.config.CuratorConfig curatorConfig, com.yahoo.vespa.zookeeper.server.VespaZooKeeperServer server) -
Curator
-
-
Method Details
-
create
Creates a curator instance from a comma-separated string of ZooKeeper host:port strings -
create
-
sessionTimeout
-
createAtomicCounter
public org.apache.curator.framework.recipes.atomic.DistributedAtomicLong createAtomicCounter(String path) For internal use; prefer creating aCuratorCounter
-
createMutex
For internal use; prefer creating aLock
-
getCompletionWaiter
public Curator.CompletionWaiter getCompletionWaiter(com.yahoo.path.Path barrierPath, String id, Duration waitForAll) -
createCompletionWaiter
public Curator.CompletionWaiter createCompletionWaiter(com.yahoo.path.Path barrierPath, String id, Duration waitForAll) -
createDirectoryCache
public Curator.DirectoryCache createDirectoryCache(String path, boolean cacheData, boolean dataIsCompressed, ExecutorService executorService) Creates a listenable cache which keeps in sync with changes to all the immediate children of a path -
createFileCache
Creates a listenable cache which keeps in sync with changes to a given node -
exists
public boolean exists(com.yahoo.path.Path path) A convenience method which returns whether the given path exists -
set
public org.apache.zookeeper.data.Stat set(com.yahoo.path.Path path, byte[] data) A convenience method which sets some content at a path. If the path and any of its parents does not exists they are created. -
set
public org.apache.zookeeper.data.Stat set(com.yahoo.path.Path path, byte[] data, int expectedVersion) -
create
public boolean create(com.yahoo.path.Path path) - See Also:
-
create
Creates an empty node at a path, creating any parents as necessary. If the node already exists nothing is done. Returns whether a change was attempted. -
createAtomically
public void createAtomically(com.yahoo.path.Path... paths) Creates all the given paths in a single transaction. Any paths which already exists are ignored. -
delete
public void delete(com.yahoo.path.Path path) Deletes the path and any children it may have. If the path does not exist, nothing is done. -
delete
public void delete(com.yahoo.path.Path path, boolean recursive) Deletes the path and any children it may have. If the path does not exist, nothing is done. -
delete
public void delete(com.yahoo.path.Path path, int expectedVersion, boolean recursive) -
getChildren
Returns the names of the children at the given path. If the path does not exist or have no children an empty list (never null) is returned. -
getData
Returns the data at the given path, which may be a zero-length buffer if the node exists but have no data. Empty is returned if the path does not exist. -
getData
-
getStat
Returns the stat data at the given path. Empty is returned if the path does not exist. -
lock
Create and acquire a re-entrant lock in given path with a TTL -
lock
Create and acquire a re-entrant lock in given path -
framework
public org.apache.curator.framework.CuratorFramework framework()Returns the curator framework API -
close
public void close()- Specified by:
close
in interfaceAutoCloseable
-
deconstruct
public void deconstruct()- Specified by:
deconstruct
in interfacecom.yahoo.component.Deconstructable
- Overrides:
deconstruct
in classcom.yahoo.component.AbstractComponent
-
zooKeeperEnsembleConnectionSpec
- Returns:
- The non-null connect string containing all ZooKeeper servers in the ensemble. WARNING: This may be different from the servers this Curator may connect to. TODO: Move method out of this class.
-
zooKeeperEnsembleCount
public int zooKeeperEnsembleCount()Returns the number of zooKeeper servers in this ensemble. WARNING: This may be different from the number of servers this Curator may connect to. TODO: Move method out of this class.
-