java.lang.Object
net.i2p.router.JobImpl
net.i2p.router.networkdb.kademlia.FloodSearchJob
- All Implemented Interfaces:
Job
- Direct Known Subclasses:
FloodOnlySearchJob, IterativeSearchJob
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 Summary
FieldsModifier and TypeFieldDescriptionprotected final longSystem time when this search was created.protected booleanWhether this search has been marked as completed.protected longDeadline after which the search expires.protected final FloodfillNetworkDatabaseFacadeFloodfill network database facade.protected final booleanWhether the target is a LeaseSet lookup.protected final HashTarget database entry hash being searched.protected final LogClass logger.protected final AtomicIntegerRemaining flood lookups before fallback to iterative search.Callbacks for search failure.Callbacks for successful search completion.protected booleanWhether the search completed successfully.protected intTimeout for the search in milliseconds.protected static final intMax simultaneous flood lookups before fallback.Constructor Summary
ConstructorsConstructorDescriptionFloodSearchJob(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.Method Summary
Public MethodsModifier and TypeMethodDescription(package private) voidaddDeferred(Job onFind, Job onFailed, long timeoutMs, boolean isLease) Add jobs to an existing search.protected intNumber of lookups remaining after decrementing.(package private) voidfailed()Deprecated, unused, see FOSJ override.longSystem time, NOT context time.longExpiration time from the context clock.getKey()The database entry hash being searched.protected intNumber of flood lookups still pending.getName()Deprecated, unused, see FOSJ override.voidrunJob()Deprecated, unused, see FOSJ override.(package private) voidsuccess()Deprecated, unused, see FOSJ override.Methods inherited from class JobImpl
dropped, getContext, getJobId, getMadeReadyOn, getTiming, madeReady, requeue, toStringModifier and TypeMethodDescriptionvoiddropped()Default implementation does nothing.final RouterContextThe router context that this job belongs to.longgetJobId()The unique job ID for this job.longThe timestamp when this job was last made ready for execution.The timing object for this job.voidmadeReady(long now) For JobQueue only, not for external use.protected voidrequeue(long delayMs) Requeue this job to run after the specified delay.toString()
Field Details
_log
Class logger._facade
Floodfill network database facade._key
Target database entry hash being searched._onFind
_onFailed
_expiration
protected long _expirationDeadline after which the search expires._timeoutMs
protected int _timeoutMsTimeout for the search in milliseconds._isLease
protected final boolean _isLeaseWhether the target is a LeaseSet lookup._lookupsRemaining
Remaining flood lookups before fallback to iterative search._dead
protected volatile boolean _deadWhether this search has been marked as completed._created
protected final long _createdSystem time when this search was created._success
protected boolean _successWhether the search completed successfully.CONCURRENT_SEARCHES
protected static final int CONCURRENT_SEARCHESMax 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 managerfacade- floodfill database the key is looked up inkey- the hash being searched foronFind- may be nullonFailed- may be nulltimeoutMs- search timeout in ms, applied in full to the flood deadlineisLease- 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
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
Deprecated, unused, see FOSJ override.- Returns:
- the fixed descriptive name
"NetDb Search (phase 1)"of this job
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.