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 in `getNextVolley()`. 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 the `InboundMessageFragments`, signaling that we can stop sending a message.

- - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `(package private) static int` | `MAX_VOLLEYS`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `OutboundMessageFragments(RouterContext ctx, UDPTransport transport)`

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `void` | `add(List<OutboundMessageState> states, PeerState peer)` Short circuit the OutNetMessage, letting us send multiple messages reliably and efficiently.
    `void` | `add(OutboundMessageState state, PeerState peer)` Short circuit the OutNetMessage, letting us send the establish complete message reliably.
    `void` | `add(OutNetMessage msg)` Add a new message to the active pool
    `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()`

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Field Detail

    - #### MAX_VOLLEYS

          static final int MAX_VOLLEYS

      See Also:
        Constant Field Values

  - ### Constructor Detail

    - #### OutboundMessageFragments

          public OutboundMessageFragments(RouterContext ctx,
                                          UDPTransport transport)

  - ### Method Detail

    - #### add

          public void add(List<OutboundMessageState> states,
                          PeerState peer)

      Short circuit the OutNetMessage, letting us send multiple messages reliably and efficiently.

    - #### 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(OutNetMessage msg)

      Add a new message to the active pool

    - #### 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

    - #### dropPeer

          void dropPeer(PeerState peer)

    - #### 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.

    - #### shutdown

          public void shutdown()

    - #### startup

          public void startup()