Class ServiceProviderImpl<T>
java.lang.Object
org.apache.curator.x.discovery.details.ServiceProviderImpl<T>
- All Implemented Interfaces:
Closeable,AutoCloseable,ServiceProvider<T>
The main interface for Service Discovery. Encapsulates the discovery service for a particular
named service along with a provider strategy.
-
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedServiceProviderImpl(ServiceDiscoveryImpl<T> discovery, String serviceName, ProviderStrategy<T> providerStrategy, ThreadFactory threadFactory, ExecutorService executorService, List<InstanceFilter<T>> filters, DownInstancePolicy downInstancePolicy) ServiceProviderImpl(ServiceDiscoveryImpl<T> discovery, String serviceName, ProviderStrategy<T> providerStrategy, ThreadFactory threadFactory, List<InstanceFilter<T>> filters, DownInstancePolicy downInstancePolicy) -
Method Summary
Modifier and TypeMethodDescriptionvoidclose()Close the provider.Return the current available set of instances IMPORTANT: users should not hold on to the instance returned.Return an instance for a single use.voidnoteError(ServiceInstance<T> instance) Take note of an error connecting to the given instance.voidstart()The provider must be started before use
-
Constructor Details
-
ServiceProviderImpl
public ServiceProviderImpl(ServiceDiscoveryImpl<T> discovery, String serviceName, ProviderStrategy<T> providerStrategy, ThreadFactory threadFactory, List<InstanceFilter<T>> filters, DownInstancePolicy downInstancePolicy) -
ServiceProviderImpl
protected ServiceProviderImpl(ServiceDiscoveryImpl<T> discovery, String serviceName, ProviderStrategy<T> providerStrategy, ThreadFactory threadFactory, ExecutorService executorService, List<InstanceFilter<T>> filters, DownInstancePolicy downInstancePolicy)
-
-
Method Details
-
start
The provider must be started before use- Specified by:
startin interfaceServiceProvider<T>- Throws:
Exception- any errors
-
close
Close the provider. Note: it's the provider's responsibility to close any caches it manages- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceCloseable- Specified by:
closein interfaceServiceProvider<T>- Throws:
IOException
-
getAllInstances
Return the current available set of instances IMPORTANT: users should not hold on to the instance returned. They should always get a fresh list.- Specified by:
getAllInstancesin interfaceServiceProvider<T>- Returns:
- all known instances
- Throws:
Exception- any errors
-
getInstance
Return an instance for a single use. IMPORTANT: users should not hold on to the instance returned. They should always get a fresh instance.- Specified by:
getInstancein interfaceServiceProvider<T>- Returns:
- the instance to use
- Throws:
Exception- any errors
-
noteError
Description copied from interface:ServiceProviderTake note of an error connecting to the given instance. The instance will potentially be marked as "down" depending on theDownInstancePolicy.- Specified by:
noteErrorin interfaceServiceProvider<T>- Parameters:
instance- instance that had an error
-