java.lang.Object
net.i2p.router.OutNetMessage
Field Summary
Modifier and TypeFieldDescriptionprivate final RouterContextThe router context.private longWhen the message was created.private longWhen the message entered the send pool.private final longWhen the message is too old to send.The transports that failed to deliver this message.private final I2NPMessageThe message to send.private final longCached message ID, for use after we discard the message.private final intSize of the message, in bytes.private final intType id of the message.private JobJob run when the reply fails.private JobJob run after a failed send.private ReplyJobJob run when the reply arrives.private JobJob run after a successful send.private final intSend priority of the message.private MessageSelectorSelector matching the expected reply.private longWhen the send started, 0 until sent.private longSequence id used to match the reply.private final booleanTrue to record the send timing.private final RouterInfoThe peer the message goes to.Contains a list of timestamp event names in the order they were fired (some JVMs have less than 10ms resolution, so the Long above doesn't guarantee order).For debugging, maps each event name to a timestamp (e.g.private longWhen the transport took the message.static final intBuild reply priority.static final intExploratory priority.static final intHighest priority.static final intHis build request priority.static final intHis netdb store priority.static final intPriorities, higher is higher priority.static final intMedium priority.static final intMy build request priority.static final intMy data priority.static final intMy netdb lookup priority.static final intMy netdb store priority.static final intMy netdb store low priority.static final intNetdb explore priority.static final intNetdb flood priority.static final intNetdb harvest priority.static final intNetdb reply priority.static final intParticipating priority.Constructor Summary
ConstructorsConstructorDescriptionOutNetMessage(RouterContext context) Null msg and target, zero expiration (used in OutboundMessageRegistry only).OutNetMessage(RouterContext context, I2NPMessage msg, long expiration, int priority, RouterInfo target) Standard constructor.Method Summary
Modifier and TypeMethodDescriptionvoidRecord the time the send process began.voidWe've done what we need to do with the data from this message, though we may keep the object around for a while to use its ID, jobs, etc.voiddrop()For CDQ.longCreation time.longThe enqueue time, used by the CDQ.longSpecify the # ms since the epoch after which if the message has not been sent the OnFailedSend job should be fired and the message should be removed from the pool.intNumber of transports that have failed to deliver this message.The transports that have failed to deliver this message.longHow long the message has existed.Specifies the message to be sent.intgetMessageData(byte[] outBuffer) Copies the message data to outbuffer.longMessage ID.intHow large the message is, including the full 16 byte header.For debugging only.intMessage type ID.If the Message selector is specified but it doesn't find a reply before its expiration passes, this job is enqueued.If the router could not be reached or the expiration passed, this job is enqueued.If the MessageSelector detects a reply, this job is enqueued.After the message is successfully passed to the router specified, the given job is enqueued.intSpecify the priority of the message, where higher numbers are higher priority.Defines a MessageSelector to find a reply to this message.longWhen the sending process began.longHow long the send has been under way.longThe sequence number, used by the CDPQ.Specifies the router to which the message should be delivered.longWhen the transport took the message.private voidStamps the message's timing fields.private voidOnly useful if log level is INFO or DEBUG;locked_initTimestamps()must have been called previously.voidReset creation time for dispatch age tracking on requeue.voidsetEnqueueTime(long now) The enqueue time, used by the CDQ.voidsetOnFailedReplyJob(Job job) The job enqueued when no reply arrives before expiration.voidsetOnFailedSendJob(Job job) The job enqueued when the message cannot be sent.voidsetOnReplyJob(ReplyJob job) The job enqueued when a reply is detected.voidsetOnSendJob(Job job) The job enqueued when the message is sent.voidsetReplySelector(MessageSelector selector) The selector used to find a reply to this message.voidsetSeqNum(long num) The sequence number, used by the CDPQ.voidsetTransportQueued(long now) When the message entered the transport queue (set by transport send()).voidStamp the message's progress.toString()String representation of this message for debugging.inttransportFailed(String transportStyle) Record a transport that failed to deliver this message, and return how many transports had already failed.
Field Details
_context
The router context._target
The peer the message goes to._message
The message to send._messageTypeId
private final int _messageTypeIdType id of the message._messageId
private final long _messageIdCached message ID, for use after we discard the message._messageSize
private final int _messageSizeSize of the message, in bytes._priority
private final int _prioritySend priority of the message._expiration
private final long _expirationWhen the message is too old to send._onSend
Job run after a successful send._onFailedSend
Job run after a failed send._onReply
Job run when the reply arrives._onFailedReply
Job run when the reply fails._replySelector
Selector matching the expected reply._failedTransports
_sendBegin
private long _sendBeginWhen the send started, 0 until sent._created
private long _createdWhen the message was created._enqueueTime
private long _enqueueTimeWhen the message entered the send pool._transportQueued
private long _transportQueuedWhen the transport took the message._seqNum
private long _seqNumSequence id used to match the reply._shouldTimestamp
private final boolean _shouldTimestampTrue to record the send timing._timestamps
_timestampOrder
PRIORITY_LOWEST
public static final int PRIORITY_LOWESTPriorities, higher is higher priority. Lowest priority.- See Also:
PRIORITY_MEDIUM
PRIORITY_HIGHEST
PRIORITY_BUILD_REPLY
PRIORITY_EXPLORATORY
PRIORITY_PARTICIPATING
PRIORITY_MY_BUILD_REQUEST
public static final int PRIORITY_MY_BUILD_REQUESTMy build request priority.- See Also:
PRIORITY_MY_DATA
PRIORITY_MY_NETDB_LOOKUP
public static final int PRIORITY_MY_NETDB_LOOKUPMy netdb lookup priority.- See Also:
PRIORITY_MY_NETDB_STORE_LOW
public static final int PRIORITY_MY_NETDB_STORE_LOWMy netdb store low priority.- See Also:
PRIORITY_MY_NETDB_STORE
public static final int PRIORITY_MY_NETDB_STOREMy netdb store priority.- See Also:
PRIORITY_NETDB_EXPLORE
PRIORITY_NETDB_FLOOD
PRIORITY_NETDB_HARVEST
PRIORITY_NETDB_REPLY
PRIORITY_HIS_BUILD_REQUEST
public static final int PRIORITY_HIS_BUILD_REQUESTHis build request priority.- See Also:
PRIORITY_HIS_NETDB_STORE
public static final int PRIORITY_HIS_NETDB_STOREHis netdb store priority.- See Also:
Constructor Details
OutNetMessage
Null msg and target, zero expiration (used in OutboundMessageRegistry only).- Parameters:
context- the router context
OutNetMessage
public OutNetMessage(RouterContext context, I2NPMessage msg, long expiration, int priority, RouterInfo target) Standard constructor.- Parameters:
context- the router contextmsg- generally non-nullexpiration- the expiration timepriority- the send priority; higher is sent sooner, 100 (PRIORITY_LOWEST) through 1000 (PRIORITY_HIGHEST)target- generally non-null
Method Details
timestamp
Stamp the message's progress. Only useful if log level is INFO or DEBUG.- Parameters:
eventName- the label this stamp is filed under; reusing a name overwrites its earlier time and appends a duplicate to the order list
locked_initTimestamps
private void locked_initTimestamps()Stamps the message's timing fields.getTarget
Specifies the router to which the message should be delivered. Generally non-null but may be null in special cases.- Returns:
- the target router
getMessage
Specifies the message to be sent. Generally non-null but may be null in special cases.- Returns:
- the I2NP message to be sent, or null for the registry-only placeholder, in which case the message type, ID and size are all zero
getMessageType
getMessageTypeId
public int getMessageTypeId()Message type ID.- Returns:
- the type id, 0 to 31
getMessageId
public long getMessageId()Message ID.- Returns:
- the id to match the reply with
getMessageSize
public int getMessageSize()How large the message is, including the full 16 byte header. Transports with different header sizes should adjust.- Returns:
- the message size
getMessageData
public int getMessageData(byte[] outBuffer) Copies the message data to outbuffer. Used only by VM Comm System.- Parameters:
outBuffer- the buffer to copy to- Returns:
- the length, or -1 if message is null
getPriority
public int getPriority()Specify the priority of the message, where higher numbers are higher priority. Higher priority messages should be delivered before lower priority ones, though some algorithm may be used to avoid starvation.- Specified by:
getPriorityin interfacePQEntry- Returns:
- the delivery priority, one of the
PRIORITY_constants, where higher numbers are delivered first
getExpiration
public long getExpiration()Specify the # ms since the epoch after which if the message has not been sent the OnFailedSend job should be fired and the message should be removed from the pool. If the message has already been sent, this expiration is ignored and the expiration from the ReplySelector is used.- Returns:
- the expiration time
getOnSendJob
After the message is successfully passed to the router specified, the given job is enqueued.- Returns:
- the onSend job
setOnSendJob
The job enqueued when the message is sent.- Parameters:
job- the onSend job
getOnFailedSendJob
If the router could not be reached or the expiration passed, this job is enqueued.- Returns:
- the onFailedSend job
setOnFailedSendJob
The job enqueued when the message cannot be sent.- Parameters:
job- the onFailedSend job
getOnReplyJob
If the MessageSelector detects a reply, this job is enqueued.- Returns:
- the onReply job
setOnReplyJob
The job enqueued when a reply is detected.- Parameters:
job- the onReply job
getOnFailedReplyJob
If the Message selector is specified but it doesn't find a reply before its expiration passes, this job is enqueued.- Returns:
- the onFailedReply job
setOnFailedReplyJob
The job enqueued when no reply arrives before expiration.- Parameters:
job- the onFailedReply job
getReplySelector
Defines a MessageSelector to find a reply to this message.- Returns:
- the reply selector
setReplySelector
The selector used to find a reply to this message.- Parameters:
selector- the reply selector
transportFailed
Record a transport that failed to deliver this message, and return how many transports had already failed.- Parameters:
transportStyle- the transport that failed- Returns:
- the number of previously failed transports
getFailedTransportCount
public int getFailedTransportCount()Number of transports that have failed to deliver this message.- Returns:
- the number of failed transports
getFailedTransports
The transports that have failed to deliver this message.As of 0.9.55, changed from a Set to a List. The list is safe to iterate, format or query while another thread records another failure; what an iteration sees is a snapshot of the failures recorded so far.
- Returns:
- the list of failed transports
getSendBegin
public long getSendBegin()When the sending process began.- Returns:
- the time, in epoch ms
beginSend
public void beginSend()Record the time the send process began.getCreated
public long getCreated()Creation time.- Returns:
- the time, in epoch ms
resetCreatedTime
public void resetCreatedTime()Reset creation time for dispatch age tracking on requeue.getLifetime
public long getLifetime()How long the message has existed.- Returns:
- the age, in ms
getSendTime
public long getSendTime()How long the send has been under way.- Returns:
- the elapsed time, in ms
setEnqueueTime
public void setEnqueueTime(long now) The enqueue time, used by the CDQ.- Specified by:
setEnqueueTimein interfaceCDQEntry- Parameters:
now- the enqueue time
getEnqueueTime
public long getEnqueueTime()The enqueue time, used by the CDQ.- Specified by:
getEnqueueTimein interfaceCDQEntry- Returns:
- the enqueue time
setTransportQueued
public void setTransportQueued(long now) When the message entered the transport queue (set by transport send()).- Parameters:
now- the queue time
getTransportQueued
public long getTransportQueued()When the transport took the message.- Returns:
- the time, in epoch ms
drop
setSeqNum
getSeqNum
discardData
public void discardData()We've done what we need to do with the data from this message, though we may keep the object around for a while to use its ID, jobs, etc.toString
renderTimestamps
Only useful if log level is INFO or DEBUG;locked_initTimestamps()must have been called previously.- Parameters:
buf- the builder the timestamp lines are appended to