java.lang.Object
net.i2p.router.JobImpl
net.i2p.router.networkdb.kademlia.ExpireRoutersJob
- All Implemented Interfaces:
Job
Go through the routing table pick routers that are out of date, but don't expire routers we're actively connected to.
The normal path uses _facade's validate(), a sliding expiration based on netdb size. When the netdb is over the size limit, eviction is profile-weighted (see dropProbability(int, long, long)) — peers with no recent contact evidence go first, recently-attested peers are kept — instead of a flat random drop.
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final KademliaNetworkDatabaseFacadeThe store whose entries are expired.private final LogLogger for this class.private static final intMost router entries examined in one run.(package private) static final longAttested more recently than this: never dropped by the size-pressure path.private static final longRerun fairly often, so the fails don't queue up too many netdb searches at once.(package private) static final longAttested more recently than this: dropped at half the base probability.Constructor Summary
ConstructorsConstructorDescriptionExpireRoutersJob(RouterContext ctx, KademliaNetworkDatabaseFacade facade) Expire outdated routers from the network database.Method Summary
Modifier and TypeMethodDescription(package private) static intdropProbability(int base, long lastSeen, long now) Profile-weighted drop probability (chance in 128) for the size-pressure eviction path.private intRun through all of the known peers and pick ones that have really old routerInfo publish dates, excluding ones that we are connected to, so that they can be failed.getName()Descriptive name of the task.voidrunJob()Actually perform the task.Methods 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 store whose entries are expired.RERUN_DELAY_MS
private static final long RERUN_DELAY_MSRerun fairly often, so the fails don't queue up too many netdb searches at once.- See Also:
LIMIT_ROUTERS
private static final int LIMIT_ROUTERSMost router entries examined in one run.PROTECTED_ATTESTED
static final long PROTECTED_ATTESTEDAttested more recently than this: never dropped by the size-pressure path.- See Also:
STALE_ATTESTED
static final long STALE_ATTESTEDAttested more recently than this: dropped at half the base probability.- See Also:
Constructor Details
ExpireRoutersJob
Expire outdated routers from the network database.- Parameters:
ctx- the router contextfacade- the Kademlia network database facade
Method Details
getName
runJob
public void runJob()Description copied from interface:JobActually perform the task. This call blocks until the Job is complete.expireKeys
private int expireKeys()Run through all of the known peers and pick ones that have really old routerInfo publish dates, excluding ones that we are connected to, so that they can be failed.- Returns:
- how many routers were failed and removed, 0 if the netdb is small, we are disconnected, or the system is lagging
dropProbability
static int dropProbability(int base, long lastSeen, long now) Profile-weighted drop probability (chance in 128) for the size-pressure eviction path. Peers with no contact evidence are dropped harder than the flat probability; peers attested withinPROTECTED_ATTESTEDare skipped entirely, so netdb size pressure evicts known-dead entries before useful ones. Pure function — directly unit-testable.- Parameters:
base- the flat probability, 10-80 in practicelastSeen- newest contact evidence for the peer, 0 if never attestednow- current context time- Returns:
- adjusted chance in 128, 0 to protect the peer this cycle