java.lang.Object
net.i2p.router.networkdb.reseed.ReseedChecker
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 ClassesModifier and TypeClassDescriptionprivate classTimer event to clear stale status and error messages after a timeout.Field Summary
Modifier and TypeFieldDescriptionprivate booleanTrue once the startup check ran.private final RouterContextThe router context.private final AtomicBooleanTrue while a check runs.private StringThe error message of the last check.private StringThe status message of the last check.private final LogThe log for the checker.private booleanTrue once the network error was logged.static final intMinimum number of router infos before automatic reseed attempted.private static final longDowntime threshold for forced reseed at startup (7 days).private static final longSidebar notification persistence (3 minutes).Constructor Summary
ConstructorsConstructorDescriptionReseedChecker(RouterContext context) Opens a log for this router's reseed checker.Method Summary
Modifier and TypeMethodDescriptionprivate booleanChecks for network connection and reseed disable config files.booleancheckReseed(int known) Checks if a reseed is needed based on peers, uptime, downtime, and system flags.(package private) voiddone()Marks reseed complete, resetting internal state and scheduling status clearance.getError()Error message from the last or current reseed attempt.Status message from the current reseed attempt.booleanChecks whether a reseed is currently in progress.private voidlogOnceWarning(int peers, String reason) Logs a warning message once for reseed prevention reason based on peer count.booleanStarts a reseed if one is not already in progress.intPerforms a blocking reseed from a zip or su3 InputStream.booleanrequestReseed(URI url) Starts a reseed from a zip or su3 URI if one is not already in progress.(package private) voidError message for the last or current reseed attempt.(package private) voidStatus message for the current reseed attempt.
Field Details
_context
The router context._log
The log for the checker._inProgress
True while a check runs._lastStatus
The status message of the last check._lastError
The error message of the last check._networkLogged
private volatile boolean _networkLoggedTrue once the network error was logged._alreadyRun
private volatile boolean _alreadyRunTrue once the startup check ran.MINIMUM
public static final int MINIMUMMinimum number of router infos before automatic reseed attempted.- See Also:
STATUS_CLEAN_TIME
private static final long STATUS_CLEAN_TIMESidebar notification persistence (3 minutes).- See Also:
RESEED_MIN_DOWNTIME
private static final long RESEED_MIN_DOWNTIMEDowntime threshold for forced reseed at startup (7 days).- See Also:
Constructor Details
ReseedChecker
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
Logs a warning message once for reseed prevention reason based on peer count.- Parameters:
peers- number of known peers excluding this routerreason- 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
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
Performs a blocking reseed from a zip or su3 InputStream.- Parameters:
in-InputStreamof 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
Status message from the current reseed attempt.- Returns:
- status message (may contain HTML), never null
setStatus
Status message for the current reseed attempt.- Parameters:
s- status message, non-null but may be empty
getError
Error message from the last or current reseed attempt.- Returns:
- error message (may contain HTML), never null
setError
Error message for the last or current reseed attempt.- Parameters:
s- error message, non-null but may be empty