Package de.dlr.proseo.storagemgr.model
Class DefaultRetryStrategy<T>
java.lang.Object
de.dlr.proseo.storagemgr.model.DefaultRetryStrategy<T>
A retry strategy for executing atomic operations. The class provides a
mechanism to retry a specified command multiple times until it succeeds or
reaches the configured maximum number of attempts.
- Author:
- Denys Chaykovskiy
-
Constructor Summary
ConstructorsConstructorDescriptionDefaultRetryStrategy(AtomicCommand<T> atomicCommand, int maxAttempts, long waitTime) The constructor initializes the retry strategy with the atomic command to be executed, the maximum number of attempts, and the wait time between each attempt. -
Method Summary
-
Constructor Details
-
DefaultRetryStrategy
The constructor initializes the retry strategy with the atomic command to be executed, the maximum number of attempts, and the wait time between each attempt.- Parameters:
atomicCommand- atomic commandmaxAttempts- maximal attemptswaitTime- wait time between retries
-
-
Method Details
-
execute
Tries to execute the atomic command and returns its result if successful. If the atomic command throws an IOException, the retry strategy catches and records it. It repeats the execution of the atomic command for a specified number of attempts, waiting for a certain time interval between each attempt. If the maximum number of attempts is reached without a successful execution, the retry strategy throws the recorded exception.- Returns:
- string with result of strategy execution
- Throws:
IOException- if atom command was not successful maxAttempts times
-