java.lang.Object
net.i2p.router.JobImpl
net.i2p.router.networkdb.HandleDatabaseLookupMessageJob
- All Implemented Interfaces:
Job
- Direct Known Subclasses:
HandleFloodfillDatabaseLookupMessageJob
Handle a lookup for a key received from a remote peer. Needs to be implemented to send back replies, etc Unused directly - see kademlia/ for extension.
Field Summary
Modifier and TypeFieldDescriptionprivate final LogThe log for the lookup job.private final DatabaseLookupMessageThe lookup message being handled.private final longThe bloom filter xor of the message id.private booleanTrue once the reply key was used.private final HashOur own router hash.static final longIf a routerInfo structure isn't this recent, don't send it out.private static final intMost routers returned in a reply.private static final intThe priority of the reply messages.private static final intTime allowed for sending a reply.Constructor Summary
ConstructorsConstructorDescriptionHandleDatabaseLookupMessageJob(RouterContext ctx, DatabaseLookupMessage receivedMessage, RouterIdentity _from, Hash _fromHash, long msgIDBloomXor) Creates a new HandleDatabaseLookupMessageJob.Method Summary
Modifier and TypeMethodDescriptionvoiddropped()Default implementation does nothing.getName()Descriptive name of the task.getNearestRouters(DatabaseLookupMessage.Type lookupType) Closest to the message's search key, honoring the message's dontInclude set.voidrunJob()Actually perform the task.protected voidSend the closest routers to the requesting peer.private voidsendData(Hash key, DatabaseEntry data, Hash toPeer, TunnelId replyTunnel) Sends the data that was found.protected voidsendMessage(I2NPMessage message, Hash toPeer, TunnelId replyTunnel) Send an I2NP message to the specified peer.private voidsendThroughTunnel(I2NPMessage message, Hash toPeer, TunnelId replyTunnel) Sends the message through the reply tunnel.Methods inherited from class JobImpl
getContext, getJobId, getMadeReadyOn, getTiming, madeReady, requeue, toStringModifier and TypeMethodDescriptionfinal 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
The log for the lookup job._message
The lookup message being handled._replyKeyConsumed
private boolean _replyKeyConsumedTrue once the reply key was used._us
Our own router hash._msgIDBloomXor
private final long _msgIDBloomXorThe bloom filter xor of the message id.MAX_ROUTERS_RETURNED
private static final int MAX_ROUTERS_RETURNEDMost routers returned in a reply.- See Also:
REPLY_TIMEOUT
private static final int REPLY_TIMEOUTTime allowed for sending a reply.- See Also:
MESSAGE_PRIORITY
private static final int MESSAGE_PRIORITYThe priority of the reply messages.- See Also:
EXPIRE_DELAY
public static final long EXPIRE_DELAYIf a routerInfo structure isn't this recent, don't send it out. Equal to KNDF.ROUTER_INFO_EXPIRATION_FLOODFILL.- See Also:
Constructor Details
HandleDatabaseLookupMessageJob
public HandleDatabaseLookupMessageJob(RouterContext ctx, DatabaseLookupMessage receivedMessage, RouterIdentity _from, Hash _fromHash, long msgIDBloomXor) Creates a new HandleDatabaseLookupMessageJob.- Parameters:
ctx- the router contextreceivedMessage- the received message_from- the router identity of the sender_fromHash- the hash of the sendermsgIDBloomXor- the message ID bloom XOR value
Method Details
runJob
public void runJob()Description copied from interface:JobActually perform the task. This call blocks until the Job is complete.getNearestRouters
Closest to the message's search key, honoring the message's dontInclude set. Will not include us. Side effect - adds us to the message's dontInclude set.- Parameters:
lookupType- the message's lookup type, EXPL also excludes the fake hash- Returns:
- the nearest routers
sendData
Sends the data that was found.- Parameters:
key- the key that was searcheddata- the entry that was foundtoPeer- the peer to reply toreplyTunnel- the tunnel for the reply
sendClosest
sendMessage
Send an I2NP message to the specified peer.- Parameters:
message- the I2NP message being sent as the replytoPeer- the destination peerreplyTunnel- the reply tunnel, or null for direct delivery
sendThroughTunnel
Sends the message through the reply tunnel.- Parameters:
message- the message to sendtoPeer- the peer to send toreplyTunnel- the tunnel for the reply
getName
dropped