public abstract class AbstractLoader extends Object implements Loader
An 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,
NetworkAddress hostname)
Run the
BucketConfig discovery process. |
protected CoreEnvironment |
env()
Returns the
CoreEnvironment for child implementations. |
rx.Observable<Tuple2<LoaderType,BucketConfig>> |
loadConfig(NetworkAddress seedNode,
String bucket,
String password)
Initiate the config loading process.
|
rx.Observable<Tuple2<LoaderType,BucketConfig>> |
loadConfig(NetworkAddress seedNode,
String bucket,
String username,
String password)
Initiate the config loading process.
|
protected abstract int |
port()
Port to use for the
ServiceType . |
protected String |
replaceHostWildcard(String input,
NetworkAddress hostname)
Replaces the host wildcard from an incoming config with a proper hostname.
|
protected AbstractLoader(LoaderType loaderType, ServiceType serviceType, ClusterFacade cluster, CoreEnvironment environment)
Create a new AbstractLoader
.
serviceType
- the service serviceType.cluster
- the cluster reference.environment
- the couchbase environment.protected abstract int port()
Port to use for the 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 abstract rx.Observable<String> discoverConfig(String bucket, String username, String password, NetworkAddress hostname)
Run the 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(NetworkAddress seedNode, String bucket, String password)
Initiate the config loading process.
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(NetworkAddress seedNode, String bucket, String username, String password)
Initiate the config loading process.
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()
Returns the ClusterFacade
for child implementations.
protected CoreEnvironment env()
Returns the CoreEnvironment
for child implementations.
protected String replaceHostWildcard(String input, NetworkAddress hostname)
Replaces the host wildcard from an incoming config with a proper hostname.
input
- the input config.hostname
- the hostname to replace it with.Copyright © 2018 Couchbase, Inc.. All rights reserved.