Class ServiceCreateRetryConfiguration.Builder

java.lang.Object
eu.cloudnetservice.driver.service.ServiceCreateRetryConfiguration.Builder
Enclosing class:
ServiceCreateRetryConfiguration

public static final class ServiceCreateRetryConfiguration.Builder extends Object
Represents a builder for a creation retry configuration.
Since:
4.0
  • Field Details

  • Constructor Details

    • Builder

      public Builder()
  • Method Details

    • maxRetries

      @NonNull public @NonNull ServiceCreateRetryConfiguration.Builder maxRetries(@Range(from=1L,to=2147483647L) int maxRetries)
      Sets the maximum amount of times to retry the service creation. Only numbers higher than zero are accepted by the method.

      If you want zero retries (or in other words no retries) use ServiceCreateRetryConfiguration.NO_RETRY instead.

      Parameters:
      maxRetries - the maximum amount of retries to do before marking the creation as failed.
      Returns:
      the same instance as used to call the method, for chaining.
      Throws:
      IllegalArgumentException - if the given max retries are lower or equal to zero.
    • fixedRetryDelay

      Sets the delay between each service creation retry to the given duration.
      Parameters:
      delay - the fixed delay between each service creation retry.
      Returns:
      the same instance as used to call the method, for chaining.
      Throws:
      NullPointerException - if the given retry duration is null.
    • backoffStrategy

      Sets the backoff strategy when retrying a service creation. Each index in the given collection will be used for the retry delay, the first one as the initial delay before the first retry. If the retry count exceeds the entries in the given collection, a fixed retry delay based on the last index will be used for further retries.
      Parameters:
      backoffStrategy - the backoff strategy to apply when retrying a service creation.
      Returns:
      the same instance as used to call the method, for chaining.
      Throws:
      NullPointerException - if the given backoff strategy is null.
    • modifyBackoffStrategy

      Modifies the backoff strategy which is currently applied to this builder.
      Parameters:
      modifier - the modifier to apply to the already added backoff entries of this builder.
      Returns:
      the same instance as used to call the method, for chaining.
      Throws:
      NullPointerException - if the given modifier function is null.
    • notificationReceivers

      Sets the receivers of state change events when a service creation which was deferred either succeeded or failed. The given targets will be notified about both these events. Already added receivers for one of the states will get overridden.

      The event will not be called on the receivers if no retry was needed, therefore the service either got created instantly or the creation failed because no retry was specified.

      Parameters:
      receivers - the receivers for state event changes of deferred service creations.
      Returns:
      the same instance as used to call the method, for chaining.
      Throws:
      NullPointerException - if the given receivers are null.
    • notificationReceivers

      Sets the receivers of state change events when a service creation which was deferred reached the given target state of the service creation. Already added receivers for the same state will get overridden.

      The event will not be called on the receivers if no retry was needed, therefore the service either got created instantly or the creation failed because no retry was specified.

      Parameters:
      state - the state in which the deferred service creation must run in order to call the receivers.
      receivers - the receivers for state event changes of deferred service creations.
      Returns:
      the same instance as used to call the method, for chaining.
      Throws:
      NullPointerException - if the given state or receivers are null.
    • notificationReceivers

      Sets the event receivers for state changes. These are mapped in a state-to-receivers relation, meaning that all receivers for key state will be called when a deferred creation results in the state. Adding receivers for the DEFERRED state is acceptable but will be without effect.

      The event will not be called on the receivers if no retry was needed, therefore the service either got created instantly or the creation failed because no retry was specified.

      Parameters:
      eventReceivers - the receivers mapping for state changes of deferred services.
      Returns:
      the same instance as used to call the method, for chaining.
      Throws:
      NullPointerException - if the given receiver mapping is null.
    • build

      Builds a new retry configuration based on the previously supplied properties.
      Returns:
      a new retry configuration based on this builder.
      Throws:
      IllegalArgumentException - if the backoff strategy has no entries.