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 void
addListener(ServiceCacheListener listener)
void
addListener(ServiceCacheListener listener, java.util.concurrent.Executor executor)
void
childEvent(org.apache.curator.framework.CuratorFramework client, org.apache.curator.framework.recipes.cache.PathChildrenCacheEvent event)
void
close()
java.util.List<ServiceInstance<T>>
getInstances()
Return the current list of instances.void
removeListener(ServiceCacheListener listener)
void
start()
The cache must be started before use
-
-
-
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 interfaceInstanceProvider<T>
- Specified by:
getInstances
in interfaceServiceCache<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 interfaceServiceCache<T>
- Throws:
java.lang.Exception
- errors
-
close
public void close() throws java.io.IOException
- Specified by:
close
in interfacejava.lang.AutoCloseable
- Specified by:
close
in interfacejava.io.Closeable
- Throws:
java.io.IOException
-
addListener
public void addListener(ServiceCacheListener listener)
- Specified by:
addListener
in interfaceorg.apache.curator.framework.listen.Listenable<T>
-
addListener
public void addListener(ServiceCacheListener listener, java.util.concurrent.Executor executor)
- Specified by:
addListener
in interfaceorg.apache.curator.framework.listen.Listenable<T>
-
removeListener
public void removeListener(ServiceCacheListener listener)
- Specified by:
removeListener
in 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:
childEvent
in interfaceorg.apache.curator.framework.recipes.cache.PathChildrenCacheListener
- Throws:
java.lang.Exception
-
-