- All Implemented Interfaces:
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.infofile 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
Constructor Summary
ConstructorsConstructorDescriptionCreate a new router info persistence job.Method Summary
All MethodsMethods 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()
Constructor Details
PersistRouterInfoJob
Create a new router info persistence job.- Parameters:
ctx- router context for accessing router services
Method Details
getName
runJob
public void runJob()Save the current router information to disk.This job writes the router's RouterInfo to the
router.infofile in the router directory. It uses a synchronized block to ensure thread-safe access to the router info file.The file is written using
SecureFileOutputStreamto ensure atomic writes and prevent corruption. Any errors during the write process are logged but do not prevent the job from completing.