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.
|
protected Mono<ProposedBucketConfigContext> |
loadBucketConfigForSeed(NodeIdentifier identifier,
int mappedKvPort,
int mappedManagerPort,
String name,
Optional<String> alternateAddress)
Encapsulates the logic to load the bucket config from kv and then fall back to manager.
|
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 |
refreshCollectionId(CollectionIdentifier identifier)
Helper method to refresh the collection map for the given collection.
|
protected Mono<Void> |
registerRefresher(String bucket)
Registers the given bucket for refreshing.
|
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()
ConfigurationProvidercollectionMap in interface ConfigurationProviderpublic Flux<ClusterConfig> configs()
ConfigurationProviderconfigs in interface ConfigurationProviderpublic ClusterConfig config()
ConfigurationProviderClusterConfig.config in interface ConfigurationProviderpublic Flux<Set<SeedNode>> seedNodes()
ConfigurationProviderOnly 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 ConfigurationProviderpublic Mono<Void> openBucket(String name)
ConfigurationProviderNote 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 ConfigurationProvidername - the name of the bucket to open.protected Mono<ProposedBucketConfigContext> loadBucketConfigForSeed(NodeIdentifier identifier, int mappedKvPort, int mappedManagerPort, String name, Optional<String> alternateAddress)
This method can be overridden in tests to simulate various states/errors from the loaders.
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.alternateAddress - the alternate address, if present.public Mono<Void> loadAndRefreshGlobalConfig()
ConfigurationProviderloadAndRefreshGlobalConfig in interface ConfigurationProviderpublic void proposeBucketConfig(ProposedBucketConfigContext ctx)
ConfigurationProviderThis 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 ConfigurationProviderctx - the bucket config and surrounding context.public void proposeGlobalConfig(ProposedGlobalConfigContext ctx)
ConfigurationProviderproposeGlobalConfig in interface ConfigurationProviderctx - the context with the global config.public Mono<Void> closeBucket(String name)
ConfigurationProvidercloseBucket in interface ConfigurationProvidername - the name of the bucket.public Mono<Void> shutdown()
ConfigurationProvidershutdown in interface ConfigurationProviderpublic void refreshCollectionId(CollectionIdentifier identifier)
ConfigurationProviderrefreshCollectionId in interface ConfigurationProvideridentifier - the identifier to refresh.public boolean collectionMapRefreshInProgress()
ConfigurationProvidercollectionMapRefreshInProgress in interface ConfigurationProviderpublic 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.protected Mono<Void> registerRefresher(String bucket)
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.
bucket - the name of the bucket.Mono once registered.public boolean globalConfigLoadInProgress()
ConfigurationProviderglobalConfigLoadInProgress in interface ConfigurationProviderpublic boolean bucketConfigLoadInProgress()
ConfigurationProviderbucketConfigLoadInProgress in interface ConfigurationProviderCopyright © 2021 Couchbase, Inc.. All rights reserved.