java.lang.Object
io.helidon.config.SimpleRetryPolicy
- All Implemented Interfaces:
RetryPolicy,Supplier<RetryPolicy>
A default retry policy implementation with
ScheduledExecutorService.
Following attributes can be configured:
- number of retries (excluding the first invocation)
- delay between the invocations
- a delay multiplication factor
- a timeout for the individual invocation
- an overall timeout
- an executor service
-
Nested Class Summary
Nested Classes -
Method Summary
Modifier and TypeMethodDescriptionstatic SimpleRetryPolicy.Builderbuilder()Fluent API builder forSimpleRetryPolicy.Timeout of the call.booleancancel(boolean mayInterruptIfRunning) Cancels the current use of the retry policy.static SimpleRetryPolicyInitializes retry policy instance from configuration properties.delay()Delay between retries.doubleDelay multiplication factor.<T> TInvokes the providedSupplierto read the source data and returns that data.Overall timeout.intretries()Number of retries.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface io.helidon.config.spi.RetryPolicy
get
-
Method Details
-
builder
Fluent API builder forSimpleRetryPolicy.- Returns:
- a new builder
-
create
Initializes retry policy instance from configuration properties.Mandatory
properties, seeRetryPolicies.repeat(int):retries- typeint
properties:delay- typeDuration, seeSimpleRetryPolicy.Builder.delay(Duration)delay-factor- typedouble, seeSimpleRetryPolicy.Builder.delayFactor(double)call-timeout- typeDuration, seeSimpleRetryPolicy.Builder.callTimeout(Duration)overall-timeout- typeDuration, seeSimpleRetryPolicy.Builder.overallTimeout(Duration)
- Parameters:
metaConfig- meta-configuration used to initialize returned polling strategy builder instance from.- Returns:
- new instance of polling strategy builder described by
metaConfig - Throws:
MissingValueException- in case the configuration tree does not contain all expected sub-nodes required by the mapper implementation to provide instance of Java type.ConfigMappingException- in case the mapper fails to map the (existing) configuration tree represented by the supplied configuration node to an instance of a given Java type.- See Also:
-
execute
Description copied from interface:RetryPolicyInvokes the providedSupplierto read the source data and returns that data.The implementation of this method incorporates the retry logic.
- Specified by:
executein interfaceRetryPolicy- Type Parameters:
T- result type- Parameters:
call- supplier ofT- Returns:
- loaded data returned by the provided
Supplier - Throws:
ConfigException
-
cancel
public boolean cancel(boolean mayInterruptIfRunning) Description copied from interface:RetryPolicyCancels the current use of the retry policy.Implementations should correctly handle three cases:
cancelinvoked when no invocation ofexecuteis in progress,cancelinvoked when an invocation ofexecuteis active but no attempted load is actually in progress (e.g., a prior attempt failed and the retry policy is waiting for some time to pass before trying again), andcancelinvoked while a load attempt is in progress.
- Specified by:
cancelin interfaceRetryPolicy- Parameters:
mayInterruptIfRunning- whether an in-progress load attempt should be interrupted- Returns:
falseif the task could not be canceled, typically because it has already completed;trueotherwise
-
retries
public int retries()Number of retries.- Returns:
- retries
-
delay
Delay between retries.- Returns:
- delay
-
delayFactor
public double delayFactor()Delay multiplication factor.- Returns:
- delay factor
-
callTimeout
Timeout of the call.- Returns:
- call timeout
-
overallTimeout
Overall timeout.- Returns:
- overall timeout
-