java.lang.Object
net.i2p.client.streaming.impl.PacketQueue
- All Implemented Interfaces:
Closeable, AutoCloseable, SendMessageStatusListener
Queue out packets to be sent through the session. Well, that's the theory at least... in practice we just send them immediately with no blocking, since the mode=bestEffort doesn't block in the SDK.
MessageOutputStream -> ConnectionDataReceiver -> Connection -> PacketQueue -> I2PSession.
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprivate classCheck for expired message states, without wastefully setting a timer for each.Field Summary
FieldsModifier and TypeFieldDescriptionprivate final ByteCacheCache supplying the packet buffers.private final I2PAppContextThe app context.private booleanTrue once the queue is shut down.private final LogLogger for the packet queue.private final Map<Long, Connection> Connections awaiting status, by message id.private intTimes a duplicate message size was seen.private intSample counters for the per-packet size stats (one per call site).private static final booleanTrue to request the send status callbacks.private static final intTags left before the final packet.private static final intTags sent in the final packet.private static final intFlags of the final tags packet.private static final intFlags of the first tags packet.private static final longLatitude allowed on the I2CP expiration times.private static final intTags sent in the first packet.private static final intTags kept in hand before sending more.private static final longInterval of the expired message cleanup.private static final intWindow share of the tags sent per packet.private static final intRecord every Nth send-size stat sample.Fields inherited from interface SendMessageStatusListener
STATUS_CANCELLEDConstructor Summary
ConstructorsConstructorDescriptionPacketQueue(I2PAppContext context, SimpleTimer2 timer) Opens the log, creates the status map and starts expiring old entries.Method Summary
All MethodsModifier and TypeMethodDescriptionvoidclose()Cannot be restarted.booleanenqueue(PacketLocal packet) Add a new packet to be sent out ASAP.voidmessageStatus(I2PSession session, long msgId, int status) SendMessageStatusListener interface
Field Details
_context
The app context._log
Logger for the packet queue._cache
Cache supplying the packet buffers._messageStatusMap
Connections awaiting status, by message id._dead
private volatile boolean _deadTrue once the queue is shut down.FLAGS_INITIAL_TAGS
private static final int FLAGS_INITIAL_TAGSFlags of the first tags packet.- See Also:
FLAGS_FINAL_TAGS
private static final int FLAGS_FINAL_TAGSFlags of the final tags packet.- See Also:
INITIAL_TAGS_TO_SEND
private static final int INITIAL_TAGS_TO_SENDTags sent in the first packet.- See Also:
MIN_TAG_THRESHOLD
private static final int MIN_TAG_THRESHOLDTags kept in hand before sending more.- See Also:
TAG_WINDOW_FACTOR
private static final int TAG_WINDOW_FACTORWindow share of the tags sent per packet.- See Also:
FINAL_TAGS_TO_SEND
private static final int FINAL_TAGS_TO_SENDTags sent in the final packet.- See Also:
FINAL_TAG_THRESHOLD
private static final int FINAL_TAG_THRESHOLDTags left before the final packet.- See Also:
REMOVE_EXPIRED_TIME
private static final long REMOVE_EXPIRED_TIMEInterval of the expired message cleanup.- See Also:
ENABLE_STATUS_LISTEN
private static final boolean ENABLE_STATUS_LISTENTrue to request the send status callbacks.- See Also:
I2CP_EXPIRATION_ADJUST
private static final long I2CP_EXPIRATION_ADJUSTLatitude allowed on the I2CP expiration times.TELEMETRY_SAMPLE_PERIOD
private static final int TELEMETRY_SAMPLE_PERIODRecord every Nth send-size stat sample. Per-packet RateStat updates lock each period's Rate; these size stats are display-only telemetry, so sampling the aggregate (scaling the recorded value by the period) preserves the graph with a fraction of the monitor traffic.- See Also:
_sendMsgSizeCnt
private int _sendMsgSizeCntSample counters for the per-packet size stats (one per call site)._sendDupMsgSizeCnt
private int _sendDupMsgSizeCntTimes a duplicate message size was seen.
Constructor Details
PacketQueue
Opens the log, creates the status map and starts expiring old entries.- Parameters:
context- the application context, used for loggingtimer- timer used to schedule removal of expired status entries
Method Details
close
public void close()Cannot be restarted.- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceCloseable
enqueue
Add a new packet to be sent out ASAP. This updates the acks. keys and tags disabled since dropped inI2PSession.- Parameters:
packet- the packet to send ahead of the queue, updating the acks- Returns:
- true if sent
messageStatus
SendMessageStatusListener interfaceTell the client of an update in the send status for a message previously sent with
I2PSession.sendMessage(Destination, byte[]). Multiple calls for a single message ID are possible.- Specified by:
messageStatusin interfaceSendMessageStatusListener- Parameters:
session- the session reporting the new status, not otherwise consultedmsgId- message number returned from a previous sendMessage() callstatus- of the message, as defined inMessageStatusMessageand this class.