java.lang.Object
net.i2p.router.Tuner.AutotuneConfig
Enclosing class:
Tuner

public static class Tuner.AutotuneConfigextends Object
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

    Fields
    Modifier and Type
    Field
    Description
    private boolean
    True since a tuned value changed without a save.
    private final File
    The autotune.config file.
    private long
    Time of the last save of the tuned values.
    private final Log
    Logger for this class.
    private final Properties
    The tuned values read from or written to the file.
    private static final String
    File the tuned values are saved to.
    private static final long
    Shortest time between saves of the tuned values.
  • Constructor Summary

    Constructors
    Constructor
    Description
    Load the autotune config for the given context.
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    Unconditional write — used on shutdown and form saves.
    (package private) File
    Autotune config file.
    (package private) int
    getInt(String key, int defaultVal)
    Read an integer property value.
    (package private) String
    Read a property value.
    private void
    Reads the saved tuned values from the file.
    void
    Write to disk only if dirty and ≥5min since last write.
    void
    setProperty(String key, String value)
    Property to set in the tuner config.
    private void
    Writes the tuned values to the file.

    Methods inherited from class Object

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

    • FILENAME

      private static final String FILENAME
      File the tuned values are saved to.
      See Also:
    • SAVE_INTERVAL_MS

      private static final long SAVE_INTERVAL_MS
      Shortest time between saves of the tuned values.
      See Also:
    • _file

      private final File _file
      The autotune.config file.
    • _props

      private final Properties _props
      The tuned values read from or written to the file.
    • _log

      private final Log _log
      Logger for this class.
    • _dirty

      private volatile boolean _dirty
      True since a tuned value changed without a save.
    • _lastSaveMs

      private volatile long _lastSaveMs
      Time of the last save of the tuned values.
  • Constructor Details

    • AutotuneConfig

      public AutotuneConfig(RouterContext ctx)
      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

      String getProperty(String key)
      Read a property value.
      Parameters:
      key - property key
      Returns:
      the stored value, or null if the key is unset
    • getInt

      int getInt(String key, int defaultVal)
      Read an integer property value.
      Parameters:
      key - property key
      defaultVal - value to return when the key is unset or unparseable
      Returns:
      the stored value as an int, or defaultVal
    • setProperty

      public void setProperty(String key, String value)
      Property to set in the tuner config.
      Parameters:
      key - the property key
      value - the property value
    • getFile

      File getFile()
      Autotune config file.
      Returns:
      the backing file, which need not exist until the first save