CuratorCache
@Deprecated public class PathChildrenCache extends Object implements Closeable
A utility that attempts to keep all data from all children of a ZK path locally cached. This class will watch the ZK path, respond to update/create/delete events, pull down the data, etc. You can register a listener that will get notified when changes occur.
IMPORTANT - it's not possible to stay transactionally in sync. Users of this class must be prepared for false-positives and false-negatives. Additionally, always use the version number when updating data to avoid overwriting another process' change.
Modifier and Type | Class and Description |
---|---|
static class |
PathChildrenCache.StartMode
Deprecated.
Method of priming cache on
start(StartMode) |
Modifier and Type | Field and Description |
---|---|
static Supplier<ThreadFactory> |
defaultThreadFactorySupplier
Deprecated.
|
Constructor and Description |
---|
PathChildrenCache(CuratorFramework client,
String path,
boolean cacheData)
Deprecated.
|
PathChildrenCache(CuratorFramework client,
String path,
boolean cacheData,
boolean dataIsCompressed,
CloseableExecutorService executorService)
Deprecated.
|
PathChildrenCache(CuratorFramework client,
String path,
boolean cacheData,
boolean dataIsCompressed,
ExecutorService executorService)
Deprecated.
|
PathChildrenCache(CuratorFramework client,
String path,
boolean cacheData,
boolean dataIsCompressed,
ThreadFactory threadFactory)
Deprecated.
|
PathChildrenCache(CuratorFramework client,
String path,
boolean cacheData,
ThreadFactory threadFactory)
Deprecated.
|
PathChildrenCache(CuratorFramework client,
String path,
PathChildrenCacheMode mode)
Deprecated.
|
PathChildrenCache(CuratorFramework client,
String path,
PathChildrenCacheMode mode,
ThreadFactory threadFactory)
Deprecated.
|
Modifier and Type | Method and Description |
---|---|
void |
clear()
Deprecated.
Clears the current data without beginning a new query and without generating any events
for listeners.
|
void |
clearAndRefresh()
Deprecated.
Clear out current data and begin a new query on the path
|
void |
clearDataBytes(String fullPath)
Deprecated.
As a memory optimization, you can clear the cached data bytes for a node.
|
boolean |
clearDataBytes(String fullPath,
int ifVersion)
Deprecated.
As a memory optimization, you can clear the cached data bytes for a node.
|
void |
close()
Deprecated.
Close/end the cache
|
protected void |
ensurePath()
Deprecated.
|
List<ChildData> |
getCurrentData()
Deprecated.
Return the current data.
|
ChildData |
getCurrentData(String fullPath)
Deprecated.
Return the current data for the given path.
|
Listenable<PathChildrenCacheListener> |
getListenable()
Deprecated.
Return the cache listenable
|
protected void |
handleException(Throwable e)
Deprecated.
Default behavior is just to log the exception
|
void |
rebuild()
Deprecated.
NOTE: this is a BLOCKING method.
|
void |
rebuildNode(String fullPath)
Deprecated.
NOTE: this is a BLOCKING method.
|
protected void |
remove(String fullPath)
Deprecated.
|
void |
start()
Deprecated.
Start the cache.
|
void |
start(boolean buildInitial)
Deprecated.
use
start(StartMode) |
void |
start(PathChildrenCache.StartMode mode)
Deprecated.
Start the cache.
|
public static final Supplier<ThreadFactory> defaultThreadFactorySupplier
@Deprecated public PathChildrenCache(CuratorFramework client, String path, PathChildrenCacheMode mode)
PathChildrenCache(CuratorFramework, String, boolean)
insteadclient
- the clientpath
- path to watchmode
- caching mode@Deprecated public PathChildrenCache(CuratorFramework client, String path, PathChildrenCacheMode mode, ThreadFactory threadFactory)
PathChildrenCache(CuratorFramework, String, boolean, ThreadFactory)
insteadclient
- the clientpath
- path to watchmode
- caching modethreadFactory
- factory to use when creating internal threadspublic PathChildrenCache(CuratorFramework client, String path, boolean cacheData)
client
- the clientpath
- path to watchcacheData
- if true, node contents are cached in addition to the statpublic PathChildrenCache(CuratorFramework client, String path, boolean cacheData, ThreadFactory threadFactory)
client
- the clientpath
- path to watchcacheData
- if true, node contents are cached in addition to the statthreadFactory
- factory to use when creating internal threadspublic PathChildrenCache(CuratorFramework client, String path, boolean cacheData, boolean dataIsCompressed, ThreadFactory threadFactory)
client
- the clientpath
- path to watchcacheData
- if true, node contents are cached in addition to the statdataIsCompressed
- if true, data in the path is compressedthreadFactory
- factory to use when creating internal threadspublic PathChildrenCache(CuratorFramework client, String path, boolean cacheData, boolean dataIsCompressed, ExecutorService executorService)
client
- the clientpath
- path to watchcacheData
- if true, node contents are cached in addition to the statdataIsCompressed
- if true, data in the path is compressedexecutorService
- ExecutorService to use for the PathChildrenCache's background thread. This service should be single threaded, otherwise the cache may see inconsistent results.public PathChildrenCache(CuratorFramework client, String path, boolean cacheData, boolean dataIsCompressed, CloseableExecutorService executorService)
client
- the clientpath
- path to watchcacheData
- if true, node contents are cached in addition to the statdataIsCompressed
- if true, data in the path is compressedexecutorService
- Closeable ExecutorService to use for the PathChildrenCache's background thread. This service should be single threaded, otherwise the cache may see inconsistent results.public void start() throws Exception
Exception
- errors@Deprecated public void start(boolean buildInitial) throws Exception
start(StartMode)
start()
but gives the option of doing an initial buildpublic void start(PathChildrenCache.StartMode mode) throws Exception
mode
- Method for priming the cacheException
- errorspublic void rebuild() throws Exception
Exception
- errorspublic void rebuildNode(String fullPath) throws Exception
fullPath
- full path of the node to rebuildException
- errorspublic void close() throws IOException
close
in interface Closeable
close
in interface AutoCloseable
IOException
- errorspublic Listenable<PathChildrenCacheListener> getListenable()
public List<ChildData> getCurrentData()
public ChildData getCurrentData(String fullPath)
null
is returned.fullPath
- full path to the node to checkpublic void clearDataBytes(String fullPath)
ChildData.getData()
for this node will return null
.fullPath
- the path of the node to clearpublic boolean clearDataBytes(String fullPath, int ifVersion)
ChildData.getData()
for this node will return null
.fullPath
- the path of the node to clearifVersion
- if non-negative, only clear the data if the data's version matches this versionpublic void clearAndRefresh() throws Exception
Exception
- errorspublic void clear()
protected void handleException(Throwable e)
e
- the exceptionprotected void remove(String fullPath)
Copyright © 2011–2023 The Apache Software Foundation. All rights reserved.