Class PathChildrenCache

java.lang.Object
org.apache.curator.framework.recipes.cache.PathChildrenCache
All Implemented Interfaces:
Closeable, AutoCloseable

@Deprecated public class PathChildrenCache extends Object implements Closeable
Deprecated.
replace by CuratorCache

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.

  • Field Details

    • defaultThreadFactorySupplier

      public static final Supplier<ThreadFactory> defaultThreadFactorySupplier
      Deprecated.
  • Constructor Details

    • PathChildrenCache

      @Deprecated public PathChildrenCache(CuratorFramework client, String path, PathChildrenCacheMode mode)
      Parameters:
      client - the client
      path - path to watch
      mode - caching mode
    • PathChildrenCache

      @Deprecated public PathChildrenCache(CuratorFramework client, String path, PathChildrenCacheMode mode, ThreadFactory threadFactory)
      Parameters:
      client - the client
      path - path to watch
      mode - caching mode
      threadFactory - factory to use when creating internal threads
    • PathChildrenCache

      public PathChildrenCache(CuratorFramework client, String path, boolean cacheData)
      Deprecated.
      Parameters:
      client - the client
      path - path to watch
      cacheData - 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 client
      path - path to watch
      cacheData - if true, node contents are cached in addition to the stat
      threadFactory - factory to use when creating internal threads
    • PathChildrenCache

      public PathChildrenCache(CuratorFramework client, String path, boolean cacheData, boolean dataIsCompressed, ThreadFactory threadFactory)
      Deprecated.
      Parameters:
      client - the client
      path - path to watch
      cacheData - if true, node contents are cached in addition to the stat
      dataIsCompressed - if true, data in the path is compressed
      threadFactory - factory to use when creating internal threads
    • PathChildrenCache

      public PathChildrenCache(CuratorFramework client, String path, boolean cacheData, boolean dataIsCompressed, ExecutorService executorService)
      Deprecated.
      Parameters:
      client - the client
      path - path to watch
      cacheData - if true, node contents are cached in addition to the stat
      dataIsCompressed - if true, data in the path is compressed
      executorService - 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 client
      path - path to watch
      cacheData - if true, node contents are cached in addition to the stat
      dataIsCompressed - if true, data in the path is compressed
      executorService - 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

      public void start() throws Exception
      Deprecated.
      Start the cache. The cache is not started automatically. You must call this method.
      Throws:
      Exception - errors
    • start

      @Deprecated public void start(boolean buildInitial) throws Exception
      Deprecated.
      Same as start() but gives the option of doing an initial build
      Parameters:
      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
      Throws:
      Exception - errors
    • start

      public void start(PathChildrenCache.StartMode mode) throws Exception
      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

      public void rebuild() throws Exception
      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

      public void rebuildNode(String fullPath) throws Exception
      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

      public void close() throws IOException
      Deprecated.
      Close/end the cache
      Specified by:
      close in interface AutoCloseable
      Specified by:
      close in interface Closeable
      Throws:
      IOException - errors
    • getListenable

      public Listenable<PathChildrenCacheListener> getListenable()
      Deprecated.
      Return the cache listenable
      Returns:
      listenable
    • getCurrentData

      public List<ChildData> 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

      public ChildData getCurrentData(String fullPath)
      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

      public void clearDataBytes(String fullPath)
      Deprecated.
      As a memory optimization, you can clear the cached data bytes for a node. Subsequent calls to ChildData.getData() for this node will return null.
      Parameters:
      fullPath - the path of the node to clear
    • clearDataBytes

      public boolean clearDataBytes(String fullPath, int ifVersion)
      Deprecated.
      As a memory optimization, you can clear the cached data bytes for a node. Subsequent calls to ChildData.getData() for this node will return null.
      Parameters:
      fullPath - the path of the node to clear
      ifVersion - if non-negative, only clear the data if the data's version matches this version
      Returns:
      true if the data was cleared
    • clearAndRefresh

      public void clearAndRefresh() throws Exception
      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

      protected void handleException(Throwable e)
      Deprecated.
      Default behavior is just to log the exception
      Parameters:
      e - the exception
    • ensurePath

      protected void ensurePath() throws Exception
      Deprecated.
      Throws:
      Exception
    • remove

      protected void remove(String fullPath)
      Deprecated.