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 dynamic Service.
Since:
1.1.0
Author:
Michael Nitschinger
  • Constructor Details

  • Method Details

    • dispatch

      protected abstract void dispatch(CouchbaseRequest request)
    • connect

      public rx.Observable<LifecycleState> connect()
      Description copied from interface: Service
      Connects all currently enabled Service Endpoints.
      Specified by:
      connect in interface Service
      Returns:
      the states of the Service after the connect process for all enabled Endpoints.
    • send

      public void send(CouchbaseRequest request)
      Description copied from interface: Service
      Sends a CouchbaseRequest into the service and eventually returns a CouchbaseResponse. The CouchbaseResponse is not returned directly, but is wrapped into a Observable.
      Specified by:
      send in interface Service
      Parameters:
      request - the request to send.
    • disconnect

      public rx.Observable<LifecycleState> disconnect()
      Description copied from interface: Service
      Disconnects all currently enabled Service Endpoints.
      Specified by:
      disconnect in interface Service
      Returns:
      the states of the Service after the disconnect process for all enabled Endpoints.
    • mapping

      public BucketServiceMapping mapping()
      Description copied from interface: Service
      Returns the mapping for the given Service.
      Specified by:
      mapping in interface Service
      Returns:
      the mapping.
    • 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 interface Service
    • 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.