Interface Deadline
-
public interface DeadlineCommon interface providing a deadline through the methodremainingTimeMillis().
-
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Modifier and Type Method Description voidforceTimeout(Exception cause)SearchTimeoutExceptionforceTimeoutAndCreateException(Exception cause)static DeadlineofMilliseconds(long milliseconds)longremainingTimeMillis()
-
-
-
Method Detail
-
remainingTimeMillis
long remainingTimeMillis()
- Returns:
- The remaining time to the deadline in milliseconds.
- Throws:
SearchTimeoutException- If the deadline was reached and it's a hard deadline requiring immediate failure.
-
forceTimeout
void forceTimeout(Exception cause)
- Parameters:
cause- The cause of the timeout, ornull.- Throws:
SearchTimeoutException- If the deadline is a hard deadline requiring immediate failure.
-
forceTimeoutAndCreateException
SearchTimeoutException forceTimeoutAndCreateException(Exception cause)
- Parameters:
cause- The cause of the timeout, ornull.- Returns:
- An exception to be thrown on timeout.
-
ofMilliseconds
static Deadline ofMilliseconds(long milliseconds)
- Parameters:
milliseconds- The number of milliseconds until the deadline.- Returns:
- An immutable
Deadlinewhich does not track the passing time.remainingTimeMillis()will always return the same value and will never throw an exception.
-
-