Class ServiceCacheImpl<T>
- java.lang.Object
-
- org.apache.curator.x.discovery.details.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 Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddListener(ServiceCacheListener listener)voidaddListener(ServiceCacheListener listener, java.util.concurrent.Executor executor)voidchildEvent(org.apache.curator.framework.CuratorFramework client, org.apache.curator.framework.recipes.cache.PathChildrenCacheEvent event)voidclose()java.util.List<ServiceInstance<T>>getInstances()Return the current list of instances.voidremoveListener(ServiceCacheListener listener)voidstart()The cache must be started before use
-
-
-
Method Detail
-
getInstances
public java.util.List<ServiceInstance<T>> getInstances()
Description copied from interface:ServiceCacheReturn 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:
getInstancesin interfaceInstanceProvider<T>- Specified by:
getInstancesin interfaceServiceCache<T>- Returns:
- the list
-
start
public void start() throws java.lang.ExceptionDescription copied from interface:ServiceCacheThe cache must be started before use- Specified by:
startin interfaceServiceCache<T>- Throws:
java.lang.Exception- errors
-
close
public void close() throws java.io.IOException- Specified by:
closein interfacejava.lang.AutoCloseable- Specified by:
closein interfacejava.io.Closeable- Throws:
java.io.IOException
-
addListener
public void addListener(ServiceCacheListener listener)
- Specified by:
addListenerin interfaceorg.apache.curator.framework.listen.Listenable<T>
-
addListener
public void addListener(ServiceCacheListener listener, java.util.concurrent.Executor executor)
- Specified by:
addListenerin interfaceorg.apache.curator.framework.listen.Listenable<T>
-
removeListener
public void removeListener(ServiceCacheListener listener)
- Specified by:
removeListenerin interfaceorg.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:
childEventin interfaceorg.apache.curator.framework.recipes.cache.PathChildrenCacheListener- Throws:
java.lang.Exception
-
-