Class SearchJob
java.lang.Object
net.i2p.router.JobImpl
net.i2p.router.networkdb.kademlia.SearchJob
- All Implemented Interfaces:
Job
- Direct Known Subclasses:
ExploreJob
Search for a particular key iteratively until we either find a value or we
run out of peers
Note that this is rarely if ever used directly, and is primary used by the ExploreJob extension.
FloodOnlySearchJob and FloodSearchJob do not extend this.
It also does not update peer profile stats.
-
Nested Class Summary
Modifier and TypeClassDescriptionprotected class
Called when a particular peer failed to respond before the timeout was reached, or if the peer could not be contacted at all. -
Field Summary
Modifier and TypeFieldDescriptionprotected final KademliaNetworkDatabaseFacade
protected final Log
(package private) static final int
only send the 10 closest "dont tell me about" refs(package private) static final long
(package private) static final int
timeout -
Constructor Summary
ConstructorDescriptionSearchJob
(RouterContext context, KademliaNetworkDatabaseFacade facade, Hash key, Job onSuccess, Job onFailure, long timeoutMs, boolean keepStats, boolean isLease) Create a new search for the routingKey specified -
Method Summary
Modifier and TypeMethodDescription(package private) boolean
int
addDeferred
(Job onFind, Job onFail, long expiration, boolean isLease) protected I2NPMessage
buildMessage
(TunnelId replyTunnelId, Hash replyGateway, long expiration, RouterInfo peer) Build the database search messageprotected void
Send a series of searches to the next available peers as selected by the routing table, but making sure no more than SEARCH_BREDTH are outstanding at any time(package private) void
protected void
fail()
Search totally failedprotected int
max # of concurrent searcheslong
protected KademliaNetworkDatabaseFacade
getName()
Descriptive name of the taskprotected int
Let each peer take up to the average successful search RTTprotected int
getPerPeerTimeoutMs
(Hash peer) protected SearchState
getState()
long
protected void
newPeersFound
(int numNewPeers) We've gotten a search reply that contained the specified number of peers that we didn't know about before.(package private) static boolean
this is now misnamed, as it is only used to determine whether to return floodfill peers only(package private) void
replyFound
(DatabaseSearchReplyMessage message, Hash peer) found a replyvoid
runJob()
Actually perform the task.protected void
Send the next search, or stop if its completedprotected void
sendLeaseSearch
(RouterInfo router) we're (probably) searching for a LeaseSet, so to be (overly) cautious, we're sending the request out through a tunnel w/ reply back through another tunnel.protected void
sendRouterSearch
(RouterInfo router) we're searching for a router, so we can just send directprotected void
sendSearch
(RouterInfo router) Send a search to the given peer(package private) long
toString()
(package private) boolean
wasAttempted
(Hash peer) Methods inherited from class net.i2p.router.JobImpl
dropped, getAddedBy, getContext, getJobId, getMadeReadyOn, getTiming, madeReady, madeReady, requeue
-
Field Details
-
_log
-
_facade
-
MAX_CLOSEST
static final int MAX_CLOSESTonly send the 10 closest "dont tell me about" refs- See Also:
-
PER_FLOODFILL_PEER_TIMEOUT
static final int PER_FLOODFILL_PEER_TIMEOUTtimeout- See Also:
-
MIN_TIMEOUT
static final long MIN_TIMEOUT- See Also:
-
-
Constructor Details
-
SearchJob
public SearchJob(RouterContext context, KademliaNetworkDatabaseFacade facade, Hash key, Job onSuccess, Job onFailure, long timeoutMs, boolean keepStats, boolean isLease) Create a new search for the routingKey specified
-
-
Method Details
-
runJob
public void runJob()Description copied from interface:Job
Actually perform the task. This call blocks until the Job is complete. -
getState
-
getFacade
-
getExpiration
public long getExpiration() -
getTimeoutMs
public long getTimeoutMs() -
onlyQueryFloodfillPeers
this is now misnamed, as it is only used to determine whether to return floodfill peers only -
getPerPeerTimeoutMs
-
getPerPeerTimeoutMs
protected int getPerPeerTimeoutMs()Let each peer take up to the average successful search RTT -
searchNext
protected void searchNext()Send the next search, or stop if its completed -
getBredth
protected int getBredth()max # of concurrent searches -
continueSearch
protected void continueSearch()Send a series of searches to the next available peers as selected by the routing table, but making sure no more than SEARCH_BREDTH are outstanding at any time -
sendSearch
Send a search to the given peer -
sendLeaseSearch
we're (probably) searching for a LeaseSet, so to be (overly) cautious, we're sending the request out through a tunnel w/ reply back through another tunnel. -
sendRouterSearch
we're searching for a router, so we can just send direct -
buildMessage
protected I2NPMessage buildMessage(TunnelId replyTunnelId, Hash replyGateway, long expiration, RouterInfo peer) Build the database search message- Parameters:
replyTunnelId
- tunnel to receive replies throughreplyGateway
- gateway for the reply tunnelexpiration
- when the search should stoppeer
- unused here; see ExploreJob extension- Returns:
- a DatabaseLookupMessage
-
replyFound
found a reply -
newPeersFound
protected void newPeersFound(int numNewPeers) We've gotten a search reply that contained the specified number of peers that we didn't know about before. -
fail
protected void fail()Search totally failed -
addDeferred
-
getName
Description copied from interface:Job
Descriptive name of the task -
toString
-
wasAttempted
-
timeoutMs
long timeoutMs() -
add
- Returns:
- true if peer was new
-
decrementOutstandingFloodfillSearches
void decrementOutstandingFloodfillSearches()
-