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
ModifierConstructorDescriptionprotected
ServiceProviderImpl
(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 TypeMethodDescriptionvoid
close()
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.void
noteError
(ServiceInstance<T> instance) Take note of an error connecting to the given instance.void
start()
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:
start
in 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:
close
in interfaceAutoCloseable
- Specified by:
close
in interfaceCloseable
- Specified by:
close
in 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:
getAllInstances
in 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:
getInstance
in interfaceServiceProvider<T>
- Returns:
- the instance to use
- Throws:
Exception
- any errors
-
noteError
Description copied from interface:ServiceProvider
Take note of an error connecting to the given instance. The instance will potentially be marked as "down" depending on theDownInstancePolicy
.- Specified by:
noteError
in interfaceServiceProvider<T>
- Parameters:
instance
- instance that had an error
-