java.lang.Object
net.i2p.router.JobImpl
net.i2p.router.networkdb.kademlia.ExpireRoutersJob
All Implemented Interfaces:
Job

class ExpireRoutersJobextends JobImpl
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 Details

    • _log

      private final Log _log
      Logger for this class.
    • _facade

      private final KademliaNetworkDatabaseFacade _facade
      The store whose entries are expired.
    • RERUN_DELAY_MS

      private static final long RERUN_DELAY_MS
      Rerun fairly often, so the fails don't queue up too many netdb searches at once.
      See Also:
    • LIMIT_ROUTERS

      private static final int LIMIT_ROUTERS
      Most router entries examined in one run.
    • PROTECTED_ATTESTED

      static final long PROTECTED_ATTESTED
      Attested more recently than this: never dropped by the size-pressure path.
      See Also:
    • STALE_ATTESTED

      static final long STALE_ATTESTED
      Attested more recently than this: dropped at half the base probability.
      See Also:
  • Constructor Details

    • ExpireRoutersJob

      public ExpireRoutersJob(RouterContext ctx, KademliaNetworkDatabaseFacade facade)
      Expire outdated routers from the network database.
      Parameters:
      ctx - the router context
      facade - the Kademlia network database facade
  • Method Details

    • getName

      public String getName()
      Description copied from interface: Job
      Descriptive name of the task.
      Returns:
      the descriptive name of the task
    • runJob

      public void runJob()
      Description copied from interface: Job
      Actually 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 within PROTECTED_ATTESTED are 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 practice
      lastSeen - newest contact evidence for the peer, 0 if never attested
      now - current context time
      Returns:
      adjusted chance in 128, 0 to protect the peer this cycle