Class TimerUtils
java.lang.Object
software.amazon.awssdk.core.internal.http.timers.TimerUtils
-
Method Summary
Modifier and TypeMethodDescriptionstatic long
resolveTimeoutInMillis
(Supplier<Optional<Duration>> supplier, Duration fallback) static <T> TimeoutTracker
timeAsyncTaskIfNeeded
(CompletableFuture<T> completableFuture, ScheduledExecutorService timeoutExecutor, Supplier<SdkClientException> exceptionSupplier, long timeoutInMills) Schedule aTimeoutTask
and exceptional completes aCompletableFuture
with the provide exception if not otherwise completed before the given timeout.static TimeoutTracker
timeSyncTaskIfNeeded
(ScheduledExecutorService timeoutExecutor, long timeoutInMills, Thread threadToInterrupt) Schedule aTimeoutTask
that aborts the task if not otherwise completed before the given timeout.
-
Method Details
-
timeAsyncTaskIfNeeded
public static <T> TimeoutTracker timeAsyncTaskIfNeeded(CompletableFuture<T> completableFuture, ScheduledExecutorService timeoutExecutor, Supplier<SdkClientException> exceptionSupplier, long timeoutInMills) Schedule aTimeoutTask
and exceptional completes aCompletableFuture
with the provide exception if not otherwise completed before the given timeout.- Type Parameters:
T
- the type of theCompletableFuture
- Parameters:
completableFuture
- the completableFuture to be timedtimeoutExecutor
- the executor to execute theTimeoutTask
exceptionSupplier
- the exception to thrown after timeouttimeoutInMills
- the timeout in milliseconds.- Returns:
- a
TimeoutTracker
-
timeSyncTaskIfNeeded
public static TimeoutTracker timeSyncTaskIfNeeded(ScheduledExecutorService timeoutExecutor, long timeoutInMills, Thread threadToInterrupt) Schedule aTimeoutTask
that aborts the task if not otherwise completed before the given timeout.- Parameters:
timeoutExecutor
- the executor to execute theTimeoutTask
timeoutInMills
- the timeout in milliseconds.threadToInterrupt
- the thread to interrupt- Returns:
- a
TimeoutTracker
-
resolveTimeoutInMillis
-