public abstract class AbstractDynamicService extends AbstractStateMachine<LifecycleState> implements Service
Parent implementation of a dynamic Service
.
Service.EndpointFactory
Modifier | Constructor and Description |
---|---|
protected |
AbstractDynamicService(String hostname,
String bucket,
String password,
int port,
CoreEnvironment env,
int minEndpoints,
com.lmax.disruptor.RingBuffer<ResponseEvent> responseBuffer,
Service.EndpointFactory endpointFactory) |
Modifier and Type | Method and Description |
---|---|
Observable<LifecycleState> |
connect()
|
protected Endpoint |
createEndpoint()
Helper method to create a new endpoint.
|
Observable<LifecycleState> |
disconnect()
|
protected abstract void |
dispatch(CouchbaseRequest request) |
protected Endpoint[] |
endpoints()
Returns the current list of endpoints.
|
protected EndpointStateZipper |
endpointStates()
Returns the underlying endpoint state zipper.
|
protected static String |
logIdent(String hostname,
Service service)
Simple log helper to give logs a common prefix.
|
BucketServiceMapping |
mapping()
Returns the mapping for the given
Service . |
void |
send(CouchbaseRequest request)
Sends a
CouchbaseRequest into the service and eventually returns a CouchbaseResponse . |
protected static void |
whenState(Endpoint endpoint,
LifecycleState wanted,
Action1<LifecycleState> then)
Waits until the endpoint goes into the given state, calls the action and then unsubscribes.
|
hasSubscribers, isState, state, states, transitionState
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
hasSubscribers, isState, state, states
protected AbstractDynamicService(String hostname, String bucket, String password, int port, CoreEnvironment env, int minEndpoints, com.lmax.disruptor.RingBuffer<ResponseEvent> responseBuffer, Service.EndpointFactory endpointFactory)
protected abstract void dispatch(CouchbaseRequest request)
public Observable<LifecycleState> connect()
Service
public void send(CouchbaseRequest request)
Service
Sends a CouchbaseRequest
into the service and eventually returns a CouchbaseResponse
.
The CouchbaseResponse
is not returned directly, but is wrapped into a Observable
.
public Observable<LifecycleState> disconnect()
Service
disconnect
in interface Service
Service
after the disconnect process for all enabled Endpoint
s.public BucketServiceMapping mapping()
Service
Returns the mapping for the given Service
.
protected Endpoint createEndpoint()
Helper method to create a new endpoint.
protected static String logIdent(String hostname, Service service)
Simple log helper to give logs a common prefix.
hostname
- the address.service
- the service.protected Endpoint[] endpoints()
Returns the current list of endpoints.
protected EndpointStateZipper endpointStates()
Returns the underlying endpoint state zipper.
protected static void whenState(Endpoint endpoint, LifecycleState wanted, Action1<LifecycleState> then)
Waits until the endpoint goes into the given state, calls the action and then unsubscribes.
endpoint
- the endpoint to monitor.wanted
- the wanted state.then
- the action to execute when the state is reached.Copyright © 2016 Couchbase, Inc.. All rights reserved.