public class IterativeSearchJob extends FloodSearchJob
Continues searching when initial lookup fails by iteratively querying closer-to-the-key peers returned in DatabaseSearchReplyMessages. Unlike traditional Kademlia, doesn't stop when no closer keys are available - keeps searching until timeout or maximum search limit is reached.
Key differences from FloodOnlySearchJob: - Chases peers in DSRM immediately rather than waiting - Searches one peer at a time with individual per-search timeouts - Uses total timeout rather than per-search timeouts - Longer overall timeout for better success rates - Reduces search traffic by half compared to parallel approaches
Advantages over flood-only approaches: - More robust in large networks with incomplete floodfill knowledge - Better success rates through sequential searching - Reduced network traffic through single-peer queries
| Modifier and Type | Field and Description |
|---|---|
static boolean | DEFAULT_ENCRYPT_RIonly on fast boxes, for now |
static String | PROP_ENCRYPT_RIPROP_ENCRYPT_RI. |
_created, _dead, _expiration, _facade, _isLease, _key, _log, _lookupsRemaining, _onFailed, _onFind, _success, _timeoutMs, CONCURRENT_SEARCHES| Constructor and Description |
|---|
IterativeSearchJob(RouterContext ctx,
FloodfillNetworkDatabaseFacade facade,
Hash key,
Job onFind,
Job onFailed,
int timeoutMs,
boolean isLease)Lookup using exploratory tunnels |
IterativeSearchJob(RouterContext ctx,
FloodfillNetworkDatabaseFacade facade,
Hash key,
Job onFind,
Job onFailed,
int timeoutMs,
boolean isLease,
Hash fromLocalDest)Lookup using the client's tunnels. |
| Modifier and Type | Method and Description |
|---|---|
(package private) void | cancelJob()Cancels the job without performing full failure handling. |
static void | clearRecentlyQueried(Hash peer)Clear peer from grace period cache (received their response). |
void | dropped()Dropped by the job queue |
(package private) void | failed()Total failure |
(package private) void | failed(Hash peer,
boolean timedOut)Note that the peer did not respond with a DSM (either a DSRM, timeout, or failure). |
Hash | getFromHash()Hash of the dest this query is from |
static int | getMaxConcurrentDefault()Gets the maximum concurrent default value. |
static int | getMaxLeaseSetLookupTime() |
static int | getMaxRouterInfoLookupTime() |
String | getName()Deprecated, unused, see FOSJ override |
(package private) void | newPeerToTry(Hash peer)A new (floodfill) peer was discovered that may have the answer. |
static long | reloadGracePeriod(RouterContext ctx)Reload grace period from properties (for dynamic tuning). |
void | runJob()Execute the iterative search, selecting floodfill peers from the
k-buckets and sending DatabaseLookupMessages to each. |
static void | setMaxConcurrentDefault(int val)Sets the maximum concurrent default value. |
static void | setMaxLeaseSetLookupTime(int val) |
static void | setMaxRouterInfoLookupTime(int val) |
(package private) void | success()Called when the search completes successfully. |
(package private) long | timeSent(Hash peer)When did we send the query to the peer? |
boolean | wasQueried(Hash peer)Did we send a request to this peer? |
static boolean | wasRecentlyQueried(Hash peer)Was this peer recently queried (within grace period)?
Used to avoid false positive bans for late but legitimate replies. |
addDeferred, decrementRemaining, getCreated, getExpiration, getKey, getLookupsRemaininggetContext, getJobId, getMadeReadyOn, getTiming, madeReady, requeue, toStringpublic static final boolean DEFAULT_ENCRYPT_RI
public static final String PROP_ENCRYPT_RI
public IterativeSearchJob(RouterContext ctx, FloodfillNetworkDatabaseFacade facade, Hash key, Job onFind, Job onFailed, int timeoutMs, boolean isLease)
public IterativeSearchJob(RouterContext ctx, FloodfillNetworkDatabaseFacade facade, Hash key, Job onFind, Job onFailed, int timeoutMs, boolean isLease, Hash fromLocalDest)
fromLocalDest - use these tunnels for the lookup, or null for exploratoryvoid cancelJob()
public static void clearRecentlyQueried(Hash peer)
peer - the peerpublic void dropped()
void failed()
failed in class FloodSearchJobvoid failed(Hash peer, boolean timedOut)
peer - the peer that failedtimedOut - if true, will blame the peer's profilepublic Hash getFromHash()
public static int getMaxConcurrentDefault()
public static int getMaxLeaseSetLookupTime()
public static int getMaxRouterInfoLookupTime()
public String getName()
FloodSearchJobgetName in interface JobgetName in class FloodSearchJobvoid newPeerToTry(Hash peer)
peer - may not actually be newpublic static long reloadGracePeriod(RouterContext ctx)
ctx - router context for property lookuppublic void runJob()
runJob in interface JobrunJob in class FloodSearchJobpublic static void setMaxConcurrentDefault(int val)
public static void setMaxLeaseSetLookupTime(int val)
val - LeaseSet lookup deadline cap in ms, clamped to [3000, MAX_SEARCH_TIME]public static void setMaxRouterInfoLookupTime(int val)
val - RouterInfo lookup deadline cap in ms, clamped to [3000, MAX_SEARCH_TIME]void success()
success in class FloodSearchJoblong timeSent(Hash peer)
peer - the peer to checkpublic boolean wasQueried(Hash peer)
peer - the peerpublic static boolean wasRecentlyQueried(Hash peer)
peer - the peer