Package net.i2p.router.transport.udp
Class OutboundMessageFragments
- java.lang.Object
-
- net.i2p.router.transport.udp.OutboundMessageFragments
-
class OutboundMessageFragments extends Object
Coordinate the outbound fragments and select the next one to be built. This pool contains messages we are actively trying to send, essentially doing a round robin across each message to send one fragment, as implemented ingetNextVolley()
. This also honors per-peer throttling, taking note of each peer's allocations. If a message has each of its fragments sent more than a certain number of times, it is failed out. In addition, this instance also receives notification of message ACKs from theInboundMessageFragments
, signaling that we can stop sending a message.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static interface
OutboundMessageFragments.ActiveThrottle
throttle
-
Field Summary
Fields Modifier and Type Field Description (package private) static int
MAX_VOLLEYS
if we can handle more messages explicitly, set this to true
-
Constructor Summary
Constructors Constructor Description OutboundMessageFragments(RouterContext ctx, UDPTransport transport, OutboundMessageFragments.ActiveThrottle throttle)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
add(List<OutboundMessageState> states, PeerState peer)
Short circuit the OutNetMessage, letting us send multiple messages reliably and efficiently.void
add(OutNetMessage msg)
Add a new message to the active poolvoid
add(OutboundMessageState state, PeerState peer)
Short circuit the OutNetMessage, letting us send the establish complete message reliably.void
add(PeerState peer, int size)
Add the peer to the list of peers wanting to transmit something.(package private) void
dropPeer(PeerState peer)
List<UDPPacket>
getNextVolley()
Fetch all the packets for a message volley, blocking until there is a message which can be fully transmitted (or the transport is shut down).(package private) void
nudge()
Wakes up the packet pusher thread.void
shutdown()
void
startup()
boolean
waitForMoreAllowed()
Block until we allow more messages to be admitted to the active pool.
-
-
-
Field Detail
-
MAX_VOLLEYS
static final int MAX_VOLLEYS
if we can handle more messages explicitly, set this to true- See Also:
- Constant Field Values
-
-
Constructor Detail
-
OutboundMessageFragments
public OutboundMessageFragments(RouterContext ctx, UDPTransport transport, OutboundMessageFragments.ActiveThrottle throttle)
-
-
Method Detail
-
startup
public void startup()
-
shutdown
public void shutdown()
-
dropPeer
void dropPeer(PeerState peer)
-
waitForMoreAllowed
public boolean waitForMoreAllowed()
Block until we allow more messages to be admitted to the active pool. This is called by theOutboundRefiller
- Returns:
- true if more messages are allowed
-
add
public void add(OutNetMessage msg)
Add a new message to the active pool
-
add
public void add(OutboundMessageState state, PeerState peer)
Short circuit the OutNetMessage, letting us send the establish complete message reliably. If you have multiple messages, use the list variant, so the messages may be bundled efficiently.
-
add
public void add(List<OutboundMessageState> states, PeerState peer)
Short circuit the OutNetMessage, letting us send multiple messages reliably and efficiently.- Since:
- 0.9.24
-
add
public void add(PeerState peer, int size)
Add the peer to the list of peers wanting to transmit something. This wakes up the packet pusher if it is sleeping. Avoid synchronization where possible. There are small chances of races. There are larger chances of adding the PeerState "behind" where the iterator is now... but these issues are the same as before concurrentification.- Parameters:
size
- the minimum size we can send, or 0 to always notify- Since:
- 0.8.9
-
getNextVolley
public List<UDPPacket> getNextVolley()
Fetch all the packets for a message volley, blocking until there is a message which can be fully transmitted (or the transport is shut down). NOT thread-safe. Called by the PacketPusher thread only.- Returns:
- null only on shutdown
-
nudge
void nudge()
Wakes up the packet pusher thread.- Since:
- 0.9.48
-
-