Top Description Fields Constructors Methods
org.eclipse.jetty.io

public abstract Class IdleTimeout

extends Object
Class Inheritance
Known Direct Subclasses
org.eclipse.jetty.io.AbstractEndPoint
Imports
java.util.concurrent.TimeUnit, .TimeoutException, java.util.concurrent.atomic.AtomicReference, org.eclipse.jetty.util.NanoTime, org.eclipse.jetty.util.thread.Scheduler, org.slf4j.Logger, .LoggerFactory

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

Modifier and TypeField and Description
private volatile long
private volatile long
private final Scheduler
private final AtomicReference<Scheduler.Task>
private static final Logger

Constructor Summary

AccessConstructor and Description
public
IdleTimeout(Scheduler
A scheduler used to schedule checks for the idle timeout.
scheduler
)

Method Summary

Modifier and TypeMethod and Description
private void
protected long
private void
public long

Returns:

the period of time, in milliseconds, that this object was idle
getIdleFor
()

Get the period of time, in milliseconds, that this object was idle.

public long

Returns:

the idle timeout in milliseconds
getIdleTimeout
()

public Scheduler
private void
public abstract boolean

Returns:

True if the entity monitored should still be checked for idle timeouts
isOpen
()

This abstract method should be called to check if idle timeouts should still be checked.

public void
notIdle()

This method should be called when non-idle activity has taken place.

public void
protected abstract void
onIdleExpired(TimeoutException
a TimeoutException
timeout
)

This abstract method is called when the idle timeout has expired.

public void
private void
scheduleIdleTimeout(long delay)

public void
setIdleTimeout(long
the idle timeout in milliseconds
idleTimeout
)

Sets the idle timeout in milliseconds.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

_idleNanoTimeback to summary
private volatile long _idleNanoTime
_idleTimeoutback to summary
private volatile long _idleTimeout
_schedulerback to summary
private final Scheduler _scheduler
_timeoutback to summary
private final AtomicReference<Scheduler.Task> _timeout
LOGback to summary
private static final Logger LOG

Constructor Detail

IdleTimeoutback to summary
public IdleTimeout(Scheduler scheduler)
Parameters
scheduler:Scheduler

A scheduler used to schedule checks for the idle timeout.

Method Detail

activateback to summary
private void activate()
checkIdleTimeoutback to summary
protected long checkIdleTimeout()
deactivateback to summary
private void deactivate()
getIdleForback to summary
public long getIdleFor()

Get the period of time, in milliseconds, that this object was idle.

Returns:long

the period of time, in milliseconds, that this object was idle

getIdleTimeoutback to summary
public long getIdleTimeout()
Returns:long

the idle timeout in milliseconds

See Also
setIdleTimeout(long)
getSchedulerback to summary
public Scheduler getScheduler()
idleCheckback to summary
private void idleCheck()
isOpenback to summary
public abstract boolean isOpen()

This abstract method should be called to check if idle timeouts should still be checked.

Returns:boolean

True if the entity monitored should still be checked for idle timeouts

notIdleback to summary
public void notIdle()

This method should be called when non-idle activity has taken place.

onCloseback to summary
public void onClose()
onIdleExpiredback to summary
protected abstract void onIdleExpired(TimeoutException timeout)

This abstract method is called when the idle timeout has expired.

Parameters
timeout:TimeoutException

a TimeoutException

onOpenback to summary
public void onOpen()
scheduleIdleTimeoutback to summary
private void scheduleIdleTimeout(long delay)
setIdleTimeoutback to summary
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:long

the idle timeout in milliseconds

See Also
getIdleTimeout()