net.i2p.router.networkdb.kademlia

## Class FloodSearchJob

- java.lang.Object
- - net.i2p.router.JobImpl
  - - net.i2p.router.networkdb.kademlia.FloodSearchJob

- All Implemented Interfaces:
    Job
  Direct Known Subclasses:
    FloodOnlySearchJob, IterativeSearchJob

      abstract class FloodSearchJob
      extends 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 half 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 Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `protected long` | `_created`
    `protected boolean` | `_dead`
    `protected long` | `_expiration`
    `protected FloodfillNetworkDatabaseFacade` | `_facade`
    `protected boolean` | `_isLease`
    `protected Hash` | `_key`
    `protected Log` | `_log`
    `protected AtomicInteger` | `_lookupsRemaining`
    `protected List<Job>` | `_onFailed`
    `protected List<Job>` | `_onFind`
    `protected boolean` | `_success`
    `protected int` | `_timeoutMs`
    `protected static int` | `CONCURRENT_SEARCHES`

    - ### Fields inherited from class net.i2p.router.JobImpl

      `_id`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `FloodSearchJob(RouterContext ctx, FloodfillNetworkDatabaseFacade facade, Hash key, Job onFind, Job onFailed, int timeoutMs, boolean isLease)`

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `(package private) void` | `addDeferred(Job onFind, Job onFailed, long timeoutMs, boolean isLease)` Add jobs to an existing search
    `protected int` | `decrementRemaining()`
    `(package private) void` | `failed()` Deprecated, unused, see FOSJ override
    `long` | `getCreated()` System time, NOT context time
    `long` | `getExpiration()` using context clock
    `Hash` | `getKey()`
    `protected int` | `getLookupsRemaining()`
    `String` | `getName()` Deprecated, unused, see FOSJ override
    `void` | `runJob()` Deprecated, unused, see FOSJ override
    `(package private) void` | `success()` Deprecated, unused, see FOSJ override

    - ### Methods inherited from class net.i2p.router.JobImpl

      `dropped, getContext, getJobId, getMadeReadyOn, getTiming, madeReady, requeue, toString`

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait`

- - ### Field Detail

    - #### _created

          protected final long _created

    - #### _dead

          protected volatile boolean _dead

    - #### _expiration

          protected long _expiration

    - #### _facade

          protected final FloodfillNetworkDatabaseFacade _facade

    - #### _isLease

          protected final boolean _isLease

    - #### _key

          protected final Hash _key

    - #### _log

          protected final Log _log

    - #### _lookupsRemaining

          protected final AtomicInteger _lookupsRemaining

    - #### _onFailed

          protected final List<Job> _onFailed

    - #### _onFind

          protected final List<Job> _onFind

    - #### _success

          protected boolean _success

    - #### _timeoutMs

          protected int _timeoutMs

    - #### CONCURRENT_SEARCHES

          protected static final int CONCURRENT_SEARCHES

  - ### Constructor Detail

    - #### FloodSearchJob

          public FloodSearchJob(RouterContext ctx,
                                FloodfillNetworkDatabaseFacade facade,
                                Hash key,
                                Job onFind,
                                Job onFailed,
                                int timeoutMs,
                                boolean isLease)

      Parameters:
        `onFind` - may be null
        `onFailed` - may be null

  - ### Method Detail

    - #### 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` - ignored
        `isLease` - ignored

    - #### decrementRemaining

          protected int decrementRemaining()

      Returns:
        number remaining after decrementing

    - #### failed

          void failed()

      Deprecated, unused, see FOSJ override

    - #### getCreated

          public long getCreated()

      System time, NOT context time

    - #### getExpiration

          public long getExpiration()

      using context clock

    - #### getKey

          public Hash getKey()

    - #### getLookupsRemaining

          protected int getLookupsRemaining()

    - #### getName

          public String getName()

      Deprecated, unused, see FOSJ override
      Returns:
        the descriptive name of the task

    - #### runJob

          public void runJob()

      Deprecated, unused, see FOSJ override

    - #### success

          void success()

      Deprecated, unused, see FOSJ override