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
,VespaCurator
,AutoCloseable
,Comparable<com.yahoo.component.Component>
- Direct Known Subclasses:
MockCurator
public class Curator
extends com.yahoo.component.AbstractComponent
implements VespaCurator, AutoCloseable
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.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) 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 parentPath, String waiterNode, int numMembers, String id) 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 given path and any children it may have.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 waiterPath, int numMembers, String id) 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<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 pathvoid
set
(com.yahoo.path.Path path, byte[] data) A convenience method which sets some content at a path.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.VespaZooKeeperServer server) -
Curator
-
-
Method Details
-
create
Creates a curator instance from a comma-separated string of ZooKeeper host:port strings -
create
-
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 waiterPath, int numMembers, String id) -
createCompletionWaiter
public Curator.CompletionWaiter createCompletionWaiter(com.yahoo.path.Path parentPath, String waiterNode, int numMembers, String id) -
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 void 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. -
create
public boolean create(com.yahoo.path.Path path) 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 given path and any children it may have. If the path does not exists nothing is done. -
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. -
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- Specified by:
lock
in interfaceVespaCurator
-
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.
-