public class DefaultConfigurationProvider extends java.lang.Object implements ConfigurationProvider
The default implementation of a ConfigurationProvider
.
The ConfigurationProvider
is the central orchestrator for configuration management. Observers can subscribe bucket and cluster configurations from this component. Behind the scenes, it facilitates configuration loaders and configuration refreshers that grab initial configurations and keep them refreshed respectively. The structure looks like this:
Constructor and Description |
---|
DefaultConfigurationProvider(ClusterFacade cluster,
CoreEnvironment environment)
Create a new
DefaultConfigurationProvider . |
DefaultConfigurationProvider(ClusterFacade cluster,
CoreEnvironment environment,
java.util.List<Loader> loaderChain,
java.util.Map<LoaderType,Refresher> refreshers)
Create a new
DefaultConfigurationProvider . |
Modifier and Type | Method and Description |
---|---|
rx.Observable<ClusterConfig> |
closeBucket(java.lang.String name) |
rx.Observable<java.lang.Boolean> |
closeBuckets() |
ClusterConfig |
config()
Returns the current config or null if not set.
|
rx.Observable<ClusterConfig> |
configs()
Returns an
Observable , which pushes a new ClusterConfig once available. |
rx.Observable<ClusterConfig> |
openBucket(java.lang.String bucket,
java.lang.String password)
Start to fetch a config for the given bucket and also watch for changes, depending on the mechanism used.
|
void |
proposeBucketConfig(java.lang.String bucket,
java.lang.String rawConfig) |
boolean |
seedHosts(java.util.Set<java.net.InetAddress> hosts,
boolean shuffle)
Set the initial seed hosts for bootstrap.
|
void |
signalOutdated() |
public DefaultConfigurationProvider(ClusterFacade cluster, CoreEnvironment environment)
Create a new DefaultConfigurationProvider
.
When this constructor is used, the default loader chain is populated (first carrier is tried and the http loader is registered as a fallback).
cluster
- the cluster reference.environment
- the environment.public DefaultConfigurationProvider(ClusterFacade cluster, CoreEnvironment environment, java.util.List<Loader> loaderChain, java.util.Map<LoaderType,Refresher> refreshers)
Create a new DefaultConfigurationProvider
.
cluster
- the cluster reference.environment
- the environment.loaderChain
- the configuration loaders which will be tried in sequence.public rx.Observable<ClusterConfig> configs()
ConfigurationProvider
Returns an Observable
, which pushes a new ClusterConfig
once available.
configs
in interface ConfigurationProvider
public ClusterConfig config()
ConfigurationProvider
Returns the current config or null if not set.
config
in interface ConfigurationProvider
public boolean seedHosts(java.util.Set<java.net.InetAddress> hosts, boolean shuffle)
ConfigurationProvider
Set the initial seed hosts for bootstrap.
This should only be done as long as the ConfigurationProvider
is not bootstrapped, otherwise it might be ignored.
seedHosts
in interface ConfigurationProvider
hosts
- list of seed hosts.shuffle
- shuffle seed host list.public rx.Observable<ClusterConfig> openBucket(java.lang.String bucket, java.lang.String password)
ConfigurationProvider
Start to fetch a config for the given bucket and also watch for changes, depending on the mechanism used.
openBucket
in interface ConfigurationProvider
bucket
- the name of the bucket.password
- the name of the password.public rx.Observable<ClusterConfig> closeBucket(java.lang.String name)
closeBucket
in interface ConfigurationProvider
public rx.Observable<java.lang.Boolean> closeBuckets()
closeBuckets
in interface ConfigurationProvider
public void proposeBucketConfig(java.lang.String bucket, java.lang.String rawConfig)
proposeBucketConfig
in interface ConfigurationProvider
public void signalOutdated()
signalOutdated
in interface ConfigurationProvider