|
||||||||||
| 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.
| Constructor Summary | |
|---|---|
PathChildrenCache(CuratorFramework client,
String path,
PathChildrenCacheMode mode)
|
|
PathChildrenCache(CuratorFramework client,
String path,
PathChildrenCacheMode mode,
ThreadFactory threadFactory)
|
|
| Method Summary | |
|---|---|
void |
clearAndRefresh()
Clear out current data and begin a new query on the path |
void |
close()
Close/end the cache |
List<ChildData> |
getCurrentData()
Return the current data. |
ChildData |
getCurrentData(String fullPath)
Return the current data for the given path. |
ListenerContainer<PathChildrenCacheListener> |
getListenable()
Return the cache listenable |
protected void |
handleException(Throwable e)
Default behavior is just to log the exception |
void |
start()
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(CuratorFramework client,
String path,
PathChildrenCacheMode mode)
client - the clientpath - path to watchmode - caching mode
public PathChildrenCache(CuratorFramework client,
String path,
PathChildrenCacheMode mode,
ThreadFactory threadFactory)
client - the clientpath - path to watchmode - caching modethreadFactory - factory to use when creating internal threads| Method Detail |
|---|
public void start()
throws Exception
Exception - errors
public void close()
throws IOException
close in interface CloseableIOException - errorspublic ListenerContainer<PathChildrenCacheListener> getListenable()
public List<ChildData> getCurrentData()
public ChildData getCurrentData(String fullPath)
null
is returned.
fullPath - full path to the node to check
public void clearAndRefresh()
throws Exception
Exception - errorsprotected void handleException(Throwable e)
e - the exception
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||