java.lang.Object
net.i2p.router.JobImpl
net.i2p.router.networkdb.kademlia.FloodSearchJob
All Implemented Interfaces:
Job
Direct Known Subclasses:
FloodOnlySearchJob, IterativeSearchJob

abstract class FloodSearchJobextends JobImpl
Base class for flood-based search operations with fallback to Kademlia.

Implements flood-based search strategy sending queries to floodfill peers. If no successful match is received within the allowed timeout, falls back to standard Kademlia iterative search through normal channels. This reduces spurious lookups caused by response delays from floodfill peers.

Note: Unused directly - see FloodOnlySearchJob extension which overrides almost everything. This does NOT extend SearchJob.

  • Field Details

    • _log

      protected final Log _log
      Class logger.
    • _facade

      protected final FloodfillNetworkDatabaseFacade _facade
      Floodfill network database facade.
    • _key

      protected final Hash _key
      Target database entry hash being searched.
    • _onFind

      protected final List<Job> _onFind
      Callbacks for successful search completion.
    • _onFailed

      protected final List<Job> _onFailed
      Callbacks for search failure.
    • _expiration

      protected long _expiration
      Deadline after which the search expires.
    • _timeoutMs

      protected int _timeoutMs
      Timeout for the search in milliseconds.
    • _isLease

      protected final boolean _isLease
      Whether the target is a LeaseSet lookup.
    • _lookupsRemaining

      protected final AtomicInteger _lookupsRemaining
      Remaining flood lookups before fallback to iterative search.
    • _dead

      protected volatile boolean _dead
      Whether this search has been marked as completed.
    • _created

      protected final long _created
      System time when this search was created.
    • _success

      protected boolean _success
      Whether the search completed successfully.
    • CONCURRENT_SEARCHES

      protected static final int CONCURRENT_SEARCHES
      Max simultaneous flood lookups before fallback.
  • Constructor Details

    • FloodSearchJob

      public FloodSearchJob(RouterContext ctx, FloodfillNetworkDatabaseFacade facade, Hash key, Job onFind, Job onFailed, int timeoutMs, boolean isLease)
      Prepares a flood search for one key: records the target, the callbacks and the lease-set flag, then derives the deadline from the requested timeout, applied in full. (IterativeSearchJob extends this class, so any shortening here would halve every iterative search's deadline as well.).
      Parameters:
      ctx - router context supplying the clock and log manager
      facade - floodfill database the key is looked up in
      key - the hash being searched for
      onFind - may be null
      onFailed - may be null
      timeoutMs - search timeout in ms, applied in full to the flood deadline
      isLease - true to search for a lease set rather than a router info
  • Method Details

    • getCreated

      public long getCreated()
      System time, NOT context time.
      Returns:
      wall-clock creation time in milliseconds, used for statistics only
    • addDeferred

      void addDeferred(Job onFind, Job onFailed, long timeoutMs, boolean isLease)
      Add jobs to an existing search.
      Parameters:
      onFind - may be null
      onFailed - may be null
      timeoutMs - search timeout in ms
      isLease - whether searching for lease set
    • getExpiration

      public long getExpiration()
      Expiration time from the context clock.
      Returns:
      context-clock time in ms at which this search times out
    • runJob

      public void runJob()
      Deprecated, unused, see FOSJ override.
    • getName

      public String getName()
      Deprecated, unused, see FOSJ override.
      Returns:
      the fixed descriptive name "NetDb Search (phase 1)" of this job
    • getKey

      public Hash getKey()
      The database entry hash being searched.
      Returns:
      the database entry hash being searched
    • decrementRemaining

      protected int decrementRemaining()
      Number of lookups remaining after decrementing.
      Returns:
      number remaining after decrementing
    • getLookupsRemaining

      protected int getLookupsRemaining()
      Number of flood lookups still pending.
      Returns:
      number of flood lookups still pending
    • failed

      void failed()
      Deprecated, unused, see FOSJ override.
    • success

      void success()
      Deprecated, unused, see FOSJ override.