java.lang.Object
net.i2p.util.SimpleTimer2.TimedEvent
net.i2p.router.transport.udp.PeerTestEvent
- All Implemented Interfaces:
Runnable
Initiate a test (we are Alice).
Field Summary
FieldsModifier and TypeFieldDescriptionprivate booleanWhether this event is active.private final RouterContextRouter context.private intForce run flags.private final AtomicLongWhen we last tested our reachability.private final AtomicLongWhen we last tested our IPv6 reachability.private booleanWhether the last test was IPv6.private final LogClass logger.private final PeerTestManagerPeer test manager.private final UDPTransportUDP transport.private static final intForce IPv4 test.private static final intForce IPv6 test.private static final intMust be greater than PeerTestManager.MAX_TEST_TIME.private static final intNo force run.private static final StringProperty to disable peer test.private static final intTest frequency in ms.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
ConstructorsConstructorDescriptionPeerTestEvent(RouterContext ctx, UDPTransport udp, PeerTestManager ptmgr) Peer test event.Method Summary
Modifier and TypeMethodDescriptionvoidforceRunImmediately(boolean isIPv6) Run within the next 5 seconds at the latest.voidforceRunSoon(boolean isIPv6) Run within the next 45 seconds at the latest.voidforceRunSoon(boolean isIPv6, long delay) Run within the specified time at the latest.private voidlocked_runTest(boolean isIPv6) Run a test with Bob.voidreschedule(long delay) Just to consolidate the logging.voidsetIsAlive(boolean isAlive) Caller MUST also call schedule(),reschedule(long),forceRunSoon(boolean), or forceRunImmediately().voidsetLastTested(boolean isIPv6) Set the last-tested timer to now.private booleanWhether we should run a test now.voidRun a reachability test if due, then reschedule.Methods inherited from class SimpleTimer2.TimedEvent
cancel, forceReschedule, 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, 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
Router context._log
Class logger._transport
UDP transport._testManager
Peer test manager._alive
private boolean _aliveWhether this event is active._lastTested
When we last tested our reachability._lastTestedV6
When we last tested our IPv6 reachability.NO_FORCE
FORCE_IPV4
FORCE_IPV6
_forceRun
private int _forceRunForce run flags._lastTestIPv6
private boolean _lastTestIPv6Whether the last test was IPv6.TEST_FREQUENCY
MIN_TEST_FREQUENCY
private static final int MIN_TEST_FREQUENCYMust be greater than PeerTestManager.MAX_TEST_TIME.- See Also:
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 onudp- the transport supplying Bob peer candidates and the configured firewalled stateptmgr- 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:
timeReachedin classSimpleTimer2.TimedEvent
reschedule
public void reschedule(long delay) Just to consolidate the logging.- Overrides:
reschedulein classSimpleTimer2.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 IPv4delay- 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