Class DefaultConfigurationProvider

  • All Implemented Interfaces:

    public class DefaultConfigurationProvider
    extends Object
    implements ConfigurationProvider
    The standard 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.

    • Constructor Detail

      • DefaultConfigurationProvider

        public DefaultConfigurationProvider​(Core core,
                                            Set<SeedNode> seedNodes)
        Creates a new configuration provider.
        core - the core against which all ops are executed.
    • Method Detail

      • seedNodes

        public Flux<Set<SeedNode>> seedNodes()
        Description copied from interface: ConfigurationProvider
        Returns 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:
        seedNodes in interface ConfigurationProvider
        a flux of new sets of seed nodes as they arrive.
      • openBucket

        public Mono<Void> openBucket​(String name)
        Description copied from interface: ConfigurationProvider
        Initiates 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:
        openBucket in interface ConfigurationProvider
        name - the name of the bucket to open.
        a Mono that completes once the bucket has been logically opened.
      • loadBucketConfigForSeed

        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.

        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.
        returns the bucket config context if present, or an error.
      • proposeBucketConfig

        public void proposeBucketConfig​(ProposedBucketConfigContext ctx)
        Description copied from interface: ConfigurationProvider
        Allows 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:
        proposeBucketConfig in interface ConfigurationProvider
        ctx - the bucket config and surrounding context.
      • closeBucket

        public Mono<Void> closeBucket​(String name)
        Description copied from interface: ConfigurationProvider
        Initiates the bucket closing process.
        Specified by:
        closeBucket in interface ConfigurationProvider
        name - the name of the bucket.
        a Mono that completes once the bucket has been logically closed.
      • shutdown

        public Mono<Void> shutdown()
        Description copied from interface: ConfigurationProvider
        Shuts down the configuration provider and all its associated resources and timers.
        Specified by:
        shutdown in interface ConfigurationProvider
        the mono completes once shut down properly.
      • 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.
        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.
        nodes - the list of nodes to check.
        nr - the network resolution setting from the environment
        seedHosts - the seed hosts from bootstrap for autoconfig.
        the found setting if external is used, null if internal/default is used.
      • registerRefresher

        protected Mono<Void> registerRefresher​(String bucket)
        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.

        bucket - the name of the bucket.
        a Mono once registered.
      • globalConfigLoadInProgress

        public boolean globalConfigLoadInProgress()
        Description copied from interface: ConfigurationProvider
        Returns true if an initial global config load attempt is in progress.
        Specified by:
        globalConfigLoadInProgress in interface ConfigurationProvider
        true if it is in progress, false if not (done or failed).