Class TreeCache
java.lang.Object
org.apache.curator.framework.recipes.cache.TreeCache
- 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
-
Constructor Summary
ConstructorDescriptionTreeCache
(CuratorFramework client, String path) Deprecated.Create a TreeCache for the given client and path with default options. -
Method Summary
Modifier and TypeMethodDescriptionvoid
close()
Deprecated.Close/end the cache.getCurrentChildren
(String fullPath) Deprecated.Return the current set of children at the given path, mapped by child name.getCurrentData
(String fullPath) Deprecated.Return the current data for the given path.Deprecated.Return the cache listenableDeprecated.Allows catching unhandled errors in asynchronous operations.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.start()
Deprecated.Start the cache.
-
Constructor Details
-
TreeCache
Deprecated.Create a TreeCache for the given client and path with default options. If the client is namespaced, all operations on the resulting TreeCache will be in terms of the namespace, including all published events. The given path is the root at which the TreeCache will watch and explore. If no node exists at the given path, the TreeCache will be initially empty.- Parameters:
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 server- See Also:
-
-
Method Details
-
newBuilder
Deprecated.Create a TreeCache builder for the given client and path to configure advanced options. If the client is namespaced, all operations on the resulting TreeCache will be in terms of the namespace, including all published events. The given path is the root at which the TreeCache will watch and explore. If no node exists at the given path, the TreeCache will be initially empty.- Parameters:
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 server- Returns:
- a new builder
-
start
Deprecated.Start the cache. The cache is not started automatically. You must call this method.- Returns:
- this
- Throws:
Exception
- errors
-
close
public void close()Deprecated.Close/end the cache.- Specified by:
close
in interfaceAutoCloseable
- Specified by:
close
in interfaceCloseable
-
getListenable
Deprecated.Return the cache listenable- Returns:
- listenable
-
getUnhandledErrorListenable
Deprecated.Allows catching unhandled errors in asynchronous operations. TODO: consider making public. -
getCurrentChildren
Deprecated.Return the current set of children at the given path, mapped by child name. There are no guarantees of accuracy; this is merely the most recent view of the data. If there is no node at this path,null
is returned.- Parameters:
fullPath
- full path to the node to check- Returns:
- a possibly-empty list of children if the node is alive, or null
-
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 node at the given path,null
is returned.- Parameters:
fullPath
- full path to the node to check- Returns:
- data if the node is alive, or null
-
iterator
Deprecated.Return an iterator over all nodes in the cache. There are no guarantees of accuracy; this is merely the most recent view of the data.- Returns:
- a possibly-empty iterator of nodes in the cache
-
size
public int size()Deprecated.Return the number of nodes in the cache. There are no guarantees of accuracy; this is merely the most recent view of the data.- Returns:
- size
-
CuratorCache