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

class ExpireLeasesJobextends JobImpl
Periodically searches through all leases to find expired ones, failing those keys and firing up a new search for each (in case we want it later, might as well preemptively fetch it). Also refreshes leasesets that are about to expire to ensure continuity of service.
  • Field Details

    • _log

      private final Log _log
      Logger for this class.
    • _facade

      private final KademliaNetworkDatabaseFacade _facade
      The facade whose leases expire.
    • RERUN_DELAY_MS

      private static final long RERUN_DELAY_MS
      Pause before the next pass - 30 seconds.
      See Also:
    • LIMIT_LEASES_FF

      private static final int LIMIT_LEASES_FF
      Most leases a floodfill checks in one pass.
      See Also:
    • LIMIT_LEASES_CLIENT

      private static final int LIMIT_LEASES_CLIENT
      Most leases a normal router checks in one pass.
    • REFRESH_THRESHOLD_MS

      private static final long REFRESH_THRESHOLD_MS
      Refresh leasesets with less than this much time remaining before expiry.
      See Also:
    • STALE_EXPIRED_MS

      private static final long STALE_EXPIRED_MS
      After this long past expiry, a leaseset is considered stale and purged immediately by purgeStaleLeasesets() in a client database.
      See Also:
  • Constructor Details

    • ExpireLeasesJob

      public ExpireLeasesJob(RouterContext ctx, KademliaNetworkDatabaseFacade facade)
      Opens the job log and remembers the facade whose leasesets are expired.
      Parameters:
      ctx - the router context supplying the clock, log manager and job queue
      facade - the network database whose leasesets this job expires and refreshes
  • Method Details

    • getName

      public String getName()
      Name of this job.
      Returns:
      the name this job is listed under in the job queue
    • runJob

      public void runJob()
      Expire outdated lease sets and refresh those about to expire.
    • purgeStaleLeasesets

      private void purgeStaleLeasesets()
      Aggressively purge leasesets that have been expired for longer than the stale threshold. This ensures expired leasesets don't linger in the netdb for extended periods.
    • refreshAboutToExpire

      private void refreshAboutToExpire()
      Refresh leasesets that are about to expire to ensure continuity of service. This preemptively fetches new leasesets before the old ones expire, avoiding any gap in service.
    • selectKeysToExpire

      private List<Hash> selectKeysToExpire()
      Run through the entire data store, finding all expired leaseSets (ones that don't have any leases that haven't yet passed, even with the CLOCK_FUDGE_FACTOR).
      Returns:
      the keys of the leaseSets to expire, empty if none
    • getTunnelName

      public String getTunnelName(Destination d)
      Tunnel nickname for the given destination, if it has inbound tunnels.
      Parameters:
      d - the destination to name the tunnel pool for, or null for the empty name
      Returns:
      the tunnel name