java.lang.Object
net.i2p.router.JobImpl
net.i2p.router.message.SendMessageDirectJob
- All Implemented Interfaces:
Job
Send a message directly to another router (not through a tunnel).
Used by HandleGarlicMessageJob to forward decrypted cloves to their target router or tunnel gateway. Also used by netdb for database store/lookup replies.
Safe to run inline via runJob(). If the RouterInfo for the Hash is not found locally, it will queue a lookup and register itself to be run again when the lookup succeeds or times out.
Field Summary
FieldsModifier and TypeFieldDescriptionprivate booleanTrue once the floodfill search started.private final longWhen the message is too old to send.private final LogLogger for the direct send job.private final I2NPMessageThe message to send.private final longRandom mask for the message id bloom filter.private final JobJob run when the send fails.private final JobJob run after a successful send.private final ReplyJobJob run when the reply arrives.private final intSend priority of the message.private RouterInfoThe target's router info, once found.private longWhen to start the floodfill search.private final MessageSelectorSelector matching the expected reply.private booleanTrue once the message was sent.private final HashThe hash of the target router.Constructor Summary
ConstructorsConstructorDescriptionSendMessageDirectJob(RouterContext ctx, I2NPMessage message, Hash toPeer, int timeoutMs, int priority) Send a message directly to a peer.SendMessageDirectJob(RouterContext ctx, I2NPMessage message, Hash toPeer, int timeoutMs, int priority, long msgIDBloomXor) Send a message directly to a peer with an XOR mask.SendMessageDirectJob(RouterContext ctx, I2NPMessage message, Hash toPeer, Job onSend, ReplyJob onSuccess, Job onFail, MessageSelector selector, int timeoutMs, int priority, long msgIDBloomXor) Send a message directly to a peer with full options.SendMessageDirectJob(RouterContext ctx, I2NPMessage message, Hash toPeer, ReplyJob onSuccess, Job onFail, MessageSelector selector, int timeoutMs, int priority) Send a message directly to a peer with reply handling.SendMessageDirectJob(RouterContext ctx, I2NPMessage message, Hash toPeer, ReplyJob onSuccess, Job onFail, MessageSelector selector, int timeoutMs, int priority, long msgIDBloomXor) Send a message directly to a peer with reply handling and XOR mask.Method Summary
Modifier and TypeMethodDescriptiongetName()Descriptive name of the task.private StringSimple class name of the message being sent, unwrapping aTunnelGatewayMessageto its inner message for a more informative log entry.voidrunJob()Actually perform the task.private voidsend()Sends the message to the target's router info.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
Logger for the direct send job._message
The message to send._targetHash
The hash of the target router._router
The target's router info, once found._expiration
private final long _expirationWhen the message is too old to send._priority
private final int _prioritySend priority of the message._onSend
Job run after a successful send._onSuccess
Job run when the reply arrives._onFail
Job run when the send fails._selector
Selector matching the expected reply._alreadySearched
private volatile boolean _alreadySearchedTrue once the floodfill search started._sent
private volatile boolean _sentTrue once the message was sent._searchOn
private long _searchOnWhen to start the floodfill search._msgIDBloomXor
private final long _msgIDBloomXorRandom mask for the message id bloom filter.
Constructor Details
SendMessageDirectJob
public SendMessageDirectJob(RouterContext ctx, I2NPMessage message, Hash toPeer, int timeoutMs, int priority) Send a message directly to a peer.- Parameters:
ctx- the router contextmessage- the message to sendtoPeer- may be ourselvestimeoutMs- milliseconds to wait for delivery; under 5000 is raised to 10000priority- the OutNetMessage priority, one of the MessageContext constants
SendMessageDirectJob
public SendMessageDirectJob(RouterContext ctx, I2NPMessage message, Hash toPeer, int timeoutMs, int priority, long msgIDBloomXor) Send a message directly to a peer with an XOR mask.- Parameters:
ctx- the router contextmessage- the message to sendtoPeer- may be ourselvestimeoutMs- milliseconds to wait for delivery; under 5000 is raised to 10000priority- the OutNetMessage priority, one of the MessageContext constantsmsgIDBloomXor- value to xor the messageID with before passing to the InNetMessagePool, may be 0
SendMessageDirectJob
public SendMessageDirectJob(RouterContext ctx, I2NPMessage message, Hash toPeer, ReplyJob onSuccess, Job onFail, MessageSelector selector, int timeoutMs, int priority) Send a message directly to a peer with reply handling.- Parameters:
ctx- the router contextmessage- the message to sendtoPeer- may be ourselvesonSuccess- may be nullonFail- may be nullselector- selects which reply triggers onSuccess, or null to accept any replytimeoutMs- milliseconds to wait for delivery; under 5000 is raised to 10000priority- the OutNetMessage priority, one of the MessageContext constants
SendMessageDirectJob
public SendMessageDirectJob(RouterContext ctx, I2NPMessage message, Hash toPeer, ReplyJob onSuccess, Job onFail, MessageSelector selector, int timeoutMs, int priority, long msgIDBloomXor) Send a message directly to a peer with reply handling and XOR mask.- Parameters:
ctx- the router contextmessage- the message to sendtoPeer- may be ourselvesonSuccess- may be nullonFail- may be nullselector- selects which reply triggers onSuccess, or null to accept any replytimeoutMs- milliseconds to wait for delivery; under 5000 is raised to 10000priority- the OutNetMessage priority, one of the MessageContext constantsmsgIDBloomXor- value to xor the messageID with before passing to the InNetMessagePool, may be 0
SendMessageDirectJob
public SendMessageDirectJob(RouterContext ctx, I2NPMessage message, Hash toPeer, Job onSend, ReplyJob onSuccess, Job onFail, MessageSelector selector, int timeoutMs, int priority, long msgIDBloomXor) Send a message directly to a peer with full options.- Parameters:
ctx- the router contextmessage- the message to sendtoPeer- may be ourselvesonSend- may be nullonSuccess- may be nullonFail- may be nullselector- selects which reply triggers onSuccess, or null to accept any replytimeoutMs- milliseconds to wait for delivery; under 5000 is raised to 10000priority- the OutNetMessage priority, one of the MessageContext constantsmsgIDBloomXor- value to xor the messageID with before passing to the InNetMessagePool, may be 0
Method Details
getName
messageTypeName
Simple class name of the message being sent, unwrapping aTunnelGatewayMessageto its inner message for a more informative log entry.- Returns:
- the simple class name of the message type
runJob
public void runJob()Description copied from interface:JobActually perform the task. This call blocks until the Job is complete.send
private void send()Sends the message to the target's router info.