Package com.couchbase.client.core.config
Class DefaultConfigurationProvider
- java.lang.Object
-
- com.couchbase.client.core.config.DefaultConfigurationProvider
-
- All Implemented Interfaces:
ConfigurationProvider
public class DefaultConfigurationProvider extends Object implements ConfigurationProvider
The standardConfigurationProviderthat 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.
- Since:
- 1.0.0
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classDefaultConfigurationProvider.AlternateAddressHolderThis class is needed since both port info and node info need to be abstracted for alternate address resolving.
-
Constructor Summary
Constructors Constructor Description DefaultConfigurationProvider(Core core, Set<SeedNode> seedNodes)Creates a new configuration provider.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description booleanbucketConfigLoadInProgress()Returns true if a bucket config load attempt is in progress.Mono<Void>closeBucket(String name)Initiates the bucket closing process.CollectionMapcollectionMap()Returns the attached collection map.booleancollectionMapRefreshInProgress()Returns true if a collection map refresh is in progress.ClusterConfigconfig()Returns the currentClusterConfig.Flux<ClusterConfig>configs()This is a hot stream which when attached will return the current config as well as all subsequent ones.static StringdetermineNetworkResolution(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.booleanglobalConfigLoadInProgress()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.voidproposeBucketConfig(ProposedBucketConfigContext ctx)Allows to propose a bucket config to the provider from an external context.voidproposeGlobalConfig(ProposedGlobalConfigContext ctx)Allows to propose a global config to the provider from an external context.voidrefreshCollectionMap(String bucket, boolean force)Helper method to refresh the collection map for the given bucket.Mono<Void>shutdown()Shuts down the configuration provider and all its associated resources and timers.
-
-
-
Method Detail
-
collectionMap
public CollectionMap collectionMap()
Description copied from interface:ConfigurationProviderReturns the attached collection map.- Specified by:
collectionMapin interfaceConfigurationProvider
-
configs
public Flux<ClusterConfig> configs()
Description copied from interface:ConfigurationProviderThis is a hot stream which when attached will return the current config as well as all subsequent ones.- Specified by:
configsin interfaceConfigurationProvider- Returns:
- a flux of new configurations as they arrive.
-
config
public ClusterConfig config()
Description copied from interface:ConfigurationProviderReturns the currentClusterConfig.- Specified by:
configin interfaceConfigurationProvider- Returns:
- the current cluster configuration.
-
openBucket
public Mono<Void> openBucket(String name)
Description copied from interface:ConfigurationProviderInitiates the bucket opening process.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.
- Specified by:
openBucketin interfaceConfigurationProvider- Parameters:
name- the name of the bucket to open.- Returns:
- a Mono that completes once the bucket has been logically opened.
-
loadAndRefreshGlobalConfig
public Mono<Void> loadAndRefreshGlobalConfig()
Description copied from interface:ConfigurationProviderInstructs the provider to try and load the global config, and then manage it.- Specified by:
loadAndRefreshGlobalConfigin interfaceConfigurationProvider
-
proposeBucketConfig
public void proposeBucketConfig(ProposedBucketConfigContext ctx)
Description copied from interface:ConfigurationProviderAllows to propose a bucket config to the provider from an external context.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.
- Specified by:
proposeBucketConfigin interfaceConfigurationProvider- Parameters:
ctx- the bucket config and surrounding context.
-
proposeGlobalConfig
public void proposeGlobalConfig(ProposedGlobalConfigContext ctx)
Description copied from interface:ConfigurationProviderAllows to propose a global config to the provider from an external context.- Specified by:
proposeGlobalConfigin interfaceConfigurationProvider- Parameters:
ctx- the context with the global config.
-
closeBucket
public Mono<Void> closeBucket(String name)
Description copied from interface:ConfigurationProviderInitiates the bucket closing process.- Specified by:
closeBucketin interfaceConfigurationProvider- Parameters:
name- the name of the bucket.- Returns:
- a Mono that completes once the bucket has been logically closed.
-
shutdown
public Mono<Void> shutdown()
Description copied from interface:ConfigurationProviderShuts down the configuration provider and all its associated resources and timers.- Specified by:
shutdownin interfaceConfigurationProvider- Returns:
- the mono completes once shut down properly.
-
refreshCollectionMap
public void refreshCollectionMap(String bucket, boolean force)
Description copied from interface:ConfigurationProviderHelper method to refresh the collection map for the given bucket.- Specified by:
refreshCollectionMapin interfaceConfigurationProvider- Parameters:
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.
-
collectionMapRefreshInProgress
public boolean collectionMapRefreshInProgress()
Description copied from interface:ConfigurationProviderReturns true if a collection map refresh is in progress.- Specified by:
collectionMapRefreshInProgressin interfaceConfigurationProvider- Returns:
- true if in progress, false if not.
-
extractAlternateAddressInfos
public 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.- Returns:
- a list of hostname/alternate address mappings.
-
determineNetworkResolution
public static String determineNetworkResolution(List<DefaultConfigurationProvider.AlternateAddressHolder> nodes, NetworkResolution nr, Set<String> 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.- Parameters:
nodes- the list of nodes to check.nr- the network resolution setting from the environmentseedHosts- the seed hosts from bootstrap for autoconfig.- Returns:
- the found setting if external is used, null if internal/default is used.
-
globalConfigLoadInProgress
public boolean globalConfigLoadInProgress()
Description copied from interface:ConfigurationProviderReturns true if an initial global config load attempt is in progress.- Specified by:
globalConfigLoadInProgressin interfaceConfigurationProvider- Returns:
- true if it is in progress, false if not (done or failed).
-
bucketConfigLoadInProgress
public boolean bucketConfigLoadInProgress()
Description copied from interface:ConfigurationProviderReturns true if a bucket config load attempt is in progress.- Specified by:
bucketConfigLoadInProgressin interfaceConfigurationProvider- Returns:
- true if in progress, false if not.
-
-