Class TimeoutManager
- java.lang.Object
-
- org.hibernate.search.engine.search.timeout.spi.TimeoutManager
-
public class TimeoutManager extends Object
- Author:
- Emmanuel Bernard
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
TimeoutManager.Type
-
Field Summary
Fields Modifier and Type Field Description protected Long
timeoutMs
protected TimeUnit
timeoutUnit
protected Long
timeoutValue
protected TimingSource
timingSource
protected TimeoutManager.Type
type
-
Constructor Summary
Constructors Constructor Description TimeoutManager(TimingSource timingSource, Long timeoutValue, TimeUnit timeoutUnit, TimeoutManager.Type type)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
checkTimedOut()
Deadline
deadlineOrNull()
protected long
elapsedTimeEstimateMillis()
Deadline
hardDeadlineOrNull()
static TimeoutManager
hardTimeout(TimingSource timingSource, long timeout, TimeUnit timeUnit)
boolean
hasHardTimeout()
boolean
isTimedOut()
static TimeoutManager
noTimeout(TimingSource timingSource)
static TimeoutManager
of(TimingSource timingSource, Long timeout, TimeUnit timeUnit, boolean exceptionOnTimeout)
static TimeoutManager
softTimeout(TimingSource timingSource, long timeout, TimeUnit timeUnit)
void
start()
we start counting from this method call (if needed)void
stop()
long
timeoutBaseline()
TimingSource
timingSource()
Duration
tookTime()
Returns the time passed from the start with high precision.
-
-
-
Field Detail
-
timingSource
protected final TimingSource timingSource
-
timeoutValue
protected final Long timeoutValue
-
timeoutUnit
protected final TimeUnit timeoutUnit
-
timeoutMs
protected final Long timeoutMs
-
type
protected final TimeoutManager.Type type
-
-
Constructor Detail
-
TimeoutManager
public TimeoutManager(TimingSource timingSource, Long timeoutValue, TimeUnit timeoutUnit, TimeoutManager.Type type)
-
-
Method Detail
-
of
public static TimeoutManager of(TimingSource timingSource, Long timeout, TimeUnit timeUnit, boolean exceptionOnTimeout)
-
noTimeout
public static TimeoutManager noTimeout(TimingSource timingSource)
-
softTimeout
public static TimeoutManager softTimeout(TimingSource timingSource, long timeout, TimeUnit timeUnit)
-
hardTimeout
public static TimeoutManager hardTimeout(TimingSource timingSource, long timeout, TimeUnit timeUnit)
-
start
public void start()
we start counting from this method call (if needed)
-
stop
public void stop()
-
timingSource
public TimingSource timingSource()
-
deadlineOrNull
public Deadline deadlineOrNull()
- Returns:
- The deadline for the timeout defined by this timeout manager,
null
if no timeout is set.
-
hardDeadlineOrNull
public Deadline hardDeadlineOrNull()
- Returns:
- The hard deadline defined by this timeout manager,
i.e. the deadline beyond which an exception should be thrown.
null
if no hard timeout is set.
-
timeoutBaseline
public long timeoutBaseline()
-
isTimedOut
public boolean isTimedOut()
- Returns:
true
if the timeout was reached in a previous call tocheckTimedOut()
,false
otherwise.
-
checkTimedOut
public boolean checkTimedOut()
- Returns:
true
if the timeout was reached,false
otherwise.- Throws:
SearchTimeoutException
- If the timeout was reached and a hard timeout was requested.
-
hasHardTimeout
public boolean hasHardTimeout()
-
tookTime
public Duration tookTime()
Returns the time passed from the start with high precision. This method may be performance expensive.- Returns:
- high precision duration of took time.
-
elapsedTimeEstimateMillis
protected long elapsedTimeEstimateMillis()
-
-