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

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

    • _log

      private final Log _log
      Logger for this class.
    • _facade

      private final FloodfillNetworkDatabaseFacade _facade
      The floodfill database whose profile is refreshed.
    • _pending

      private final ConcurrentLinkedQueue<Hash> _pending
      Peers we've heard from recently that may need a RI refresh.
    • _lastRefresh

      private final Map<Hash,Long> _lastRefresh
      Cooldown tracker: peer hash -> last refresh time (ms).
    • MAX_BATCH

      private static final int MAX_BATCH
      Max peers to process per cycle.
      See Also:
    • CYCLE_MS

      private static final long CYCLE_MS
      Run interval when idle.
      See Also:
    • COOLDOWN_MS

      private static final long COOLDOWN_MS
      Don't re-refresh the same peer more often than this.
      See Also:
    • MAX_COOLDOWN_ENTRIES

      private static final int MAX_COOLDOWN_ENTRIES
      Max cooldown map entries to prevent unbounded growth.
      See Also:
    • MAX_PENDING

      private static final int MAX_PENDING
      Max 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 context
      facade - the floodfill 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
    • heardFrom

      void heardFrom(Hash peer)
      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: Job
      Actually perform the task. This call blocks until the Job is complete.