java.lang.Object
net.i2p.router.JobImpl
net.i2p.router.tasks.ReadConfigJob
- All Implemented Interfaces:
Job
Simply read the router config periodically, so that the user may make config changes externally. This isn't advertised as a feature, but it could be used, for example, to change bandwidth limits at certain times of day.
Unfortunately it will also read the file back in every time the router writes it.
We must keep this enabled, as it's the only way for people to set routerconsole.advanced=true without restarting.
Field Summary
FieldsModifier and TypeFieldDescriptionprivate longWhen the config file was last read, in ms.private static final longHow often the config is reread - every minute.private static final StringProperty the advanced settings live under.Constructor Summary
ConstructorsMethod Summary
Modifier and TypeMethodDescriptiongetName()Name of this job.booleanCheck if advanced console mode is enabled.voidrunJob()Check for and reload router configuration if file has changed.private booleanshouldReread(File configFile) Checks whether the config file changed since the last read.Methods inherited from class JobImpl
dropped, getContext, getJobId, getMadeReadyOn, getTiming, madeReady, requeue, toStringModifier and TypeMethodDescriptionvoiddropped()Default implementation does nothing.final RouterContextThe router context that this job belongs to.longgetJobId()The unique job ID for this job.longThe timestamp when this job was last made ready for execution.The timing object for this job.voidmadeReady(long now) For JobQueue only, not for external use.protected voidrequeue(long delayMs) Requeue this job to run after the specified delay.toString()
Field Details
DELAY
private static final long DELAYHow often the config is reread - every minute.- See Also:
_lastRead
private volatile long _lastReadWhen the config file was last read, in ms.PROP_ADVANCED
Property the advanced settings live under.- See Also:
Constructor Details
ReadConfigJob
Create a new configuration reader job.- Parameters:
ctx- router context for accessing configuration and clock
Method Details
isAdvanced
public boolean isAdvanced()Check if advanced console mode is enabled.- Returns:
- true if
routerconsole.advancedproperty is true
getName
runJob
public void runJob()Check for and reload router configuration if file has changed.This job runs periodically to detect external configuration changes. If the
router.configfile has been modified since last check, it will be reloaded and the last read timestamp updated.The check interval varies based on console mode:
- Normal mode: every 60 seconds
- Advanced mode: every 90 seconds
Note: This will also trigger when the router itself writes the config file, but that's acceptable behavior.
shouldReread
Checks whether the config file changed since the last read.- Parameters:
configFile- the config file to check- Returns:
- true if it is newer than the last read