java.lang.Object
net.i2p.util.SimpleTimer2.TimedEvent
net.i2p.router.transport.udp.PeerTestEvent
All Implemented Interfaces:
Runnable

class PeerTestEventextends SimpleTimer2.TimedEvent
Initiate a test (we are Alice).
  • Field Details

    • _context

      private final RouterContext _context
      Router context.
    • _log

      private final Log _log
      Class logger.
    • _transport

      private final UDPTransport _transport
      UDP transport.
    • _testManager

      private final PeerTestManager _testManager
      Peer test manager.
    • _alive

      private boolean _alive
      Whether this event is active.
    • _lastTested

      private final AtomicLong _lastTested
      When we last tested our reachability.
    • _lastTestedV6

      private final AtomicLong _lastTestedV6
      When we last tested our IPv6 reachability.
    • NO_FORCE

      private static final int NO_FORCE
      No force run.
      See Also:
    • FORCE_IPV4

      private static final int FORCE_IPV4
      Force IPv4 test.
      See Also:
    • FORCE_IPV6

      private static final int FORCE_IPV6
      Force IPv6 test.
      See Also:
    • _forceRun

      private int _forceRun
      Force run flags.
    • _lastTestIPv6

      private boolean _lastTestIPv6
      Whether the last test was IPv6.
    • TEST_FREQUENCY

      private static final int TEST_FREQUENCY
      Test frequency in ms.
      See Also:
    • MIN_TEST_FREQUENCY

      private static final int MIN_TEST_FREQUENCY
      Must be greater than PeerTestManager.MAX_TEST_TIME.
      See Also:
    • PROP_DISABLE_PEER_TEST

      private static final String PROP_DISABLE_PEER_TEST
      Property to disable peer test.
      See Also:
  • Constructor Details

    • PeerTestEvent

      PeerTestEvent(RouterContext ctx, UDPTransport udp, PeerTestManager ptmgr)
      Peer test event.
      Parameters:
      ctx - the router context supplying the clock and the timer this event is scheduled on
      udp - the transport supplying Bob peer candidates and the configured firewalled state
      ptmgr - the manager that runs the reachability test against the chosen peer
  • Method Details

    • timeReached

      public void timeReached()
      Run a reachability test if due, then reschedule.
      Specified by:
      timeReached in class SimpleTimer2.TimedEvent
    • reschedule

      public void reschedule(long delay)
      Just to consolidate the logging.
      Overrides:
      reschedule in class SimpleTimer2.TimedEvent
      Parameters:
      delay - timeout in milliseconds
    • locked_runTest

      private void locked_runTest(boolean isIPv6)
      Run a test with Bob.
      Parameters:
      isIPv6 - true for IPv6
    • forceRunSoon

      public void forceRunSoon(boolean isIPv6)
      Run within the next 45 seconds at the latest.
      Parameters:
      isIPv6 - true to test IPv6 reachability, false to test IPv4
    • forceRunSoon

      public void forceRunSoon(boolean isIPv6, long delay)
      Run within the specified time at the latest.
      Parameters:
      isIPv6 - true to test IPv6 reachability, false to test IPv4
      delay - milliseconds to wait before the test runs, at most MIN_TEST_FREQUENCY
    • forceRunImmediately

      public void forceRunImmediately(boolean isIPv6)
      Run within the next 5 seconds at the latest.
      Parameters:
      isIPv6 - true to test IPv6 reachability, false to test IPv4
    • setIsAlive

      public void setIsAlive(boolean isAlive)
      Caller MUST also call schedule(), reschedule(long), forceRunSoon(boolean), or forceRunImmediately().
      Parameters:
      isAlive - true keeps the event scheduled for later tests, false cancels it
    • setLastTested

      public void setLastTested(boolean isIPv6)
      Set the last-tested timer to now.
      Parameters:
      isIPv6 - true stamps the IPv6 timer, false stamps the IPv4 timer
    • shouldTest

      private boolean shouldTest()
      Whether we should run a test now.
      Returns:
      true if we should test