Class AbstractDynamicService
- java.lang.Object
-
- com.couchbase.client.core.state.AbstractStateMachine<LifecycleState>
-
- com.couchbase.client.core.service.AbstractDynamicService
-
- All Implemented Interfaces:
Service
,Stateful<LifecycleState>
- Direct Known Subclasses:
AbstractLazyService
,AbstractOnDemandService
,AbstractPoolingService
public abstract class AbstractDynamicService extends AbstractStateMachine<LifecycleState> implements Service
Parent implementation of a dynamicService
.- Since:
- 1.1.0
- Author:
- Michael Nitschinger
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface com.couchbase.client.core.service.Service
Service.EndpointFactory
-
-
Constructor Summary
Constructors Modifier Constructor Description protected
AbstractDynamicService(String hostname, String bucket, String username, String password, int port, CoreContext ctx, int minEndpoints, Service.EndpointFactory endpointFactory)
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description rx.Observable<LifecycleState>
connect()
protected Endpoint
createEndpoint()
Helper method to create a new endpoint.rx.Observable<EndpointHealth>
diagnostics()
Returns endpoint health information for all endpoints this service is currently associated with.rx.Observable<LifecycleState>
disconnect()
protected abstract void
dispatch(CouchbaseRequest request)
protected List<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 givenService
.void
send(CouchbaseRequest request)
Sends aCouchbaseRequest
into the service and eventually returns aCouchbaseResponse
.protected static void
whenState(Endpoint endpoint, LifecycleState wanted, rx.functions.Action1<LifecycleState> then)
Waits until the endpoint goes into the given state, calls the action and then unsubscribes.-
Methods inherited from class com.couchbase.client.core.state.AbstractStateMachine
hasSubscribers, isState, state, states, transitionState
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface com.couchbase.client.core.state.Stateful
hasSubscribers, isState, state, states
-
-
-
-
Constructor Detail
-
AbstractDynamicService
protected AbstractDynamicService(String hostname, String bucket, String username, String password, int port, CoreContext ctx, int minEndpoints, Service.EndpointFactory endpointFactory)
-
-
Method Detail
-
dispatch
protected abstract void dispatch(CouchbaseRequest request)
-
connect
public rx.Observable<LifecycleState> connect()
Description copied from interface:Service
-
send
public void send(CouchbaseRequest request)
Description copied from interface:Service
Sends aCouchbaseRequest
into the service and eventually returns aCouchbaseResponse
. TheCouchbaseResponse
is not returned directly, but is wrapped into aObservable
.
-
disconnect
public rx.Observable<LifecycleState> disconnect()
Description copied from interface:Service
- Specified by:
disconnect
in interfaceService
- Returns:
- the states of the
Service
after the disconnect process for all enabledEndpoint
s.
-
mapping
public BucketServiceMapping mapping()
Description copied from interface:Service
Returns the mapping for the givenService
.
-
diagnostics
public rx.Observable<EndpointHealth> diagnostics()
Description copied from interface:Service
Returns endpoint health information for all endpoints this service is currently associated with.- Specified by:
diagnostics
in interfaceService
-
createEndpoint
protected Endpoint createEndpoint()
Helper method to create a new endpoint.- Returns:
- the endpoint to create.
-
logIdent
protected static String logIdent(String hostname, Service service)
Simple log helper to give logs a common prefix.- Parameters:
hostname
- the address.service
- the service.- Returns:
- a prefix string for logs.
-
endpoints
protected List<Endpoint> endpoints()
Returns the current list of endpoints.- Returns:
- the list of endpoints.
-
endpointStates
protected EndpointStateZipper endpointStates()
Returns the underlying endpoint state zipper.- Returns:
- the underlying state zipper.
-
whenState
protected static void whenState(Endpoint endpoint, LifecycleState wanted, rx.functions.Action1<LifecycleState> then)
Waits until the endpoint goes into the given state, calls the action and then unsubscribes.- Parameters:
endpoint
- the endpoint to monitor.wanted
- the wanted state.then
- the action to execute when the state is reached.
-
-