Class DefaultConfigurationProvider

  • All Implemented Interfaces:
    ConfigurationProvider

    public class DefaultConfigurationProvider
    extends Object
    implements ConfigurationProvider
    **The default implementation of a ConfigurationProvider.**

    The ConfigurationProvider is the central orchestrator for configuration management. Observers can observe bucket and cluster configurations from this component. Behind the scenes, it facilitates configuration loaders and configuration refreshers that grab initial configurations and keep them refreshed respectively. The structure looks like this:

    
         [ConfigurationProvider] --> [Config from REST]
         [ConfigurationProvider] --> [Config from Carrier]
    
         package "Config from REST" {
             [HttpLoader]
             [HttpRefresher]
         }
    
         [HttpLoader] --> 8091
         [HttpRefresher] --> 8091
    
         package "Config from Carrier" {
             [CarrierLoader]
             [CarrierRefresher]
         }
    
         [CarrierLoader] --> 11210
         [CarrierRefresher] --> 11210
    
     
    Since:
    1.0
    Author:
    Michael Nitschinger
    • Constructor Detail

      • DefaultConfigurationProvider

        public DefaultConfigurationProvider​(ClusterFacade cluster,
                                            CoreEnvironment environment)
        Create a new DefaultConfigurationProvider. When this constructor is used, the default loader chain is populated (first carrier is tried and the http loader is registered as a fallback).
        Parameters:
        cluster - the cluster reference.
        environment - the environment.
    • Method Detail

      • seedHosts

        public boolean seedHosts​(Set<String> hosts,
                                 boolean shuffle)
        Description copied from interface: ConfigurationProvider
        Set the initial seed hosts for bootstrap. This should only be done as long as the ConfigurationProvider is not bootstrapped, otherwise it might be ignored.
        Specified by:
        seedHosts in interface ConfigurationProvider
        Parameters:
        hosts - list of seed hosts.
        shuffle - shuffle seed host list.
        Returns:
        true if host list updated, false otherwise.
      • openBucket

        public rx.Observable<ClusterConfig> openBucket​(String bucket,
                                                       String password)
        Description copied from interface: ConfigurationProvider
        Start to fetch a config for the given bucket and also watch for changes, depending on the mechanism used.
        Specified by:
        openBucket in interface ConfigurationProvider
        Parameters:
        bucket - the name of the bucket.
        password - the name of the password.
        Returns:
        an observable with the configuration if success, and failures otherwise.
      • openBucket

        public rx.Observable<ClusterConfig> openBucket​(String bucket,
                                                       String username,
                                                       String password)
        Description copied from interface: ConfigurationProvider
        Start to fetch a config for the given bucket and also watch for changes, depending on the mechanism used.
        Specified by:
        openBucket in interface ConfigurationProvider
        Parameters:
        bucket - the name of the bucket.
        username - the user authorized for bucket access.
        password - the password of the user.
        Returns:
        an observable with the configuration if success, and failures otherwise.
      • determineNetworkResolution

        public static String determineNetworkResolution​(BucketConfig config,
                                                        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:
        config - the config to check against
        nr - the network resolution setting from the environment
        seedHosts - the seed hosts from bootstrap for autoconfig.
        Returns:
        the found setting if external is used, null if internal/default is used.