Class ServiceCacheImpl<T>

java.lang.Object
org.apache.curator.x.discovery.details.ServiceCacheImpl<T>
All Implemented Interfaces:
Closeable, AutoCloseable, org.apache.curator.framework.listen.Listenable<ServiceCacheListener>, org.apache.curator.framework.recipes.cache.PathChildrenCacheListener, InstanceProvider<T>, ServiceCache<T>

public class ServiceCacheImpl<T> extends Object implements ServiceCache<T>, org.apache.curator.framework.recipes.cache.PathChildrenCacheListener
  • Method Details

    • getInstances

      public List<ServiceInstance<T>> getInstances()
      Description copied from interface: ServiceCache
      Return the current list of instances. NOTE: there is no guarantee of freshness. This is merely the last known list of instances. However, the list is updated via a ZooKeeper watcher so it should be fresh within a window of a second or two.
      Specified by:
      getInstances in interface InstanceProvider<T>
      Specified by:
      getInstances in interface ServiceCache<T>
      Returns:
      the list
    • start

      public void start() throws Exception
      Description copied from interface: ServiceCache
      The cache must be started before use
      Specified by:
      start in interface ServiceCache<T>
      Throws:
      Exception - errors
    • startImmediate

      public CountDownLatch startImmediate() throws Exception
      Specified by:
      startImmediate in interface ServiceCache<T>
      Throws:
      Exception
    • close

      public void close()
      Specified by:
      close in interface AutoCloseable
      Specified by:
      close in interface Closeable
    • addListener

      public void addListener(ServiceCacheListener listener)
      Specified by:
      addListener in interface org.apache.curator.framework.listen.Listenable<T>
    • addListener

      public void addListener(ServiceCacheListener listener, Executor executor)
      Specified by:
      addListener in interface org.apache.curator.framework.listen.Listenable<T>
    • removeListener

      public void removeListener(ServiceCacheListener listener)
      Specified by:
      removeListener in interface org.apache.curator.framework.listen.Listenable<T>
    • childEvent

      public void childEvent(org.apache.curator.framework.CuratorFramework client, org.apache.curator.framework.recipes.cache.PathChildrenCacheEvent event)
      Specified by:
      childEvent in interface org.apache.curator.framework.recipes.cache.PathChildrenCacheListener