Class Core

  • @Volatile
    public class Core
    extends Object
    The main entry point into the core layer.

    This class has been around behind a facade in the 1.x days, but here it is just a plain simple class that can be instantiated and is used across the upper language bindings.

    • Constructor Detail

    • Method Detail

      • create

        public static Core create​(CoreEnvironment environment,
                                  Authenticator authenticator,
                                  Set<SeedNode> seedNodes)
        Creates a new Core with the given environment.
        environment - the environment for this core.
        the created Core.
      • configurationProvider

        public ConfigurationProvider configurationProvider()
        Returns the attached configuration provider.

        Internal API, use with care!

      • send

        public <R extends Response> void send​(Request<R> request)
        Sends a command into the core layer and registers the request with the timeout timer.
        request - the request to dispatch.
      • send

        public <R extends Response> void send​(Request<R> request,
                                              boolean registerForTimeout)
        Sends a command into the core layer and allows to avoid timeout registration.

        Usually you want to use send(Request) instead, this method should only be used during retry situations where the request has already been registered with a timeout timer before.

        request - the request to dispatch.
        registerForTimeout - if the request should be registered with a timeout.
      • serviceState

        public Optional<Flux<ServiceState>> serviceState​(NodeIdentifier nodeIdentifier,
                                                         ServiceType type,
                                                         Optional<String> bucket)
        If present, returns a flux that allows to monitor the state changes of a specific service.
        nodeIdentifier - the node identifier for the node.
        type - the type of service.
        bucket - the bucket, if present.
        if found, a flux with the service states.
      • initGlobalConfig

        public void initGlobalConfig()
        Instructs the client to, if possible, load and initialize the global config.

        Since global configs are an "optional" feature depending on the cluster version, if an error happens this method will not fail. Rather it will log the exception (with some logic dependent on the type of error) and will allow the higher level components to move on where possible.

      • openBucket

        public void openBucket​(String name)
        Attempts to open a bucket and fails the Mono if there is a persistent error as the reason.
      • clusterConfig

        public ClusterConfig clusterConfig()
        This API provides access to the current config that is published throughout the core.

        Note that this is internal API and might change at any time.

      • ensureServiceAt

        public Mono<Void> ensureServiceAt​(NodeIdentifier identifier,
                                          ServiceType serviceType,
                                          int port,
                                          Optional<String> bucket,
                                          Optional<String> alternateAddress)
        This method can be used by a caller to make sure a certain service is enabled at the given target node.

        This is advanced, internal functionality and should only be used if the caller knows what they are doing.

        identifier - the node to check.
        serviceType - the service type to enable if not enabled already.
        port - the port where the service is listening on.
        bucket - if the service is bound to a bucket, it needs to be provided.
        alternateAddress - if an alternate address is present, needs to be provided since it is passed down to the node and its services.
        a Mono which completes once initiated.
      • createNode

        protected Node createNode​(NodeIdentifier identifier,
                                  Optional<String> alternateAddress)
        Create a Node from the given identifier.

        This method is here so it can be overridden in tests.

        identifier - the identifier for the node.
        alternateAddress - the alternate address if present.
        the created node instance.
      • shutdown

        public Mono<Void> shutdown​(Duration timeout)
        Shuts down this core and all associated, owned resources.