Package org.apache.curator.x.discovery
Interface ServiceProvider<T>
-
- All Superinterfaces:
java.lang.AutoCloseable
,java.io.Closeable
- All Known Implementing Classes:
ServiceProviderImpl
public interface ServiceProvider<T> extends java.io.Closeable
The main API for Discovery. This class is essentially a facade over aProviderStrategy
paired with anInstanceProvider
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description void
close()
Close the provider.java.util.Collection<ServiceInstance<T>>
getAllInstances()
Return the current available set of instances IMPORTANT: users should not hold on to the instance returned.ServiceInstance<T>
getInstance()
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
-
-
-
Method Detail
-
start
void start() throws java.lang.Exception
The provider must be started before use- Throws:
java.lang.Exception
- any errors
-
getInstance
ServiceInstance<T> getInstance() throws java.lang.Exception
Return an instance for a single use. IMPORTANT: users should not hold on to the instance returned. They should always get a fresh instance.- Returns:
- the instance to use
- Throws:
java.lang.Exception
- any errors
-
getAllInstances
java.util.Collection<ServiceInstance<T>> getAllInstances() throws java.lang.Exception
Return the current available set of instances IMPORTANT: users should not hold on to the instance returned. They should always get a fresh list.- Returns:
- all known instances
- Throws:
java.lang.Exception
- any errors
-
noteError
void noteError(ServiceInstance<T> instance)
Take note of an error connecting to the given instance. The instance will potentially be marked as "down" depending on theDownInstancePolicy
.- Parameters:
instance
- instance that had an error
-
close
void close() throws java.io.IOException
Close the provider. Note: it's the provider's responsibility to close any caches it manages- Specified by:
close
in interfacejava.lang.AutoCloseable
- Specified by:
close
in interfacejava.io.Closeable
- Throws:
java.io.IOException
-
-