net.i2p.router.tasks

## Class PersistRouterInfoJob

- java.lang.Object
- - net.i2p.router.JobImpl
  - - net.i2p.router.tasks.PersistRouterInfoJob

- All Implemented Interfaces:
    Job

      public class PersistRouterInfoJob
      extends JobImpl

  Router information persistence and synchronization job. This job is responsible for persisting the router's RouterInfo to disk whenever it changes. The RouterInfo contains critical router identity, capabilities, addresses, and statistics that must be preserved across restarts and shared with the network. RouterInfo Contents:
  - Router identity (public keys, certificates)
  - Network addresses and transport endpoints
  - Router capabilities and supported versions
  - Performance statistics and bandwidth limits
  - Current router status and options
  Persistence Process:
  - Retrieves current RouterInfo from router
  - Writes to router.info file in router directory
  - Uses synchronized access to prevent corruption
  - Employs atomic file writing for safety
  - Handles errors gracefully with detailed logging
  File Safety:
  - Uses SecureFileOutputStream for atomic writes
  - Synchronized on routerInfoFileLock for thread safety
  - Prevents partial writes and corruption
  - Ensures consistent state across restarts
  This job is triggered automatically whenever RouterInfo is updated due to address changes, capability changes, or periodic refreshes. The persisted file is used for router startup and network database publication.

- - ### Field Summary

    - ### Fields inherited from class net.i2p.router.JobImpl

      `_id`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `PersistRouterInfoJob(RouterContext ctx)` Create a new router info persistence job.

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `String` | `getName()` Get the name of this job.
    `void` | `runJob()` Save the current router information to disk.

    - ### Methods inherited from class net.i2p.router.JobImpl

      `dropped, getContext, getJobId, getMadeReadyOn, getTiming, madeReady, requeue, toString`

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

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

- - ### Constructor Detail

    - #### PersistRouterInfoJob

          public PersistRouterInfoJob(RouterContext ctx)

      Create a new router info persistence job.
      Parameters:
        `ctx` - router context for accessing router services

  - ### Method Detail

    - #### getName

          public String getName()

      Get the name of this job.
      Returns:
        job name for logging and identification

    - #### runJob

          public void runJob()

      Save the current router information to disk. This job writes the router's RouterInfo to the router.info file in the router directory. It uses a synchronized block to ensure thread-safe access to the router info file. The file is written using SecureFileOutputStream to ensure atomic writes and prevent corruption. Any errors during the write process are logged but do not prevent the job from completing.