Interface CloudServiceFactory


public interface CloudServiceFactory
The main factory class to create cloud services based on a given service configuration. This factory is designed to automatically run all needed checks against the given configuration and ensures that services are split in the best way onto all nodes in the cluster, while respecting all settings made to the service configuration (for example if the service configuration already has the node set to start the service on, the factory will think about on which node it should start the service).

The taken input configurations are always cloned before being used, so there is no need to do this manually. This is due to the fact, that

  1. there might be changes made by the system to the given configuration which should not get reflected to the later created services based on the configuration.
  2. changes made to the configuration should not get reflected into the service, this might lead to unexpected behaviour of the system.

A method call to any of the create methods will always generate a different result if the service was created successfully, even if the same configuration was used multiple times. You can safely assume, that a service created by this factory is ALWAYS unique.

All factory methods are thread safe, calling them with the same configuration across multiple threads will not lead to duplicate service results.

Since:
4.0
  • Method Details

    • createCloudService

      @NonNull @NonNull ServiceCreateResult createCloudService(@NonNull @NonNull ServiceConfiguration serviceConfiguration)
      Creates and prepares a new cloud service based on the given configuration. This method can be called with the same configuration multiple times and will always (if the service was created successfully) in a different result.

      This method will return a result with the state set to FAILED if the service could not get created. This can happen (for example) if:

      1. no node in the cluster can currently pick up the service (for example if all nodes are draining).
      2. the configured node in the configuration is not connected or draining.
      3. the selected node to start the service did not respond within a given time (uncommon).
      This list only includes some common reasons for the service not getting created. Not that there is never a guarantee that the method returns a (non-null) service result.

      The result of the service creation will only have a state of DEFERRED if a retry configuration was provided to the given service configuration.

      Parameters:
      serviceConfiguration - the configuration to base the newly created service on.
      Returns:
      a result representing the state of the service creation.
      Throws:
      NullPointerException - if the given service configuration is null.
    • createCloudServiceAsync

      Creates and prepares a new cloud service based on the given configuration. This method can be called with the same configuration multiple times and will always (if the service was created successfully) in a different result.

      This method will return a task completed with null if the service could not get created. This can happen (for example) if:

      1. no node in the cluster can currently pick up the service (for example if all nodes are draining).
      2. the configured node in the configuration is not connected or draining.
      3. the selected node to start the service did not respond within a given time (uncommon).
      This list only includes some common reasons for the service not getting created. Not that there is never a guarantee that the method returns a (non-null) service result.

      The result of the service creation will only have a state of DEFERRED if a retry configuration was provided to the given service configuration.

      Parameters:
      configuration - the configuration to base the newly created service on.
      Returns:
      a task completed with a result representing the state of the service creation.
      Throws:
      NullPointerException - if the given service configuration is null.