CuratorCache
@Deprecated public class TreeCache 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 |
TreeCache.Builder
Deprecated.
|
Constructor and Description |
---|
TreeCache(CuratorFramework client,
String path)
Deprecated.
Create a TreeCache for the given client and path with default options.
|
Modifier and Type | Method and Description |
---|---|
void |
close()
Deprecated.
Close/end the cache.
|
Map<String,ChildData> |
getCurrentChildren(String fullPath)
Deprecated.
Return the current set of children at the given path, mapped by child name.
|
ChildData |
getCurrentData(String fullPath)
Deprecated.
Return the current data for the given path.
|
Listenable<TreeCacheListener> |
getListenable()
Deprecated.
Return the cache listenable
|
Listenable<UnhandledErrorListener> |
getUnhandledErrorListenable()
Deprecated.
Allows catching unhandled errors in asynchronous operations.
|
Iterator<ChildData> |
iterator()
Deprecated.
Return an iterator over all nodes in the cache.
|
static TreeCache.Builder |
newBuilder(CuratorFramework client,
String path)
Deprecated.
Create a TreeCache builder for the given client and path to configure advanced options.
|
int |
size()
Deprecated.
Return the number of nodes in the cache.
|
TreeCache |
start()
Deprecated.
Start the cache.
|
public TreeCache(CuratorFramework client, String path)
client
- the client to use; may be namespacedpath
- the path to the root node to watch/explore; this path need not actually exist on
the servernewBuilder(CuratorFramework, String)
public static TreeCache.Builder newBuilder(CuratorFramework client, String path)
client
- the client to use; may be namespacedpath
- the path to the root node to watch/explore; this path need not actually exist on
the serverpublic TreeCache start() throws Exception
Exception
- errorspublic void close()
close
in interface Closeable
close
in interface AutoCloseable
public Listenable<TreeCacheListener> getListenable()
public Listenable<UnhandledErrorListener> getUnhandledErrorListenable()
public Map<String,ChildData> getCurrentChildren(String fullPath)
null
is returned.fullPath
- full path to the node to checkpublic ChildData getCurrentData(String fullPath)
null
is returned.fullPath
- full path to the node to checkpublic Iterator<ChildData> iterator()
public int size()
Copyright © 2011–2023 The Apache Software Foundation. All rights reserved.