java.lang.Object
net.i2p.util.SimpleTimer2.TimedEvent
net.i2p.router.web.DeadlockDetector
All Implemented Interfaces:
Runnable

public class DeadlockDetectorextends SimpleTimer2.TimedEvent
Periodic check ref: https://dzone.com/articles/how-detect-java-deadlocks

In routerconsole because java.lang.management is not available in Android.

  • Field Details

    • _context

      private final RouterContext _context
      The router being watched.
    • _log

      private final Log _log
      Logger for this class.
    • PROP_INTERVAL

      private static final String PROP_INTERVAL
      Property giving how many hours between deadlock checks.
      See Also:
    • DEFAULT_INTERVAL

      private static final long DEFAULT_INTERVAL
      Default hours between deadlock checks.
      See Also:
    • _isDeadlocked

      private static final AtomicBoolean _isDeadlocked
      True while a deadlock is believed to be held.
  • Constructor Details

    • DeadlockDetector

      public DeadlockDetector(RouterContext ctx)
      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:
      timeReached in class SimpleTimer2.TimedEvent
    • detect

      private boolean detect()
      Looks for a lock cycle among the router's threads.
      Returns:
      true if a deadlock was found
    • detect

      public static boolean detect(RouterContext ctx)
      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