Interface CoreEnvironment

All Superinterfaces:
ConfigParserEnvironment, SecureEnvironment
All Known Implementing Classes:
DefaultCoreEnvironment

public interface CoreEnvironment
extends SecureEnvironment, ConfigParserEnvironment
A CoreEnvironment provides all the core building blocks like environment settings and thread pools so that the application can work with it properly. This interface defines the contract. How properties are loaded is chosen by the implementation. See the DefaultCoreEnvironment class for the default implementation. Note that the CoreEnvironment is stateful, so be sure to call shutdown() or shutdownAsync() properly.
  • Method Details

    • shutdown

      boolean shutdown()
      Shutdown the CoreEnvironment with the default timeout. Note: If this Environment has been created by the user, it is very important to properly close it, but only after all the related cluster and bucket resources need to be closed! Once an environment is shut down, all its contained resources cannot be used any longer! This method has been converted (after a deprecation phase) from an async method into a synchronous one. The async version can still be found at shutdownAsync().
      Returns:
      returning a boolean, indicating the success of the shutdown.
    • shutdown

      boolean shutdown​(long timeout, TimeUnit timeUnit)
      Shutdown the CoreEnvironment with a custom timeout. Note: If this Environment has been created by the user, it is very important to properly close it, but only after all the related cluster and bucket resources need to be closed! Once an environment is shut down, all its contained resources cannot be used any longer! This method has been converted (after a deprecation phase) from an async method into a synchronous one. The async version can still be found at shutdownAsync().
      Returns:
      returning a boolean, indicating the success of the shutdown.
    • disconnectTimeout

      long disconnectTimeout()
      The default timeout for disconnect operations, set to DefaultCoreEnvironment.DISCONNECT_TIMEOUT.
      Returns:
      the default disconnect timeout.
    • shutdownAsync

      rx.Observable<Boolean> shutdownAsync()
      Shutdown the CoreEnvironment in an asynchronous fashion. Note: If this Environment has been created by the user, it is very important to properly close it, but only after all the related cluster and bucket resources need to be closed! Once an environment is shut down, all its contained resources cannot be used any longer! Since this method is asynchronous and cold, it is important to subscribe to the observable to actually initiate the shutdown process.
      Returns:
      an Observable eventually returning a boolean, indicating the success of the shutdown.
    • ioPool

      EventLoopGroup ioPool()
      Returns the IO pool for the underlying IO framework, used as the default pool if not overridden for the individual services.
      Returns:
      the default IO pool, shared across resources.
    • kvIoPool

      EventLoopGroup kvIoPool()
      If set returns the IO Pool for the KV service, if not returns null.
      Returns:
      the KV IO pool if set, null otherwise.
    • viewIoPool

      EventLoopGroup viewIoPool()
      If set returns the IO Pool for the View service, if not returns null.
      Returns:
      the view IO pool if set, null otherwise.
    • queryIoPool

      EventLoopGroup queryIoPool()
      If set returns the IO Pool for the query service, if not returns null.
      Returns:
      the query IO pool if set, null otherwise.
    • searchIoPool

      EventLoopGroup searchIoPool()
      If set returns the IO Pool for the search service, if not returns null.
      Returns:
      the search IO pool if set, null otherwise.
    • analyticsIoPool

      EventLoopGroup analyticsIoPool()
      If set returns the IO Pool for the analytics service, if not returns null.
      Returns:
      the analytics IO pool if set, null otherwise.
    • kvServiceConfig

      KeyValueServiceConfig kvServiceConfig()
      Returns the current service configuration for the KV service. This configuration contains the number of endpoints per node that are to be established by the client. Note that the KV service config is a little less configurable than the HTTP based services since it has different runtime properties in terms of resource utilization and when establishing connections.
      Returns:
      the current config for the kv service.
    • queryServiceConfig

      QueryServiceConfig queryServiceConfig()
      Returns the current service configuration for the Query service. This configuration contains settings around minimum and maximum number of endpoints (sockets) per node as well as the idle time until an inactive endpoint is closed.
      Returns:
      the current config for the query service.
    • viewServiceConfig

      ViewServiceConfig viewServiceConfig()
      Returns the current service configuration for the View service. This configuration contains settings around minimum and maximum number of endpoints (sockets) per node as well as the idle time until an inactive endpoint is closed.
      Returns:
      the current config for the view service.
    • searchServiceConfig

      SearchServiceConfig searchServiceConfig()
      Returns the current service configuration for the Search service. This configuration contains settings around minimum and maximum number of endpoints (sockets) per node as well as the idle time until an inactive endpoint is closed.
      Returns:
      the current config for the search service.
    • analyticsServiceConfig

      AnalyticsServiceConfig analyticsServiceConfig()
      Returns the current service configuration for the Analytics service. This configuration contains settings around minimum and maximum number of endpoints (sockets) per node as well as the idle time until an inactive endpoint is closed.
      Returns:
      the current config for the analytics service.
    • scheduler

      rx.Scheduler scheduler()
      Returns the scheduler which should be used for all core actions that need to happen asynchronously.
      Returns:
      the scheduler used for internal operations.
    • bootstrapHttpEnabled

      boolean bootstrapHttpEnabled()
      If bootstrapping through HTTP is enabled.
      Returns:
      true if enabled.
    • bootstrapCarrierEnabled

      boolean bootstrapCarrierEnabled()
      If bootstrapping through the advanced carrier publication is enabled.
      Returns:
      true if enabled.
    • bootstrapHttpDirectPort

      int bootstrapHttpDirectPort()
      The port to use when bootstrapping through HTTP without SSL.
      Returns:
      the direct http port.
    • bootstrapHttpSslPort

      int bootstrapHttpSslPort()
      The port to use when bootstrapping through HTTP with SSL.
      Returns:
      the https port.
    • bootstrapCarrierDirectPort

      int bootstrapCarrierDirectPort()
      The port to use when bootstrapping through carrier publication without SSL.
      Returns:
      the direct carrier publication port.
    • bootstrapCarrierSslPort

      int bootstrapCarrierSslPort()
      The port to use when bootstrapping through carrier publication with SSL.
      Returns:
      the ssl carrier publication port.
    • ioPoolSize

      int ioPoolSize()
      Returns the configured IO pool size.
      Returns:
      the pool size (number of threads to use).
    • computationPoolSize

      int computationPoolSize()
      Returns the pool size (number of threads) for all computation tasks.
      Returns:
      the pool size (number of threads to use).
    • observeIntervalDelay

      Delay observeIntervalDelay()
      Returns the Delay for Observe poll operations.
      Returns:
      the observe interval delay.
    • reconnectDelay

      Delay reconnectDelay()
      Returns the Delay for node reconnects.
      Returns:
      the node reconnect delay.
    • retryDelay

      Delay retryDelay()
      Returns the Delay for request retries.
      Returns:
      the request retry delay.
    • requestBufferSize

      int requestBufferSize()
      Returns the size of the request ringbuffer.
      Returns:
      the size of the ringbuffer.
    • responseBufferSize

      int responseBufferSize()
      Returns the size of the response ringbuffer.
      Returns:
      the size of the ringbuffer.
    • kvEndpoints

      int kvEndpoints()
      The number of key/value service endpoints.
      Returns:
      amount of endpoints per service.
    • viewEndpoints

      int viewEndpoints()
      The number of view service endpoints.
      Returns:
      amount of endpoints per service.
    • queryEndpoints

      int queryEndpoints()
      The number of query service endpoints.
      Returns:
      amount of endpoints per service.
    • searchEndpoints

      int searchEndpoints()
      The number of search service endpoints.
      Returns:
      amount of endpoints per service.
    • coreVersion

      String coreVersion()
      Returns version information on the core. Version number is in the form MAJOR.MINOR.PATCH, and is the one for the core-io layer.
      Returns:
      the version string for the core.
      See Also:
      for a more specific build information (relevant for tracking the exact version of the code the core was built from)
    • coreBuild

      String coreBuild()
      Returns build information on the Couchbase Java SDK core. This has a better granularity than coreVersion() and thus is more relevant to track the exact version of the code the core was built from. Build information can contain VCS information like commit numbers, tags, etc...
      Returns:
      the build string for the core.
      See Also:
      for more generic version information.
    • userAgent

      String userAgent()
      Library identification string, which can be used as User-Agent header in HTTP requests.
      Returns:
      identification string
    • packageNameAndVersion

      String packageNameAndVersion()
      Returns name and the version of the package. This method used to by @{link userAgent()}.
      Returns:
      string containing package name and version
    • retryStrategy

      RetryStrategy retryStrategy()
      The retry strategy on how to dispatch requests in the failure case.
      Returns:
      the retry strategy.
    • maxRequestLifetime

      long maxRequestLifetime()
      Returns the maximum time in milliseconds a request is allowed to life. If the best effort retry strategy is used, the request will still be cancelled after this period to make sure that requests are not sticking around forever. Make sure it is longer than any timeout you potentially have configured.
      Returns:
      the maximum request lifetime.
    • autoreleaseAfter

      long autoreleaseAfter()
      The time in milliseconds after which a non-subscribed observable is going to be automatically released. This prevents accidentally leaking buffers when requested but not consumed by the user.
      Returns:
      the time after which the buffers are released if not subscribed.
    • keepAliveInterval

      long keepAliveInterval()
      The time in milliseconds after which some service will issue a form of keep-alive request.
      Returns:
      the interval of idle time in milliseconds after which a keep-alive is triggered.
    • continuousKeepAliveEnabled

      @Public @Uncommitted boolean continuousKeepAliveEnabled()
      If set to true, KeepAlives will be sent on a regular basis in the interval also if there is traffic on the socket, not only if its idle.
      Returns:
      true if enabled, false otherwise.
    • keepAliveErrorThreshold

      @Public @Uncommitted long keepAliveErrorThreshold()
      Specifies the number of times a KeepAlive message on a socket can fail before the connection is recycled.
      Returns:
      the number of keepalive errors allowed to happen before the socket is reopened.
    • keepAliveTimeout

      @Public @Uncommitted long keepAliveTimeout()
      Specifies the timeout of a keepalive operation on the socket in milliseconds.
      Returns:
    • eventBus

      EventBus eventBus()
      Returns the event bus where events are broadcasted on and can be published to.
      Returns:
      the configured event bus.
    • bufferPoolingEnabled

      boolean bufferPoolingEnabled()
      Returns if buffer pooling is enabled for greater GC efficiency. In general this is always set to true and should only be set to false if there are leaks reported that are not fixable by correcting user level code.
      Returns:
      true if enabled, false otherwise.
    • tcpNodelayEnabled

      boolean tcpNodelayEnabled()
      Returns true if TCP_NODELAY is enabled (therefore Nagle'ing is disabled).
      Returns:
      true if enabled.
    • mutationTokensEnabled

      boolean mutationTokensEnabled()
      Returns true if extended mutation tokens are enabled. Note that while this may return true, the server also needs to support it (Couchbase Server 4.0 and above). It will be negotiated during connection setup, but needs to be explicitly enabled on the environment as well to take effect (since it has a 16 bytes overhead on every mutation performed).
      Returns:
      true if enabled on the client side.
    • runtimeMetricsCollector

      MetricsCollector runtimeMetricsCollector()
      Returns the collector responsible for aggregating and publishing runtime information like gc and memory.
      Returns:
      the collector.
    • networkLatencyMetricsCollector

      NetworkLatencyMetricsCollector networkLatencyMetricsCollector()
      Returns the collector responsible for aggregating and publishing network latency information.
      Returns:
      the collector.
    • socketConnectTimeout

      int socketConnectTimeout()
      Returns the amount of time the SDK will wait on the socket connect until an error is raised and handled.
      Returns:
      the socket connect timeout in milliseconds.
    • callbacksOnIoPool

      boolean callbacksOnIoPool()
      Returns true if the Observable callbacks are completed on the IO event loops. Note: this is an advanced option and must be used with care. It can be used to improve performance since it removes additional scheduling overhead on the response path, but any blocking calls in the callbacks will lead to more work on the event loops itself and eventually stall them.
      Returns:
      true if callbacks are scheduled on the IO event loops.
    • requestBufferWaitStrategy

      @Experimental @Public WaitStrategyFactory requestBufferWaitStrategy()
      Waiting strategy used by request EventProcessors to wait for data from RingBuffer
      Returns:
      waiting strategy
    • configPollInterval

      @Committed @Public long configPollInterval()
      Returns the proactive polling interval for cluster configurations.
      Returns:
      the polling interval in milliseconds.
    • configPollFloorInterval

      @Committed @Public long configPollFloorInterval()
      Returns the minimum polling interval allowed.
      Returns:
      the minimum polling interval.
    • certAuthEnabled

      @Uncommitted @Public boolean certAuthEnabled()
      True if X.509 client certificate authentication is enabled.
    • couchbaseCoreSendHook

      Returns the CouchbaseCoreSendHook if set, null otherwise.
    • forceSaslPlain

      boolean forceSaslPlain()
      Forces the KeyValue SASL Authentication method to PLAIN if set to true, specifically allowing LDAP-based users to authenticate.
      Returns:
      true if plain should be forced, false otherwise (default).
    • operationTracingEnabled

      @Committed boolean operationTracingEnabled()
      True if tracing is enabled on the environment.
    • operationTracingServerDurationEnabled

      @Committed boolean operationTracingServerDurationEnabled()
      True if additional server duration tracing is enabled.
    • tracer

      @Committed io.opentracing.Tracer tracer()
      If tracing is enabled, contains the current tracer that should be used.
      Returns:
      the tracer to be used.
    • compressionEnabled

      boolean compressionEnabled()
      If true, compression is enabled and will be used if the min size and other thresholds match as well. If false, it won't even be negotiated with the server.
      Returns:
      true if enabled, false otherwise.
    • compressionMinSize

      int compressionMinSize()
      Returns the minimum size of a document to be considered for compression in the first place.
      Returns:
      the minimum size to be considered for compression, in bytes.
    • compressionMinRatio

      double compressionMinRatio()
      If the document is greater than the min compression size it is used for compression, but only sent if the compressed document has a greater compression ratio as the one provided.
      Returns:
      the minimum compression ratio for compression
    • orphanResponseReportingEnabled

      @Committed boolean orphanResponseReportingEnabled()
      Check if orphan response reporting is enabled. If it is, operations that are not listened to anymore are being fed into the orphan reporter and depending on the implementation (by default) logged.
      Returns:
      true if enabled.
    • orphanResponseReporter

      @Committed OrphanResponseReporter orphanResponseReporter()
      Returns the current orphan response reporter implementation.
    • networkResolution

      Allows to configure the network resolution, default being automatic.