Class PathChildrenCache
java.lang.Object
org.apache.curator.framework.recipes.cache.PathChildrenCache
- All Implemented Interfaces:
Closeable
,AutoCloseable
Deprecated.
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.
-
Nested Class Summary
Modifier and TypeClassDescriptionstatic enum
Deprecated.Method of priming cache onstart(StartMode)
-
Field Summary
-
Constructor Summary
ConstructorDescriptionPathChildrenCache
(CuratorFramework client, String path, boolean cacheData) 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, boolean dataIsCompressed, CloseableExecutorService executorService) 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. -
Method Summary
Modifier and TypeMethodDescriptionvoid
clear()
Deprecated.Clears the current data without beginning a new query and without generating any events for listeners.void
Deprecated.Clear out current data and begin a new query on the pathvoid
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 cacheprotected void
Deprecated.Deprecated.Return the current data.getCurrentData
(String fullPath) Deprecated.Return the current data for the given path.Deprecated.Return the cache listenableprotected void
Deprecated.Default behavior is just to log the exceptionvoid
rebuild()
Deprecated.NOTE: this is a BLOCKING method.void
rebuildNode
(String fullPath) Deprecated.NOTE: this is a BLOCKING method.protected void
Deprecated.void
start()
Deprecated.Start the cache.void
start
(boolean buildInitial) Deprecated.usestart(StartMode)
void
Deprecated.Start the cache.
-
Field Details
-
defaultThreadFactorySupplier
Deprecated.
-
-
Constructor Details
-
PathChildrenCache
@Deprecated public PathChildrenCache(CuratorFramework client, String path, PathChildrenCacheMode mode) Deprecated.- Parameters:
client
- the clientpath
- path to watchmode
- caching mode
-
PathChildrenCache
@Deprecated public PathChildrenCache(CuratorFramework client, String path, PathChildrenCacheMode mode, ThreadFactory threadFactory) Deprecated.- Parameters:
client
- the clientpath
- path to watchmode
- caching modethreadFactory
- factory to use when creating internal threads
-
PathChildrenCache
Deprecated.- Parameters:
client
- the clientpath
- path to watchcacheData
- if true, node contents are cached in addition to the stat
-
PathChildrenCache
public PathChildrenCache(CuratorFramework client, String path, boolean cacheData, ThreadFactory threadFactory) Deprecated.- Parameters:
client
- the clientpath
- path to watchcacheData
- if true, node contents are cached in addition to the statthreadFactory
- factory to use when creating internal threads
-
PathChildrenCache
public PathChildrenCache(CuratorFramework client, String path, boolean cacheData, boolean dataIsCompressed, ThreadFactory threadFactory) Deprecated.- Parameters:
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 threads
-
PathChildrenCache
public PathChildrenCache(CuratorFramework client, String path, boolean cacheData, boolean dataIsCompressed, ExecutorService executorService) Deprecated.- Parameters:
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.
-
PathChildrenCache
public PathChildrenCache(CuratorFramework client, String path, boolean cacheData, boolean dataIsCompressed, CloseableExecutorService executorService) Deprecated.- Parameters:
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.
-
-
Method Details
-
start
Deprecated.Start the cache. The cache is not started automatically. You must call this method.- Throws:
Exception
- errors
-
start
Deprecated.usestart(StartMode)
Same asstart()
but gives the option of doing an initial build -
start
Deprecated.Start the cache. The cache is not started automatically. You must call this method.- Parameters:
mode
- Method for priming the cache- Throws:
Exception
- errors
-
rebuild
Deprecated.NOTE: this is a BLOCKING method. Completely rebuild the internal cache by querying for all needed data WITHOUT generating any events to send to listeners.- Throws:
Exception
- errors
-
rebuildNode
Deprecated.NOTE: this is a BLOCKING method. Rebuild the internal cache for the given node by querying for all needed data WITHOUT generating any events to send to listeners.- Parameters:
fullPath
- full path of the node to rebuild- Throws:
Exception
- errors
-
close
Deprecated.Close/end the cache- Specified by:
close
in interfaceAutoCloseable
- Specified by:
close
in interfaceCloseable
- Throws:
IOException
- errors
-
getListenable
Deprecated.Return the cache listenable- Returns:
- listenable
-
getCurrentData
Deprecated.Return the current data. There are no guarantees of accuracy. This is merely the most recent view of the data. The data is returned in sorted order.- Returns:
- list of children and data
-
getCurrentData
Deprecated.Return the current data for the given path. There are no guarantees of accuracy. This is merely the most recent view of the data. If there is no child with that path,null
is returned.- Parameters:
fullPath
- full path to the node to check- Returns:
- data or null
-
clearDataBytes
Deprecated.As a memory optimization, you can clear the cached data bytes for a node. Subsequent calls toChildData.getData()
for this node will returnnull
.- Parameters:
fullPath
- the path of the node to clear
-
clearDataBytes
Deprecated.As a memory optimization, you can clear the cached data bytes for a node. Subsequent calls toChildData.getData()
for this node will returnnull
.- Parameters:
fullPath
- the path of the node to clearifVersion
- if non-negative, only clear the data if the data's version matches this version- Returns:
- true if the data was cleared
-
clearAndRefresh
Deprecated.Clear out current data and begin a new query on the path- Throws:
Exception
- errors
-
clear
public void clear()Deprecated.Clears the current data without beginning a new query and without generating any events for listeners. -
handleException
Deprecated.Default behavior is just to log the exception- Parameters:
e
- the exception
-
ensurePath
Deprecated.- Throws:
Exception
-
remove
Deprecated.
-
CuratorCache