Class BaseBucketLoader

java.lang.Object
com.couchbase.client.core.config.loader.BaseBucketLoader
All Implemented Interfaces:
BucketLoader
Direct Known Subclasses:
ClusterManagerBucketLoader, KeyValueBucketLoader

public abstract class BaseBucketLoader extends Object implements BucketLoader
The BaseBucketLoader contains all common functionality needed for the actual loader implementations.

This abstract parent class basically ensures that the service and node needed to possibly fetch a configuration are enabled. It might still fail in progress for whatever reason, but that's why there are fallbacks in place (in the form of other loaders).

Once a config is loaded, the base loader is also responsible for turning the string-based config into a proper config that can be distributed throughout the system.

Since:
2.0.0
  • Method Details

    • discoverConfig

      protected abstract Mono<byte[]> discoverConfig(NodeIdentifier seed, String bucket)
      To be implemented by the actual child, performs the actual fetching of a config.
      Parameters:
      seed - the node from where to fetch it.
      bucket - the name of the bucket to fetch from.
      Returns:
      the encoded json version of the config if complete, an error otherwise.
    • load

      public Mono<ProposedBucketConfigContext> load(NodeIdentifier seed, int port, String bucket, Optional<String> alternateAddress)
      Performs the config loading through multiple steps.

      First, it makes sure that the service is enabled so that the following child implementation can run its commands to actually fetch the config. Once the config is successfully loaded, it then turns it first into a proper string and then sends it to the bucket config parser to turn it into an actual config.

      Two things to note: $HOST is a special syntax by the cluster manager which the client needs to replace with the hostname where it loaded the config from. Also, at the end we are wrapping all non-config exceptions into config exceptions so that the upper level only needs to handle one specific exception type.

      At this point, we are passing an Optional.empty() for alternate addresses when the service is created, since we do not have a config to check against at this point. The config provider will take care of this at a later point in time, before the rest of the bootstrap happens.

      Specified by:
      load in interface BucketLoader
      Parameters:
      seed - the seed node to attempt loading from.
      port - the port to use when enabling the service.
      bucket - the name of the bucket.
      Returns:
      if successful, returns a config. It fails the mono otherwise.
    • core

      protected Core core()
      Returns the attached Core to be used by implementations.