Package io.deephaven.util
Class RetryBackoffContext.Exponential
java.lang.Object
io.deephaven.util.RetryBackoffContext.Exponential
- All Implemented Interfaces:
RetryBackoffContext
- Enclosing interface:
- RetryBackoffContext
Helper class to
Borrowing the retry backoff algorithm from
gRPC reconnection
-
Nested Class Summary
Nested ClassesNested classes/interfaces inherited from interface io.deephaven.util.RetryBackoffContext
RetryBackoffContext.Exponential
-
Constructor Summary
ConstructorsConstructorDescriptionCreate an Exponential Backoff Context -
Method Summary
Modifier and TypeMethodDescriptionlong
Return the time in milliseconds to wait to the next retry.boolean
Check if we have exceeded our time deadline to retry.long
Return the elapsed between the last time toRetryBackoffContext.deadlineExceeded()
and the last call toRetryBackoffContext.start(long)
.void
Inform this context object that a retry without applying backoff will be performed.int
Number of retries performed.void
start
(long timeOfDeadlineMillis) Start tracking time to execute a backoff retry strategy using this context object.long
Absolute point in time when the last call toRetryBackoffContext.startMillis()
was invoked.long
Returns the absolute epoch time in milliseconds for the deadline.
-
Constructor Details
-
Exponential
Create an Exponential Backoff Context- Parameters:
params
- parameters for the context
-
-
Method Details
-
start
public void start(long timeOfDeadlineMillis) Description copied from interface:RetryBackoffContext
Start tracking time to execute a backoff retry strategy using this context object. A deadline is defined when this method is called.- Specified by:
start
in interfaceRetryBackoffContext
- Parameters:
timeOfDeadlineMillis
- absolute time as milliseconds from the epoch to the deadline.
-
retryCount
public int retryCount()Description copied from interface:RetryBackoffContext
Number of retries performed. Useful for clients that want to log a retry summary after deadline exceeded.- Specified by:
retryCount
in interfaceRetryBackoffContext
- Returns:
- number of retries performed.
-
startMillis
public long startMillis()Description copied from interface:RetryBackoffContext
Absolute point in time when the last call toRetryBackoffContext.startMillis()
was invoked.- Specified by:
startMillis
in interfaceRetryBackoffContext
- Returns:
- a milliseconds from the epoch timestamp.
-
deadlineExceeded
public boolean deadlineExceeded()Description copied from interface:RetryBackoffContext
Check if we have exceeded our time deadline to retry.- Specified by:
deadlineExceeded
in interfaceRetryBackoffContext
- Returns:
- true if the retry deadline has been exceeded, false otherwise.
-
noBackoff
public void noBackoff()Description copied from interface:RetryBackoffContext
Inform this context object that a retry without applying backoff will be performed.If the caller has some criteria to decide to perform retries in some cases without applying a backoff (eg, if a failure due to authentication requires to renew credentials, which makes sense to be done right away since we understand the reason for the failure), the calling this function lets this object keep the right context for the number of retries performed.
- Specified by:
noBackoff
in interfaceRetryBackoffContext
-
backoffMillis
public long backoffMillis()Description copied from interface:RetryBackoffContext
Return the time in milliseconds to wait to the next retry. It is assumed the caller will perform a retry after performing this way in some way, eg, callingThread.sleep(long)
.- Specified by:
backoffMillis
in interfaceRetryBackoffContext
- Returns:
- time in milliseconds to wait until the next retry.
-
elapsedMillis
public long elapsedMillis()Description copied from interface:RetryBackoffContext
Return the elapsed between the last time toRetryBackoffContext.deadlineExceeded()
and the last call toRetryBackoffContext.start(long)
.- Specified by:
elapsedMillis
in interfaceRetryBackoffContext
- Returns:
- elapsed time in milliseconds.
-
timeOfDeadlineMillis
public long timeOfDeadlineMillis()Description copied from interface:RetryBackoffContext
Returns the absolute epoch time in milliseconds for the deadline. Note this method only returns a valid deadline if start has already been called on this Context.- Specified by:
timeOfDeadlineMillis
in interfaceRetryBackoffContext
- Returns:
- epoch time of deadline in milliseconds.
-