public class DefaultConfigurationProvider extends Object implements ConfigurationProvider
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:
[ConfigurationProvider] --> [Config from REST] [ConfigurationProvider] --> [Config from Carrier] package "Config from REST" { [HttpLoader] [HttpRefresher] } [HttpLoader] --> 8091 [HttpRefresher] --> 8091 package "Config from Carrier" { [CarrierLoader] [CarrierRefresher] } [CarrierLoader] --> 11210 [CarrierRefresher] --> 11210
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)
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)
DefaultConfigurationProvider
.cluster
- the cluster reference.environment
- the environment.loaderChain
- the configuration loaders which will be tried in sequence.public rx.Observable<ClusterConfig> configs()
ConfigurationProvider
Observable
, which pushes a new ClusterConfig
once available.configs
in interface ConfigurationProvider
public ClusterConfig config()
ConfigurationProvider
config
in interface ConfigurationProvider
public boolean seedHosts(Set<NetworkAddress> hosts, boolean shuffle)
ConfigurationProvider
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
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
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
proposeBucketConfig
in interface ConfigurationProvider
ctx
- the raw config including context.public void signalOutdated()
signalOutdated
in interface ConfigurationProvider
public rx.Observable<Boolean> shutdown()
ConfigurationProvider
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)
config
- the config to check againstnr
- the network resolution setting from the environmentseedHosts
- the seed hosts from bootstrap for autoconfig.Copyright © 2019 Couchbase, Inc.. All rights reserved.