java.lang.Object
net.i2p.router.networkdb.reseed.ReseedChecker

public class ReseedCheckerextends Object
Checks whether reseeding of the network database is necessary and initiates reseed requests. This class manages reseed triggers based on network status, router uptime/downtime, peer count, and configuration flags.

All reseeding must be done through this instance. Access through context.netDb().reseedChecker(), others should not instantiate this class directly.

  • Nested Class Summary

    Nested Classes
    Modifier and Type
    Class
    Description
    private class 
    Timer event to clear stale status and error messages after a timeout.
  • Field Summary

    Modifier and Type
    Field
    Description
    private boolean
    True once the startup check ran.
    private final RouterContext
    The router context.
    private final AtomicBoolean
    True while a check runs.
    private String
    The error message of the last check.
    private String
    The status message of the last check.
    private final Log
    The log for the checker.
    private boolean
    True once the network error was logged.
    static final int
    Minimum number of router infos before automatic reseed attempted.
    private static final long
    Downtime threshold for forced reseed at startup (7 days).
    private static final long
    Sidebar notification persistence (3 minutes).
  • Constructor Summary

    Constructors
    Constructor
    Description
    Opens a log for this router's reseed checker.
  • Method Summary

    Modifier and Type
    Method
    Description
    private boolean
    Checks for network connection and reseed disable config files.
    boolean
    checkReseed(int known)
    Checks if a reseed is needed based on peers, uptime, downtime, and system flags.
    (package private) void
    Marks reseed complete, resetting internal state and scheduling status clearance.
    Error message from the last or current reseed attempt.
    Status message from the current reseed attempt.
    boolean
    Checks whether a reseed is currently in progress.
    private void
    logOnceWarning(int peers, String reason)
    Logs a warning message once for reseed prevention reason based on peer count.
    boolean
    Starts a reseed if one is not already in progress.
    int
    Performs a blocking reseed from a zip or su3 InputStream.
    boolean
    Starts a reseed from a zip or su3 URI if one is not already in progress.
    (package private) void
    Error message for the last or current reseed attempt.
    (package private) void
    Status message for the current reseed attempt.

    Methods inherited from class Object

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

    • _context

      private final RouterContext _context
      The router context.
    • _log

      private final Log _log
      The log for the checker.
    • _inProgress

      private final AtomicBoolean _inProgress
      True while a check runs.
    • _lastStatus

      private volatile String _lastStatus
      The status message of the last check.
    • _lastError

      private volatile String _lastError
      The error message of the last check.
    • _networkLogged

      private volatile boolean _networkLogged
      True once the network error was logged.
    • _alreadyRun

      private volatile boolean _alreadyRun
      True once the startup check ran.
    • MINIMUM

      public static final int MINIMUM
      Minimum number of router infos before automatic reseed attempted.
      See Also:
    • STATUS_CLEAN_TIME

      private static final long STATUS_CLEAN_TIME
      Sidebar notification persistence (3 minutes).
      See Also:
    • RESEED_MIN_DOWNTIME

      private static final long RESEED_MIN_DOWNTIME
      Downtime threshold for forced reseed at startup (7 days).
      See Also:
  • Constructor Details

    • ReseedChecker

      public ReseedChecker(RouterContext context)
      Opens a log for this router's reseed checker.
      Parameters:
      context - the router context
  • Method Details

    • checkReseed

      public boolean checkReseed(int known)
      Checks if a reseed is needed based on peers, uptime, downtime, and system flags. Starts reseed if conditions are met.
      Parameters:
      known - current number of known routers (includes this router)
      Returns:
      true if reseed started; false otherwise
    • logOnceWarning

      private void logOnceWarning(int peers, String reason)
      Logs a warning message once for reseed prevention reason based on peer count.
      Parameters:
      peers - number of known peers excluding this router
      reason - reason why reseed is disabled or prevented
    • _hasNetworkConnection

      private boolean _hasNetworkConnection()
      Checks for network connection and reseed disable config files.
      Returns:
      true if network is connected and no config disables reseed; false otherwise
    • requestReseed

      public boolean requestReseed()
      Starts a reseed if one is not already in progress.
      Returns:
      true if reseed was started; false if already in progress or failed to start
    • requestReseed

      public boolean requestReseed(URI url) throws IllegalArgumentException
      Starts a reseed from a zip or su3 URI if one is not already in progress.
      Parameters:
      url - URI to the reseed data file (zip/su3)
      Returns:
      true if reseed was started; false if already in progress or failed to start
      Throws:
      IllegalArgumentException - if URI is invalid or unsupported format
    • requestReseed

      public int requestReseed(InputStream in) throws IOException
      Performs a blocking reseed from a zip or su3 InputStream.
      Parameters:
      in - InputStream of reseed data
      Returns:
      number of routers imported
      Throws:
      IOException - if reseed is already in progress or an IO error occurs
    • inProgress

      public boolean inProgress()
      Checks whether a reseed is currently in progress.
      Returns:
      true if reseed in progress; false otherwise
    • done

      void done()
      Marks reseed complete, resetting internal state and scheduling status clearance.
    • getStatus

      public String getStatus()
      Status message from the current reseed attempt.
      Returns:
      status message (may contain HTML), never null
    • setStatus

      void setStatus(String s)
      Status message for the current reseed attempt.
      Parameters:
      s - status message, non-null but may be empty
    • getError

      public String getError()
      Error message from the last or current reseed attempt.
      Returns:
      error message (may contain HTML), never null
    • setError

      void setError(String s)
      Error message for the last or current reseed attempt.
      Parameters:
      s - error message, non-null but may be empty