java.lang.Object
net.i2p.util.SimpleTimer2.TimedEvent
net.i2p.router.web.DeadlockDetector
- All Implemented Interfaces:
Runnable
Periodic check ref: https://dzone.com/articles/how-detect-java-deadlocks
In routerconsole because java.lang.management is not available in Android.
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final RouterContextThe router being watched.private static final AtomicBooleanTrue while a deadlock is believed to be held.private final LogLogger for this class.private static final longDefault hours between deadlock checks.private static final StringProperty giving how many hours between deadlock checks.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
ConstructorsConstructorDescriptionStart the periodic deadlock poll, scheduled only when enabled.Method Summary
Modifier and TypeMethodDescriptionprivate booleandetect()Looks for a lock cycle among the router's threads.static booleandetect(RouterContext ctx) Check this detector's router context for deadlocked threads.private longReads the check interval from the config.static booleanReturn the results of the last test.voidPoll for deadlocks, rescheduling only when none were found.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
_context
The router being watched._log
Logger for this class.PROP_INTERVAL
Property giving how many hours between deadlock checks.- See Also:
DEFAULT_INTERVAL
private static final long DEFAULT_INTERVALDefault hours between deadlock checks.- See Also:
_isDeadlocked
True while a deadlock is believed to be held.
Constructor Details
DeadlockDetector
Start the periodic deadlock poll, scheduled only when enabled.- Parameters:
ctx- the router context to poll and to report deadlocks in
Method Details
getInterval
private long getInterval()Reads the check interval from the config.- Returns:
- the interval, in hours
timeReached
public void timeReached()Poll for deadlocks, rescheduling only when none were found.- Specified by:
timeReachedin classSimpleTimer2.TimedEvent
detect
private boolean detect()Looks for a lock cycle among the router's threads.- Returns:
- true if a deadlock was found
detect
Check this detector's router context for deadlocked threads.- Parameters:
ctx- the router context to poll and to report deadlocks in- Returns:
- true if a deadlock is found, false if none or if the check failed
isDeadlocked
public static boolean isDeadlocked()Return the results of the last test. Does not run a new test.- Returns:
- the last recorded result, false before any test has run