Class ServiceCreateRetryConfiguration
java.lang.Object
eu.cloudnetservice.driver.service.ServiceCreateRetryConfiguration
- All Implemented Interfaces:
Cloneable
A configuration applied when the initial creation of a service fails. The caller has the ability to specify how the
retry of the service creation should be done. Additionally, if the service creation was deferred the further state
changes will be published to the configured event receivers.
- Since:
- 4.0
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic final classRepresents a builder for a creation retry configuration. -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final Map<ServiceCreateResult.State, List<ChannelMessageTarget>> private final intstatic final ServiceCreateRetryConfigurationA jvm static retry configuration which will not retry failed service creations. -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedServiceCreateRetryConfiguration(int maxRetries, @NonNull List<Long> backoffStrategy, @NonNull Map<ServiceCreateResult.State, List<ChannelMessageTarget>> eventReceivers) Constructs a new retry configuration instance. -
Method Summary
Modifier and TypeMethodDescriptionGet an unmodifiable copy of the backoff strategy which should be applied when retrying the service creation.builder()Constructs a new builder instance for a retry configuration.builder(@NonNull ServiceCreateRetryConfiguration retryConfiguration) Creates a new retry configuration builder which has the same options set as the given retry configuration.clone()booleanenabled()Checks if this configuration is enabled, in other words if there is at least one retry and delay specified.Get an unmodifiable copy of the event receivers which should get notified about state change events if the service creation was deferred.intGet the maximum number of retries until the retry process should stop.
-
Field Details
-
NO_RETRY
A jvm static retry configuration which will not retry failed service creations. -
maxRetries
private final int maxRetries -
backoffStrategy
-
eventReceivers
-
-
Constructor Details
-
ServiceCreateRetryConfiguration
protected ServiceCreateRetryConfiguration(int maxRetries, @NonNull @NonNull List<Long> backoffStrategy, @NonNull @NonNull Map<ServiceCreateResult.State, List<ChannelMessageTarget>> eventReceivers) Constructs a new retry configuration instance.- Parameters:
maxRetries- the maximum amount of retries for the service creation.backoffStrategy- the strategy to apply to delay the service creation based on executed times.eventReceivers- the receivers of state events if the creation was deferred.- Throws:
NullPointerException- if the given backoff strategy or event receivers are null.
-
-
Method Details
-
builder
Constructs a new builder instance for a retry configuration.- Returns:
- a new retry configuration builder.
-
builder
@NonNull public static @NonNull ServiceCreateRetryConfiguration.Builder builder(@NonNull @NonNull ServiceCreateRetryConfiguration retryConfiguration) Creates a new retry configuration builder which has the same options set as the given retry configuration. Changes made to the given configuration will not reflect into the new builder and vice-versa.When calling build directly after creating the builder based on the given retry configuration it will return a retry configuration which is equal to the given one, but not identical.
- Parameters:
retryConfiguration- the configuration to copy the set options of.- Returns:
- a new builder instance which has the same options set as the given configuration.
- Throws:
NullPointerException- if the given configuration is null.
-
enabled
public boolean enabled()Checks if this configuration is enabled, in other words if there is at least one retry and delay specified.- Returns:
- if this configuration is enabled.
-
maxRetries
public int maxRetries()Get the maximum number of retries until the retry process should stop. Negative values or zero indicate that no retry attempts should be made.- Returns:
- the maximum number of retries.
-
backoffStrategy
Get an unmodifiable copy of the backoff strategy which should be applied when retrying the service creation. An empty list indicates that no retry attempts should be made.- Returns:
- the backoff strategy which should be applied when retrying the service creation.
-
eventReceivers
@NonNull public @Unmodifiable @NonNull Map<ServiceCreateResult.State, List<ChannelMessageTarget>> eventReceivers()Get an unmodifiable copy of the event receivers which should get notified about state change events if the service creation was deferred. The listeners won't be called if the service creation succeeded or failed without any retries.- Returns:
- the event receivers for deferred service state changes.
-
clone
-