java.lang.Object
net.i2p.router.transport.udp.InboundMessageFragments
Organize the received data message fragments, feeding completed messages to the
MessageReceiver and telling the PeerState to ACK. In addition, it drops failed fragments and keeps a minimal list of the most recently completed messages (even though higher up in the router we have full blown replay detection, its nice to have a basic line of defense here).Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classModifiable Long, no locking.Field Summary
FieldsModifier and TypeFieldDescriptionprivate booleanFalse once the job has been cancelled.private final RouterContextThe router receiving the datagrams.private final MessageReceiverWhere complete messages are handed on.private DecayingBloomFilterList of message IDs recently received, so we can ignore in flight dups.private final UDPTransportThe transport the datagrams arrived on.private static final intDecay the recently completed every 10 seconds.Constructor Summary
ConstructorsConstructorDescriptionInboundMessageFragments(RouterContext ctx, OutboundMessageFragments outbound, UDPTransport transport) Creates the message receiver and registers the fragment reassembly stats.Method Summary
Public MethodsModifier and TypeMethodDescription(package private) voidDynamically adjust MessageReceiver thread count to match the target.(package private) doubleMessage receiver pool utilization as a ratio (0.0-1.0).(package private) intReturns the maximum capacity of the message receiver queue.(package private) intReturns the current queue depth of the message receiver.booleanisAlive()Whether the receiver is alive.booleanmessageReceived(long messageID) This message was received - SSU 2 only.voidshutdown()Shut down the receiver and duplicate filter.voidstartup()Start the receiver and duplicate filter.booleanwasRecentlyReceived(long messageID) Was this message recently received? SSU 2 only.
Field Details
_context
The router receiving the datagrams._recentlyCompletedMessages
List of message IDs recently received, so we can ignore in flight dups._transport
The transport the datagrams arrived on._messageReceiver
Where complete messages are handed on._alive
private volatile boolean _aliveFalse once the job has been cancelled.DECAY_PERIOD
private static final int DECAY_PERIODDecay the recently completed every 10 seconds.- See Also:
Constructor Details
InboundMessageFragments
public InboundMessageFragments(RouterContext ctx, OutboundMessageFragments outbound, UDPTransport transport) Creates the message receiver and registers the fragment reassembly stats.- Parameters:
ctx- our router contextoutbound- the outbound fragment pool to hand completed messages totransport- the UDP transport this receiver belongs to
Method Details
startup
public void startup()Start the receiver and duplicate filter.shutdown
public void shutdown()Shut down the receiver and duplicate filter.isAlive
adjustMessageReceiverThreads
void adjustMessageReceiverThreads()Dynamically adjust MessageReceiver thread count to match the target.getReceiverQueueSize
int getReceiverQueueSize()Returns the current queue depth of the message receiver.- Returns:
- the number of messages currently queued for processing
getReceiverQueueCapacity
int getReceiverQueueCapacity()Returns the maximum capacity of the message receiver queue.- Returns:
- the queue size at which incoming messages are dropped
getMessageReceiverUtilization
double getMessageReceiverUtilization()Message receiver pool utilization as a ratio (0.0-1.0).- Returns:
- queued messages as a fraction of the queue capacity
messageReceived
public boolean messageReceived(long messageID) This message was received - SSU 2 only. No stats updated here, caller should handle stats.- Parameters:
messageID- message identifier added to the recently-completed bloom filter- Returns:
- true if this message was a duplicate
wasRecentlyReceived
public boolean wasRecentlyReceived(long messageID) Was this message recently received? SSU 2 only. No stats updated here, caller should handle stats.- Parameters:
messageID- message identifier tested against the recently-completed bloom filter- Returns:
- true if this message was recently received.