java.lang.Object
net.i2p.i2ptunnel.streamr.Pinger
All Implemented Interfaces:
Runnable, Source

public class Pingerextends Object implements Source, Runnable
Connectivity tester that pings streamr destinations at regular intervals to monitor network status.
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    private final int
    UDP port the pings are sent from.
    private final Log
    Logger for this class.
    protected boolean
    True while the ping loop should keep running.
    protected Sink
    The destination that carries the ping messages.
    protected final Thread
    The thread running the ping loop.
    private final Object
    Held while waiting for the next ping.
  • Constructor Summary

    Constructors
    Constructor
    Description
    Pinger(I2PAppContext ctx, int fromPort)
    Creates a pinger for the given I2CP from port.
  • Method Summary

    All Methods
    Modifier and Type
    Method
    Description
    void
    run()
    Main run loop that periodically sends subscribe messages.
    void
    setSink(Sink sink)
    Sets the destination sink for ping messages.
    void
    Starts the pinger thread to send periodic subscribe messages.
    void
    Stops the pinger thread and sends an unsubscribe message.

    Methods inherited from class Object

    clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • sink

      protected Sink sink
      The destination that carries the ping messages.
    • thread

      protected final Thread thread
      The thread running the ping loop.
    • waitlock

      private final Object waitlock
      Held while waiting for the next ping.
    • running

      protected volatile boolean running
      True while the ping loop should keep running.
    • log

      private final Log log
      Logger for this class.
    • fromPort

      private final int fromPort
      UDP port the pings are sent from.
  • Constructor Details

    • Pinger

      public Pinger(I2PAppContext ctx, int fromPort)
      Creates a pinger for the given I2CP from port.
      Parameters:
      ctx - the application context supplying the router log manager
      fromPort - the I2CP from port
  • Method Details

    • setSink

      public void setSink(Sink sink)
      Sets the destination sink for ping messages.
      Specified by:
      setSink in interface Source
      Parameters:
      sink - the sink to receive ping messages
    • start

      public void start()
      Starts the pinger thread to send periodic subscribe messages.
      Specified by:
      start in interface Source
    • stop

      public void stop()
      Stops the pinger thread and sends an unsubscribe message.
    • run

      public void run()
      Main run loop that periodically sends subscribe messages. Runs until stop() is called.
      Specified by:
      run in interface Runnable