net.i2p.router.networkdb.reseed

## Class ReseedChecker

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

-     public class ReseedChecker
      extends 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.

- - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `static int` | `MINIMUM` Minimum number of router infos before automatic reseed attempted

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `ReseedChecker(RouterContext context)` Constructor.

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `boolean` | `checkReseed(int known)` Checks if a reseed is needed based on peers, uptime, downtime, and system flags.
    `(package private) void` | `done()` Marks reseed complete, resetting internal state and scheduling status clearance.
    `String` | `getError()` Gets the error message from the last or current reseed attempt.
    `String` | `getStatus()` Gets the status message from the current reseed attempt.
    `boolean` | `inProgress()` Checks whether a reseed is currently in progress.
    `boolean` | `requestReseed()` Starts a reseed if one is not already in progress.
    `int` | `requestReseed(InputStream in)` Performs a blocking reseed from a zip or su3 InputStream.
    `boolean` | `requestReseed(URI url)` Starts a reseed from a zip or su3 URI if one is not already in progress.
    `(package private) void` | `setError(String s)` Sets the error message for the last or current reseed attempt.
    `(package private) void` | `setStatus(String s)` Sets the status message for the current reseed attempt.

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Field Detail

    - #### MINIMUM

          public static final int MINIMUM

      Minimum number of router infos before automatic reseed attempted
      See Also:
        Constant Field Values

  - ### Constructor Detail

    - #### ReseedChecker

          public ReseedChecker(RouterContext context)

      Constructor.
      Parameters:
        `context` - the router context

  - ### Method Detail

    - #### 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

    - #### done

          void done()

      Marks reseed complete, resetting internal state and scheduling status clearance.

    - #### getError

          public String getError()

      Gets the error message from the last or current reseed attempt.
      Returns:
        error message (may contain HTML), never null

    - #### getStatus

          public String getStatus()

      Gets the status message from the current reseed attempt.
      Returns:
        status message (may contain HTML), never null

    - #### inProgress

          public boolean inProgress()

      Checks whether a reseed is currently in progress.
      Returns:
        true if reseed in progress; 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 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

    - #### 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

    - #### setError

          void setError(String s)

      Sets the error message for the last or current reseed attempt.
      Parameters:
        `s` - error message, non-null but may be empty

    - #### setStatus

          void setStatus(String s)

      Sets the status message for the current reseed attempt.
      Parameters:
        `s` - status message, non-null but may be empty