public abstract class AbstractLoader extends Object implements Loader
AbstractLoader
which provides common basic processing for all implementing loaders.
A loader fetches configuration from a service, maybe falls back to another service and finally response with a
BucketConfig
or an error. There are multiple steps, like making sure that a node or service is alive before
sending a request into, is abstracted in here to avoid duplication.Modifier | Constructor and Description |
---|---|
protected |
AbstractLoader(LoaderType loaderType,
ServiceType serviceType,
ClusterFacade cluster,
CoreEnvironment environment)
Create a new
AbstractLoader . |
Modifier and Type | Method and Description |
---|---|
protected ClusterFacade |
cluster()
Returns the
ClusterFacade for child implementations. |
protected abstract rx.Observable<String> |
discoverConfig(String bucket,
String username,
String password,
String hostname)
Run the
BucketConfig discovery process. |
protected CoreEnvironment |
env()
Returns the
CoreEnvironment for child implementations. |
rx.Observable<Tuple2<LoaderType,BucketConfig>> |
loadConfig(String seedNode,
String bucket,
String password)
Initiate the config loading process.
|
rx.Observable<Tuple2<LoaderType,BucketConfig>> |
loadConfig(String seedNode,
String bucket,
String username,
String password)
Initiate the config loading process.
|
protected abstract int |
port(String hostname)
Port to use for the
ServiceType . |
protected String |
replaceHostWildcard(String input,
String hostname)
Replaces the host wildcard from an incoming config with a proper hostname.
|
protected Integer |
tryLoadingPortFromConfig(String hostname)
Tries to identify a prt from a config if present, null otherwise.
|
protected AbstractLoader(LoaderType loaderType, ServiceType serviceType, ClusterFacade cluster, CoreEnvironment environment)
AbstractLoader
.serviceType
- the service serviceType.cluster
- the cluster reference.environment
- the couchbase environment.protected abstract int port(String hostname)
ServiceType
.
This method needs to be implemented by the actual loader and defines the port which should be used to
connect the service to. In practice, the actual port may depend on the environment (i.e. if SSL is used or not).protected Integer tryLoadingPortFromConfig(String hostname)
hostname
- the hostname to identify a port from.protected abstract rx.Observable<String> discoverConfig(String bucket, String username, String password, String hostname)
BucketConfig
discovery process.bucket
- the name of the bucket.username
- user authorized for bucket access.password
- the password of the user.hostname
- the hostname of the seed node list.public rx.Observable<Tuple2<LoaderType,BucketConfig>> loadConfig(String seedNode, String bucket, String password)
loadConfig
in interface Loader
seedNode
- the seed node.bucket
- the name of the bucket.password
- the password of the bucket.BucketConfig
.public rx.Observable<Tuple2<LoaderType,BucketConfig>> loadConfig(String seedNode, String bucket, String username, String password)
loadConfig
in interface Loader
seedNode
- the seed node.bucket
- the name of the bucket.username
- the user authorized for bucket access.password
- the password of the user.BucketConfig
.protected ClusterFacade cluster()
ClusterFacade
for child implementations.protected CoreEnvironment env()
CoreEnvironment
for child implementations.Copyright © 2021 Couchbase, Inc.. All rights reserved.