Klasse DefaultRetryStrategy<T>

java.lang.Object
de.dlr.proseo.storagemgr.model.DefaultRetryStrategy<T>

public class DefaultRetryStrategy<T> extends Object
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.
Autor:
Denys Chaykovskiy
  • Konstruktorübersicht

    Konstruktoren
    Konstruktor
    Beschreibung
    DefaultRetryStrategy(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.
  • Methodenübersicht

    Modifizierer und Typ
    Methode
    Beschreibung
    Tries to execute the atomic command and returns its result if successful.

    Von Klasse geerbte Methoden java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Konstruktordetails

    • DefaultRetryStrategy

      public DefaultRetryStrategy(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.
      Parameter:
      atomicCommand - atomic command
      maxAttempts - maximal attempts
      waitTime - wait time between retries
  • Methodendetails

    • execute

      public T execute() throws IOException
      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.
      Gibt zurück:
      string with result of strategy execution
      Löst aus:
      IOException - if atom command was not successful maxAttempts times