|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectcom.netflix.curator.framework.recipes.cache.PathChildrenCache
public class PathChildrenCache
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 | |
|---|---|
static class |
PathChildrenCache.StartMode
Method of priming cache on start(StartMode) |
| Constructor Summary | |
|---|---|
PathChildrenCache(com.netflix.curator.framework.CuratorFramework client,
java.lang.String path,
boolean cacheData)
|
|
PathChildrenCache(com.netflix.curator.framework.CuratorFramework client,
java.lang.String path,
boolean cacheData,
boolean dataIsCompressed,
java.util.concurrent.ExecutorService executorService)
|
|
PathChildrenCache(com.netflix.curator.framework.CuratorFramework client,
java.lang.String path,
boolean cacheData,
boolean dataIsCompressed,
java.util.concurrent.ThreadFactory threadFactory)
|
|
PathChildrenCache(com.netflix.curator.framework.CuratorFramework client,
java.lang.String path,
boolean cacheData,
java.util.concurrent.ThreadFactory threadFactory)
|
|
PathChildrenCache(com.netflix.curator.framework.CuratorFramework client,
java.lang.String path,
PathChildrenCacheMode mode)
Deprecated. use PathChildrenCache(CuratorFramework, String, boolean) instead |
|
PathChildrenCache(com.netflix.curator.framework.CuratorFramework client,
java.lang.String path,
PathChildrenCacheMode mode,
java.util.concurrent.ThreadFactory threadFactory)
Deprecated. use PathChildrenCache(CuratorFramework, String, boolean, ThreadFactory) instead |
|
| Method Summary | |
|---|---|
void |
clear()
Clears the current data without beginning a new query and without generating any events for listeners. |
void |
clearAndRefresh()
Clear out current data and begin a new query on the path |
void |
clearDataBytes(java.lang.String fullPath)
As a memory optimization, you can clear the cached data bytes for a node. |
boolean |
clearDataBytes(java.lang.String fullPath,
int ifVersion)
As a memory optimization, you can clear the cached data bytes for a node. |
void |
close()
Close/end the cache |
java.util.List<ChildData> |
getCurrentData()
Return the current data. |
ChildData |
getCurrentData(java.lang.String fullPath)
Return the current data for the given path. |
com.netflix.curator.framework.listen.ListenerContainer<PathChildrenCacheListener> |
getListenable()
Return the cache listenable |
protected void |
handleException(java.lang.Throwable e)
Default behavior is just to log the exception |
void |
rebuild()
NOTE: this is a BLOCKING method. |
void |
rebuildNode(java.lang.String fullPath)
NOTE: this is a BLOCKING method. |
protected void |
remove(java.lang.String fullPath)
|
void |
start()
Start the cache. |
void |
start(boolean buildInitial)
Deprecated. use start(StartMode) |
void |
start(PathChildrenCache.StartMode mode)
Start the cache. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public PathChildrenCache(com.netflix.curator.framework.CuratorFramework client,
java.lang.String path,
PathChildrenCacheMode mode)
PathChildrenCache(CuratorFramework, String, boolean) instead
client - the clientpath - path to watchmode - caching mode
public PathChildrenCache(com.netflix.curator.framework.CuratorFramework client,
java.lang.String path,
PathChildrenCacheMode mode,
java.util.concurrent.ThreadFactory threadFactory)
PathChildrenCache(CuratorFramework, String, boolean, ThreadFactory) instead
client - the clientpath - path to watchmode - caching modethreadFactory - factory to use when creating internal threads
public PathChildrenCache(com.netflix.curator.framework.CuratorFramework client,
java.lang.String path,
boolean cacheData)
client - the clientpath - path to watchcacheData - if true, node contents are cached in addition to the stat
public PathChildrenCache(com.netflix.curator.framework.CuratorFramework client,
java.lang.String path,
boolean cacheData,
java.util.concurrent.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 threads
public PathChildrenCache(com.netflix.curator.framework.CuratorFramework client,
java.lang.String path,
boolean cacheData,
boolean dataIsCompressed,
java.util.concurrent.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 threads
public PathChildrenCache(com.netflix.curator.framework.CuratorFramework client,
java.lang.String path,
boolean cacheData,
boolean dataIsCompressed,
java.util.concurrent.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| Method Detail |
|---|
public void start()
throws java.lang.Exception
java.lang.Exception - errors
public void start(boolean buildInitial)
throws java.lang.Exception
start(StartMode)
start() but gives the option of doing an initial build
buildInitial - if true, rebuild() will be called before this method
returns in order to get an initial view of the node; otherwise,
the cache will be initialized asynchronously
java.lang.Exception - errors
public void start(PathChildrenCache.StartMode mode)
throws java.lang.Exception
mode - Method for priming the cache
java.lang.Exception - errors
public void rebuild()
throws java.lang.Exception
java.lang.Exception - errors
public void rebuildNode(java.lang.String fullPath)
throws java.lang.Exception
fullPath - full path of the node to rebuild
java.lang.Exception - errors
public void close()
throws java.io.IOException
close in interface java.io.Closeablejava.io.IOException - errorspublic com.netflix.curator.framework.listen.ListenerContainer<PathChildrenCacheListener> getListenable()
public java.util.List<ChildData> getCurrentData()
public ChildData getCurrentData(java.lang.String fullPath)
null
is returned.
fullPath - full path to the node to check
public void clearDataBytes(java.lang.String fullPath)
ChildData.getData() for this node will return null.
fullPath - the path of the node to clear
public boolean clearDataBytes(java.lang.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 version
public void clearAndRefresh()
throws java.lang.Exception
java.lang.Exception - errorspublic void clear()
protected void handleException(java.lang.Throwable e)
e - the exceptionprotected void remove(java.lang.String fullPath)
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||