Class ServiceCacheImpl<T>

  • All Implemented Interfaces:
    java.io.Closeable, java.lang.AutoCloseable, org.apache.curator.framework.listen.Listenable<ServiceCacheListener>, org.apache.curator.framework.recipes.cache.PathChildrenCacheListener, InstanceProvider<T>, ServiceCache<T>

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

      • getInstances

        public java.util.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 java.lang.Exception
        Description copied from interface: ServiceCache
        The cache must be started before use
        Specified by:
        start in interface ServiceCache<T>
        Throws:
        java.lang.Exception - errors
      • close

        public void close()
                   throws java.io.IOException
        Specified by:
        close in interface java.lang.AutoCloseable
        Specified by:
        close in interface java.io.Closeable
        Throws:
        java.io.IOException
      • addListener

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

        public void addListener​(ServiceCacheListener listener,
                                java.util.concurrent.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)
                        throws java.lang.Exception
        Specified by:
        childEvent in interface org.apache.curator.framework.recipes.cache.PathChildrenCacheListener
        Throws:
        java.lang.Exception