java.lang.Object
net.i2p.router.Tuner.AutotuneConfig
- Enclosing class:
Tuner
Manages the autotune.config file — separate from
router.config.Stores tuner metadata (value, default, min, max, step) for each param, and is the only file the tuner persists to. Each param's applyValue() sets the runtime value in the live subsystem (streaming, transport, ...) and deliberately does not write router.config, so an auto-tuned value never outlives the tuning decision that produced it and never competes with an operator's router.config entry. The one deliberate router.config write is the one-time legacy cleanup in purgeOldTunerProps(), which deletes pre-autotune.config tuner.* keys and sets the migration marker.
Writes are throttled: values are marked dirty and flushed to disk at most once per 5 minutes (save()). Use forceSave() for unconditional writes (e.g. shutdown).
Field Summary
FieldsModifier and TypeFieldDescriptionprivate booleanTrue since a tuned value changed without a save.private final FileThe autotune.config file.private longTime of the last save of the tuned values.private final LogLogger for this class.private final PropertiesThe tuned values read from or written to the file.private static final StringFile the tuned values are saved to.private static final longShortest time between saves of the tuned values.Constructor Summary
ConstructorsConstructorDescriptionLoad the autotune config for the given context.Method Summary
Modifier and TypeMethodDescriptionvoidUnconditional write — used on shutdown and form saves.(package private) FilegetFile()Autotune config file.(package private) intRead an integer property value.(package private) StringgetProperty(String key) Read a property value.private voidload()Reads the saved tuned values from the file.voidsave()Write to disk only if dirty and ≥5min since last write.voidsetProperty(String key, String value) Property to set in the tuner config.private voidwrite()Writes the tuned values to the file.
Field Details
FILENAME
File the tuned values are saved to.- See Also:
SAVE_INTERVAL_MS
private static final long SAVE_INTERVAL_MSShortest time between saves of the tuned values.- See Also:
_file
The autotune.config file._props
The tuned values read from or written to the file._log
Logger for this class._dirty
private volatile boolean _dirtyTrue since a tuned value changed without a save._lastSaveMs
private volatile long _lastSaveMsTime of the last save of the tuned values.
Constructor Details
AutotuneConfig
Load the autotune config for the given context.- Parameters:
ctx- the router context
Method Details
load
private void load()Reads the saved tuned values from the file.save
public void save()Write to disk only if dirty and ≥5min since last write.forceSave
public void forceSave()Unconditional write — used on shutdown and form saves.write
private void write()Writes the tuned values to the file.getProperty
getInt
Read an integer property value.- Parameters:
key- property keydefaultVal- value to return when the key is unset or unparseable- Returns:
- the stored value as an int, or defaultVal
setProperty
getFile
File getFile()Autotune config file.- Returns:
- the backing file, which need not exist until the first save