Class DefaultConfigurationProvider
- All Implemented Interfaces:
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.
- Since:
- 1.0.0
-
Field Summary
Fields inherited from interface com.couchbase.client.core.config.ConfigurationProvider
TRIGGERED_BY_CONFIG_CHANGE_NOTIFICATION -
Constructor Summary
ConstructorsConstructorDescriptionDefaultConfigurationProvider(Core core, ConnectionString connectionString) Creates a new configuration provider. -
Method Summary
Modifier and TypeMethodDescriptionbooleanReturns true if a bucket config load attempt is in progress.reactor.core.publisher.Mono<Void> closeBucket(String name, boolean pushConfig) Initiates the bucket closing process.Returns the attached collection map.booleanReturns true while a collection refresh is in progress at all.booleancollectionRefreshInProgress(CollectionIdentifier identifier) Returns true if a collection refresh is in progress for the given identifier.config()Returns the currentClusterConfig.reactor.core.publisher.Flux<Long> Returns a feed that emits -1L whenever someone callsConfigurationProvider.signalConfigChanged().reactor.core.publisher.Flux<ClusterConfig> configs()This is a hot stream which when attached will return the current config as well as all subsequent ones.booleanReturns true if an initial global config load attempt is in progress.reactor.core.publisher.Mono<Void> Instructs the provider to try and load the global config, and then manage it.protected reactor.core.publisher.Mono<ProposedBucketConfigContext> loadBucketConfigForSeed(NodeIdentifier identifier, int mappedKvPort, int mappedManagerPort, String name) Encapsulates the logic to load the bucket config from kv and then fall back to manager.reactor.core.publisher.Mono<Void> openBucket(String name) Initiates the bucket opening process.performDnsSrvLookup(boolean tlsEnabled) Performs DNS SRV lookups - and can be overridden by test classes.voidAllows to propose a bucket config to the provider from an external context.voidAllows to propose a global config to the provider from an external context.voidrefreshCollectionId(CollectionIdentifier identifier) Helper method to refresh the collection map for the given collection.protected reactor.core.publisher.Mono<Void> registerRefresher(String bucket) Registers the given bucket for refreshing.voidShouldn't be necessary, but givesInvalidStateWatchdogsomething to do.Returns a stream of seed node sets sourced from the server's global config or bucket config.reactor.core.publisher.Mono<Void> shutdown()Shuts down the configuration provider and all its associated resources and timers.voidSignals to the config provider that the server sent a notification that the cluster topology or bucket config changed.voidSignals to the config provider that certain types of config refreshes failed and action might need to be taken.
-
Constructor Details
-
DefaultConfigurationProvider
Creates a new configuration provider.- Parameters:
core- the core against which all ops are executed.
-
-
Method Details
-
collectionMap
Description copied from interface:ConfigurationProviderReturns the attached collection map.- Specified by:
collectionMapin interfaceConfigurationProvider
-
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
Description copied from interface:ConfigurationProviderReturns the currentClusterConfig.- Specified by:
configin interfaceConfigurationProvider- Returns:
- the current cluster configuration.
-
seedNodes
Description copied from interface:ConfigurationProviderReturns a stream of seed node sets sourced from the server's global config or bucket config.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.
- Specified by:
seedNodesin interfaceConfigurationProvider- Returns:
- a flux of new sets of seed nodes as they arrive.
-
openBucket
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.
-
loadBucketConfigForSeed
protected reactor.core.publisher.Mono<ProposedBucketConfigContext> loadBucketConfigForSeed(NodeIdentifier identifier, int mappedKvPort, int mappedManagerPort, String name) Encapsulates the logic to load the bucket config from kv and then fall back to manager.This method can be overridden in tests to simulate various states/errors from the loaders.
- Parameters:
identifier- the identifier to load it from.mappedKvPort- the port of the kv loader.mappedManagerPort- the port for the manager.name- the name of the bucket.- Returns:
- returns the bucket config context if present, or an error.
-
loadAndRefreshGlobalConfig
Description copied from interface:ConfigurationProviderInstructs the provider to try and load the global config, and then manage it.- Specified by:
loadAndRefreshGlobalConfigin interfaceConfigurationProvider
-
proposeGlobalConfig
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.
-
proposeBucketConfig
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.
-
closeBucket
Description copied from interface:ConfigurationProviderInitiates the bucket closing process.- Specified by:
closeBucketin interfaceConfigurationProvider- Parameters:
name- the name of the bucket.pushConfig- whether this should result in a config being pushed. Not needed during e.g. shutdown.- Returns:
- a Mono that completes once the bucket has been logically closed.
-
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.
-
refreshCollectionId
Description copied from interface:ConfigurationProviderHelper method to refresh the collection map for the given collection. Returns after refreshed completes the mono (or fails if error).- Specified by:
refreshCollectionIdin interfaceConfigurationProvider- Parameters:
identifier- the identifier to refresh.
-
collectionRefreshInProgress
public boolean collectionRefreshInProgress()Description copied from interface:ConfigurationProviderReturns true while a collection refresh is in progress at all.- Specified by:
collectionRefreshInProgressin interfaceConfigurationProvider
-
collectionRefreshInProgress
Description copied from interface:ConfigurationProviderReturns true if a collection refresh is in progress for the given identifier.- Specified by:
collectionRefreshInProgressin interfaceConfigurationProvider- Parameters:
identifier- the collection identifier to check.
-
republishCurrentConfig
public void republishCurrentConfig()Description copied from interface:ConfigurationProviderShouldn't be necessary, but givesInvalidStateWatchdogsomething to do.- Specified by:
republishCurrentConfigin interfaceConfigurationProvider
-
registerRefresher
Registers the given bucket for refreshing.Note that this changes the implementation from the 1.x series a bit. In the past, whatever loader succeeded automatically registered the same type of refresher. This is still the case for situations like a memcache bucket, but in cases where we bootstrap from i.e. a query node only the manager loader will work but we'll be able to use the key value refresher going forward.
As a result, this method is a bit more intelligent in selecting the right refresher based on the loaded configuration.
- Parameters:
bucket- the name of the bucket.- Returns:
- a
Monoonce registered.
-
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.
-
signalConfigRefreshFailed
Description copied from interface:ConfigurationProviderSignals to the config provider that certain types of config refreshes failed and action might need to be taken.- Specified by:
signalConfigRefreshFailedin interfaceConfigurationProvider- Parameters:
failure- the type of config refresh failure.
-
signalConfigChanged
public void signalConfigChanged()Description copied from interface:ConfigurationProviderSignals to the config provider that the server sent a notification that the cluster topology or bucket config changed.- Specified by:
signalConfigChangedin interfaceConfigurationProvider
-
configChangeNotifications
Description copied from interface:ConfigurationProviderReturns a feed that emits -1L whenever someone callsConfigurationProvider.signalConfigChanged().- Specified by:
configChangeNotificationsin interfaceConfigurationProvider
-
performDnsSrvLookup
Performs DNS SRV lookups - and can be overridden by test classes.- Returns:
- the (potentially empty) DNS SRV records after the lookup.
- Throws:
NamingException
-