java.lang.Object
net.i2p.router.JobImpl
net.i2p.router.networkdb.kademlia.ContactDrivenRefreshJob
- All Implemented Interfaces:
Job
Lightweight background job that refreshes RouterInfo for peers we recently interacted with. When we receive a DatabaseStore (or other direct contact) from a peer, we enqueue them here. On each cycle, we process a batch: if the peer's stored RouterInfo is stale (published > 1h ago) or missing, we proactively refresh it via
DirectLookupJob.This is the contact-driven half of proactive RouterInfo freshness: peers we actively communicate with are likely to be re-selected as tunnel hops, so keeping their RI current prevents build-time next-hop lookup failures.
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final FloodfillNetworkDatabaseFacadeThe floodfill database whose profile is refreshed.Cooldown tracker: peer hash -> last refresh time (ms).private final LogLogger for this class.private final ConcurrentLinkedQueue<Hash> Peers we've heard from recently that may need a RI refresh.private static final longDon't re-refresh the same peer more often than this.private static final longRun interval when idle.private static final intMax peers to process per cycle.private static final intMax cooldown map entries to prevent unbounded growth.private static final intMax pending queue size — reject offers past this to prevent OOM under heavy store load.Constructor Summary
ConstructorsConstructorDescriptionCreates a new ContactDrivenRefreshJob.Method Summary
Public 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()
Field Details
_log
Logger for this class._facade
The floodfill database whose profile is refreshed._pending
Peers we've heard from recently that may need a RI refresh._lastRefresh
MAX_BATCH
CYCLE_MS
COOLDOWN_MS
private static final long COOLDOWN_MSDon't re-refresh the same peer more often than this.- See Also:
MAX_COOLDOWN_ENTRIES
private static final int MAX_COOLDOWN_ENTRIESMax cooldown map entries to prevent unbounded growth.- See Also:
MAX_PENDING
private static final int MAX_PENDINGMax pending queue size — reject offers past this to prevent OOM under heavy store load.- See Also:
Constructor Details
ContactDrivenRefreshJob
ContactDrivenRefreshJob(RouterContext ctx, FloodfillNetworkDatabaseFacade facade) Creates a new ContactDrivenRefreshJob.- Parameters:
ctx- the router contextfacade- the floodfill network database facade
Method Details
getName
heardFrom
Called when we hear from or about a peer. Safe to call from any thread (e.g., message handler). Drops the entry if the pending queue is full to prevent unbounded memory growth.- Parameters:
peer- the peer hash
runJob
public void runJob()Description copied from interface:JobActually perform the task. This call blocks until the Job is complete.