public class DefaultConfigurationProvider extends Object implements ConfigurationProvider
The default implementation of a ConfigurationProvider
.
The ConfigurationProvider
is the central orchestrator for configuration management. Observers can observe 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,
List<Loader> loaderChain,
Map<LoaderType,Refresher> refreshers)
Create a new
DefaultConfigurationProvider . |
Modifier and Type | Method and Description |
---|---|
rx.Observable<ClusterConfig> |
closeBucket(String name) |
rx.Observable<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. |
static String |
determineNetworkResolution(BucketConfig config,
NetworkResolution nr,
Set<NetworkAddress> seedHosts)
Helper method to figure out which network resolution should be used.
|
rx.Observable<ClusterConfig> |
openBucket(String bucket,
String password)
Start to fetch a config for the given bucket and also watch for changes, depending on the mechanism used.
|
rx.Observable<ClusterConfig> |
openBucket(String bucket,
String username,
String password)
Start to fetch a config for the given bucket and also watch for changes, depending on the mechanism used.
|
void |
proposeBucketConfig(ProposedBucketConfigContext ctx)
Propose a new bucket config with surrounding context.
|
boolean |
seedHosts(Set<NetworkAddress> hosts,
boolean shuffle)
Set the initial seed hosts for bootstrap.
|
rx.Observable<Boolean> |
shutdown()
Shutdown the
ConfigurationProvider into a terminal state where it cannot be used anymore and all its non-bucket resources are freed. |
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, List<Loader> loaderChain, 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(Set<NetworkAddress> 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(String bucket, 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> openBucket(String bucket, String username, 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.username
- the user authorized for bucket access.password
- the password of the user.public rx.Observable<ClusterConfig> closeBucket(String name)
closeBucket
in interface ConfigurationProvider
public rx.Observable<Boolean> closeBuckets()
closeBuckets
in interface ConfigurationProvider
public void proposeBucketConfig(ProposedBucketConfigContext ctx)
ConfigurationProvider
Propose a new bucket config with surrounding context.
proposeBucketConfig
in interface ConfigurationProvider
ctx
- the raw config including context.public void signalOutdated()
signalOutdated
in interface ConfigurationProvider
public rx.Observable<Boolean> shutdown()
ConfigurationProvider
Shutdown the ConfigurationProvider
into a terminal state where it cannot be used anymore and all its non-bucket resources are freed.
shutdown
in interface ConfigurationProvider
public static String determineNetworkResolution(BucketConfig config, NetworkResolution nr, Set<NetworkAddress> seedHosts)
Helper method to figure out which network resolution should be used.
if DEFAULT is selected, then null is returned which is equal to the “internal” or default config mode. If AUTO is used then we perform the select heuristic based off of the seed hosts given. All other resolution settings (i.e. EXTERNAL) are returned directly and are considered to be part of the alternate address configs.
config
- the config to check againstnr
- the network resolution setting from the environmentseedHosts
- the seed hosts from bootstrap for autoconfig.Copyright © 2018 Couchbase, Inc.. All rights reserved.