Class BaseLoader
- java.lang.Object
-
- com.couchbase.client.core.config.loader.BaseLoader
-
- All Implemented Interfaces:
Loader
- Direct Known Subclasses:
ClusterManagerLoader
,KeyValueLoader
public abstract class BaseLoader extends Object implements Loader
TheBaseLoader
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 Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description protected Core
core()
Returns the attachedCore
to be used by implementations.protected abstract Mono<byte[]>
discoverConfig(NodeIdentifier seed, String bucket)
To be implemented by the actual child, performs the actual fetching of a config.Mono<ProposedBucketConfigContext>
load(NodeIdentifier seed, int port, String bucket)
Performs the config loading through multiple steps.
-
-
-
Method Detail
-
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)
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.
-
-