Class ServiceCacheImpl<T>
java.lang.Object
org.apache.curator.x.discovery.details.ServiceCacheImpl<T>
- All Implemented Interfaces:
Closeable,AutoCloseable,Listenable<ServiceCacheListener>,PathChildrenCacheListener,InstanceProvider<T>,ServiceCache<T>
public class ServiceCacheImpl<T>
extends Object
implements ServiceCache<T>, PathChildrenCacheListener
-
Method Summary
Modifier and TypeMethodDescriptionvoidaddListener(ServiceCacheListener listener) Add the given listener.voidaddListener(ServiceCacheListener listener, Executor executor) Add the given listener.voidchildEvent(CuratorFramework client, PathChildrenCacheEvent event) Called when a change has occurredvoidclose()Return the current list of instances.voidremoveListener(ServiceCacheListener listener) Remove the given listenervoidstart()The cache must be started before use
-
Method Details
-
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
Description copied from interface:ServiceCacheThe cache must be started before use- Specified by:
startin interfaceServiceCache<T>- Throws:
Exception- errors
-
startImmediate
- Specified by:
startImmediatein interfaceServiceCache<T>- Throws:
Exception
-
close
public void close()- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceCloseable
-
addListener
Description copied from interface:ListenableAdd the given listener. The listener will be executed in the containing instance's thread.- Specified by:
addListenerin interfaceListenable<T>- Parameters:
listener- listener to add
-
addListener
Description copied from interface:ListenableAdd the given listener. The listener will be executed using the given executor- Specified by:
addListenerin interfaceListenable<T>- Parameters:
listener- listener to addexecutor- executor to run listener in
-
removeListener
Description copied from interface:ListenableRemove the given listener- Specified by:
removeListenerin interfaceListenable<T>- Parameters:
listener- listener to remove
-
childEvent
Description copied from interface:PathChildrenCacheListenerCalled when a change has occurred- Specified by:
childEventin interfacePathChildrenCacheListener- Parameters:
client- the clientevent- describes the change
-