java.lang.Object
net.i2p.util.SimpleTimer2.TimedEvent
net.i2p.client.impl.SessionIdleTimer
- All Implemented Interfaces:
Runnable
Reduce tunnels or shutdown the session on idle if so configured.
Field Summary
Modifier and TypeFieldDescriptionprivate final I2PAppContextThe app context.private longWhen the session was last active.private final LogLogger for the session idle timer.private final longShortest interval between the timer runs.private final booleanTrue to reduce tunnels when the session idles.private final intTunnels to reduce by when the session idles.private final longIdle time before the tunnels are reduced.private final I2PSessionImplThe session watched for idleness.private final booleanTrue to close the session when it idles.private final longIdle time before the session is closed.private static final longDefault idle time before closing the session.private static final longDefault idle time before reducing tunnels.static final longLower bound on the configured reduce and shutdown times, in milliseconds.Fields inherited from class SimpleTimer2.TimedEvent
_state, DEFAULT_FUZZModifier and TypeFieldDescriptionprotected SimpleTimer2.TimedEventStateState of the current event.protected static final intDefault fuzz threshold in milliseconds.Constructor Summary
ConstructorsConstructorDescriptionSessionIdleTimer(I2PAppContext context, I2PSessionImpl session, boolean reduce, boolean shutdown) Construct a timer that reduces, shuts down, or both.Method Summary
All MethodsModifier and TypeMethodDescriptionvoidCheck session activity and reduce or destroy on idle.Methods inherited from class SimpleTimer2.TimedEvent
cancel, forceReschedule, reschedule, reschedule, run, schedule, setFuzz, setPool, toStringModifier and TypeMethodDescriptionbooleancancel()Cancel the timed event.voidforceReschedule(long timeoutMs) Always use the new time - ignores fuzz.voidreschedule(long timeoutMs) Use the earliest of the new time and the old time May be called from within timeReached(), but schedule() is better there.voidreschedule(long timeoutMs, boolean useEarliestTime) May be called from within timeReached(), but schedule() is better there.voidrun()voidschedule(long timeoutMs) Schedule this event.voidsetFuzz(int fuzz) Reschedule threshold in ms.voidsetPool(SimpleTimer2 pool) Timer pool for this event.toString()Timer summary for log messages.
Field Details
MINIMUM_TIME
public static final long MINIMUM_TIMELower bound on the configured reduce and shutdown times, in milliseconds.- See Also:
DEFAULT_REDUCE_TIME
private static final long DEFAULT_REDUCE_TIMEDefault idle time before reducing tunnels.- See Also:
DEFAULT_CLOSE_TIME
private static final long DEFAULT_CLOSE_TIMEDefault idle time before closing the session.- See Also:
_log
Logger for the session idle timer._context
The app context._session
The session watched for idleness._reduceEnabled
private final boolean _reduceEnabledTrue to reduce tunnels when the session idles._reduceQuantity
private final int _reduceQuantityTunnels to reduce by when the session idles._reduceTime
private final long _reduceTimeIdle time before the tunnels are reduced._shutdownEnabled
private final boolean _shutdownEnabledTrue to close the session when it idles._shutdownTime
private final long _shutdownTimeIdle time before the session is closed._minimumTime
private final long _minimumTimeShortest interval between the timer runs._lastActive
private long _lastActiveWhen the session was last active.
Constructor Details
SessionIdleTimer
public SessionIdleTimer(I2PAppContext context, I2PSessionImpl session, boolean reduce, boolean shutdown) Construct a timer that reduces, shuts down, or both.- Parameters:
context- the application context supplying the timer and the log managersession- the session whose i2cp options supply the idle thresholds and the reduction quantityreduce- if true, cut the session's tunnel quantity back after the idle timeshutdown- if true, close the session after the idle time
Method Details
timeReached
public void timeReached()Check session activity and reduce or destroy on idle.- Specified by:
timeReachedin classSimpleTimer2.TimedEvent