public class DefaultConfigurationProvider extends Object implements ConfigurationProvider
ConfigurationProvider
that is used by default.
This provider has been around since the 1.x days, but it has been revamped and reworked for the 2.x breakage - the overall functionality remains very similar though.
Modifier and Type | Class and Description |
---|---|
static class |
DefaultConfigurationProvider.AlternateAddressHolder
This class is needed since both port info and node info need to be abstracted for alternate address resolving.
|
Constructor and Description |
---|
DefaultConfigurationProvider(Core core,
Set<SeedNode> seedNodes)
Creates a new configuration provider.
|
Modifier and Type | Method and Description |
---|---|
boolean |
bucketConfigLoadInProgress()
Returns true if a bucket config load attempt is in progress.
|
Mono<Void> |
closeBucket(String name)
Initiates the bucket closing process.
|
CollectionMap |
collectionMap()
Returns the attached collection map.
|
boolean |
collectionMapRefreshInProgress()
Returns true if a collection map refresh is in progress.
|
ClusterConfig |
config()
Returns the current
ClusterConfig . |
Flux<ClusterConfig> |
configs()
This is a hot stream which when attached will return the current config as well as
all subsequent ones.
|
static String |
determineNetworkResolution(List<DefaultConfigurationProvider.AlternateAddressHolder> nodes,
NetworkResolution nr,
Set<String> seedHosts)
Helper method to figure out which network resolution should be used.
|
static List<DefaultConfigurationProvider.AlternateAddressHolder> |
extractAlternateAddressInfos(ClusterConfig config)
Helper method to turn either the port info or the node info into a list of hosts to use for the
alternate address resolution.
|
boolean |
globalConfigLoadInProgress()
Returns true if an initial global config load attempt is in progress.
|
Mono<Void> |
loadAndRefreshGlobalConfig()
Instructs the provider to try and load the global config, and then manage it.
|
Mono<Void> |
openBucket(String name)
Initiates the bucket opening process.
|
void |
proposeBucketConfig(ProposedBucketConfigContext ctx)
Allows to propose a bucket config to the provider from an external context.
|
void |
proposeGlobalConfig(ProposedGlobalConfigContext ctx)
Allows to propose a global config to the provider from an external context.
|
void |
refreshCollectionMap(String bucket,
boolean force)
Helper method to refresh the collection map for the given bucket.
|
Flux<Set<SeedNode>> |
seedNodes()
Returns a stream of seed node sets sourced from the server's global config or bucket config.
|
Mono<Void> |
shutdown()
Shuts down the configuration provider and all its associated resources and timers.
|
public CollectionMap collectionMap()
ConfigurationProvider
collectionMap
in interface ConfigurationProvider
public Flux<ClusterConfig> configs()
ConfigurationProvider
configs
in interface ConfigurationProvider
public ClusterConfig config()
ConfigurationProvider
ClusterConfig
.config
in interface ConfigurationProvider
public Flux<Set<SeedNode>> seedNodes()
ConfigurationProvider
Only nodes running the KV service are present in the set.
This is a hot stream which when attached will return the current set of seed nodes as well as all subsequent sets. The returned Flux does not emit any items until the client has received at least one config from the server.
seedNodes
in interface ConfigurationProvider
public Mono<Void> openBucket(String name)
ConfigurationProvider
Note that when this mono completes, it does not mean that the process is completely finished yet, just that it has been initiated and no hard error has been found at the time.
openBucket
in interface ConfigurationProvider
name
- the name of the bucket to open.public Mono<Void> loadAndRefreshGlobalConfig()
ConfigurationProvider
loadAndRefreshGlobalConfig
in interface ConfigurationProvider
public void proposeBucketConfig(ProposedBucketConfigContext ctx)
ConfigurationProvider
This method is usually only called when a "not my vbucket" response is received and the corresponding config is extracted. Do not call this method with arbitrary configs.
proposeBucketConfig
in interface ConfigurationProvider
ctx
- the bucket config and surrounding context.public void proposeGlobalConfig(ProposedGlobalConfigContext ctx)
ConfigurationProvider
proposeGlobalConfig
in interface ConfigurationProvider
ctx
- the context with the global config.public Mono<Void> closeBucket(String name)
ConfigurationProvider
closeBucket
in interface ConfigurationProvider
name
- the name of the bucket.public Mono<Void> shutdown()
ConfigurationProvider
shutdown
in interface ConfigurationProvider
public void refreshCollectionMap(String bucket, boolean force)
ConfigurationProvider
refreshCollectionMap
in interface ConfigurationProvider
bucket
- the name of the bucket.force
- if set, the provider must fetch a new one. otherwise it will only fetch one for the bucket if not
already present.public boolean collectionMapRefreshInProgress()
ConfigurationProvider
collectionMapRefreshInProgress
in interface ConfigurationProvider
public static List<DefaultConfigurationProvider.AlternateAddressHolder> extractAlternateAddressInfos(ClusterConfig config)
public static String determineNetworkResolution(List<DefaultConfigurationProvider.AlternateAddressHolder> nodes, NetworkResolution nr, Set<String> seedHosts)
nodes
- the list of nodes to check.nr
- the network resolution setting from the environmentseedHosts
- the seed hosts from bootstrap for autoconfig.public boolean globalConfigLoadInProgress()
ConfigurationProvider
globalConfigLoadInProgress
in interface ConfigurationProvider
public boolean bucketConfigLoadInProgress()
ConfigurationProvider
bucketConfigLoadInProgress
in interface ConfigurationProvider
Copyright © 2020 Couchbase, Inc.. All rights reserved.