Package org.eclipse.jetty.io
Class IdleTimeout
- java.lang.Object
-
- org.eclipse.jetty.io.IdleTimeout
-
- Direct Known Subclasses:
AbstractEndPoint
,HttpChannelOverFCGI.FCGIIdleTimeout
public abstract class IdleTimeout extends java.lang.Object
An Abstract implementation of an Idle Timeout.This implementation is optimised that timeout operations are not cancelled on every operation. Rather timeout are allowed to expire and a check is then made to see when the last operation took place. If the idle timeout has not expired, the timeout is rescheduled for the earliest possible time a timeout could occur.
-
-
Field Summary
Fields Modifier and Type Field Description private long
_idleTimeout
private long
_idleTimestamp
private Scheduler
_scheduler
private java.util.concurrent.atomic.AtomicReference<Scheduler.Task>
_timeout
private static Logger
LOG
-
Constructor Summary
Constructors Constructor Description IdleTimeout(Scheduler scheduler)
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description private void
activate()
protected long
checkIdleTimeout()
private void
deactivate()
long
getIdleFor()
long
getIdleTimeout()
Scheduler
getScheduler()
private void
idleCheck()
abstract boolean
isOpen()
This abstract method should be called to check if idle timeouts should still be checked.void
notIdle()
This method should be called when non-idle activity has taken place.void
onClose()
protected abstract void
onIdleExpired(java.util.concurrent.TimeoutException timeout)
This abstract method is called when the idle timeout has expired.void
onOpen()
private void
scheduleIdleTimeout(long delay)
void
setIdleTimeout(long idleTimeout)
Sets the idle timeout in milliseconds.
-
-
-
Field Detail
-
LOG
private static final Logger LOG
-
_scheduler
private final Scheduler _scheduler
-
_timeout
private final java.util.concurrent.atomic.AtomicReference<Scheduler.Task> _timeout
-
_idleTimeout
private volatile long _idleTimeout
-
_idleTimestamp
private volatile long _idleTimestamp
-
-
Constructor Detail
-
IdleTimeout
public IdleTimeout(Scheduler scheduler)
- Parameters:
scheduler
- A scheduler used to schedule checks for the idle timeout.
-
-
Method Detail
-
getScheduler
public Scheduler getScheduler()
-
getIdleFor
public long getIdleFor()
- Returns:
- the period of time, in milliseconds, that this object was idle
-
getIdleTimeout
public long getIdleTimeout()
- Returns:
- the idle timeout in milliseconds
- See Also:
setIdleTimeout(long)
-
setIdleTimeout
public void setIdleTimeout(long idleTimeout)
Sets the idle timeout in milliseconds.
A value that is less than or zero disables the idle timeout checks.
- Parameters:
idleTimeout
- the idle timeout in milliseconds- See Also:
getIdleTimeout()
-
notIdle
public void notIdle()
This method should be called when non-idle activity has taken place.
-
idleCheck
private void idleCheck()
-
scheduleIdleTimeout
private void scheduleIdleTimeout(long delay)
-
onOpen
public void onOpen()
-
activate
private void activate()
-
onClose
public void onClose()
-
deactivate
private void deactivate()
-
checkIdleTimeout
protected long checkIdleTimeout()
-
onIdleExpired
protected abstract void onIdleExpired(java.util.concurrent.TimeoutException timeout)
This abstract method is called when the idle timeout has expired.- Parameters:
timeout
- a TimeoutException
-
isOpen
public abstract boolean isOpen()
This abstract method should be called to check if idle timeouts should still be checked.- Returns:
- True if the entity monitored should still be checked for idle timeouts
-
-