Interface ServiceTaskProvider


public interface ServiceTaskProvider
The main api which allows read and write access to task configurations. This provider directly represents the holder of the configurations as well, therefore every lookup made through this class should not require a cluster wide lookup.

All tasks which are manageable via this provider are permanent. While a task a service is based on can be temporarily registered in the system, this provider will never return these tasks. A service holds the same configuration as a task, therefore no lookup of the task should be required. This does also mean that services could be based on a task but the task was unregistered while the service is running.

Since:
4.0
  • Method Details

    • reload

      void reload()
      Reloads this provider by clearing the backing task cache and re-reading all task configurations in the associated directory. Note that this method will not trigger a cluster re-sync of the task configurations.
    • serviceTasks

      Get all task configurations which are registered within the cluster. The backing collection will be updated if a group configuration was added via the api endpoint of any node in the cluster. Additions and removals to the returned collection are not possible and will not have any effect.
      Returns:
      all registered task configurations within the cluster.
    • serviceTask

      Get a task configuration which has the given name and is registered within the cluster. This method returns null if no task with the given name is registered.
      Parameters:
      name - the name of the task to get.
      Returns:
      the task configuration which has the given name or null if no task with the given name is registered.
      Throws:
      NullPointerException - if the given name is null.
    • addServiceTask

      boolean addServiceTask(@NonNull @NonNull ServiceTask serviceTask)
      Adds a new task configuration by caching the given object, creating the task file and syncing the change to all other nodes which are currently connected in the cluster. This method either creates the task or updates it if it already exists. There are no checks made if there is a diff before updating the configuration.
      Parameters:
      serviceTask - the task configuration to create or update.
      Returns:
      true if the service task was registered or updated, false otherwise.
      Throws:
      NullPointerException - if the given task configuration is null.
    • removeServiceTaskByName

      void removeServiceTaskByName(@NonNull @NonNull String name)
      Deletes the task configuration with the given name on the local node and all other nodes in the cluster by removing it from the backing collection and deleting the associated file.

      This method does nothing if no task configuration with the given name exists.

      Parameters:
      name - the name of the task configuration to remove.
      Throws:
      NullPointerException - if the given task name is null.
    • removeServiceTask

      void removeServiceTask(@NonNull @NonNull ServiceTask serviceTask)
      Deletes the task configuration with the given name on the local node and all other nodes in the cluster by removing it from the backing collection and deleting the associated file.

      This method does nothing if no task configuration with the given name exists.

      Parameters:
      serviceTask - the service task to remove.
      Throws:
      NullPointerException - if the given task name is null.
    • reloadAsync

      Reloads this provider by clearing the backing task cache and re-reading all task configurations in the associated directory. Note that this method will not trigger a cluster re-sync of the task configurations.
      Returns:
      a task completed when the provider was reloaded successfully.
    • serviceTasksAsync

      Get all task configurations which are registered within the cluster. The backing collection will be updated if a group configuration was added via the api endpoint of any node in the cluster. Additions and removals to the returned collection are not possible and will not have any effect.
      Returns:
      a task completed with all registered task configurations within the cluster.
    • serviceTaskAsync

      Get a task configuration which has the given name and is registered within the cluster. This method returns null if no task with the given name is registered.
      Parameters:
      name - the name of the task to get.
      Returns:
      a task completed with the task configuration which has the given name or null if such task exists.
      Throws:
      NullPointerException - if the given name is null.
    • addServiceTaskAsync

      Adds a new task configuration by caching the given object, creating the task file and syncing the change to all other nodes which are currently connected in the cluster. This method either creates the task or updates it if it already exists. There are no checks made if there is a diff before updating the configuration.
      Parameters:
      serviceTask - the task configuration to create or update.
      Returns:
      a task completed with true if the task configuration was registered or updated, false otherwise.
      Throws:
      NullPointerException - if the given task configuration is null.
    • removeServiceTaskByNameAsync

      @NonNull @NonNull CompletableFuture<Void> removeServiceTaskByNameAsync(@NonNull @NonNull String name)
      Deletes the task configuration with the given name on the local node and all other nodes in the cluster by removing it from the backing collection and deleting the associated file.

      This method does nothing if no task configuration with the given name exists.

      Parameters:
      name - the name of the task configuration to remove.
      Returns:
      a task completed when the service task with the given name was removed.
      Throws:
      NullPointerException - if the given task name is null.
    • removeServiceTaskAsync

      @NonNull @NonNull CompletableFuture<Void> removeServiceTaskAsync(@NonNull @NonNull ServiceTask serviceTask)
      Deletes the task configuration with the given name on the local node and all other nodes in the cluster by removing it from the backing collection and deleting the associated file.

      This method does nothing if no task configuration with the given name exists.

      Parameters:
      serviceTask - the service task to remove.
      Returns:
      a task completed when the given service task was removed.
      Throws:
      NullPointerException - if the given task name is null.