Package org.infinispan.util
Interface ExponentialBackOff
-
- All Known Implementing Classes:
ExponentialBackOffImpl
@Experimental public interface ExponentialBackOffInterface to implement an exponential back-off algorithm that retries the request based on the result of the remote operation.This interface contains 2 methods:
backoffSleep()which should be invoked if the request needs to be retried andreset(), invoked when a request is "successful", which resets the state.The interface may me changed in the future to include async methods.
- Since:
- 12.0
- Author:
- Pedro Ruivo
-
-
Field Summary
Fields Modifier and Type Field Description static ExponentialBackOffNO_OPDisabled exponential back-off algorithm.
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description voidbackoffSleep()It blocks the thread for a certain amount of time before retries the request.voidreset()Resets its state.
-
-
-
Field Detail
-
NO_OP
static final ExponentialBackOff NO_OP
Disabled exponential back-off algorithm. It does nothing.
-
-
Method Detail
-
backoffSleep
void backoffSleep() throws InterruptedExceptionIt blocks the thread for a certain amount of time before retries the request.The method is blocking and should be invoked when a request needs to be retried. It blocks the thread for a certain amount of time until it is allowed to do the request again.
- Throws:
InterruptedException- If theThreadis interrupted while blocked.
-
reset
void reset()
Resets its state.The blocking time in
backoffSleep()increases with the number of consecutive retries. This methods resets its state back to the initial sleep time.
-
-