Class OutgoingBTHaveMessageAggregator


  • public class OutgoingBTHaveMessageAggregator
    extends java.lang.Object
    Utility class to enable write aggregation of BT Have messages, in order to save bandwidth by not wasting a whole network packet on a single small 9-byte message, and instead pad them onto other messages.
    • Field Detail

      • pending_haves

        private final java.util.ArrayList pending_haves
      • pending_haves_mon

        private final AEMonitor pending_haves_mon
      • bt_have_version

        private byte bt_have_version
      • az_have_version

        private byte az_have_version
      • destroyed

        private boolean destroyed
    • Constructor Detail

      • OutgoingBTHaveMessageAggregator

        public OutgoingBTHaveMessageAggregator​(OutgoingMessageQueue outgoing_message_q,
                                               byte _bt_have_version,
                                               byte _az_have_version)
        Create a new aggregator, which will send messages out the given queue.
        Parameters:
        outgoing_message_q -
    • Method Detail

      • setHaveVersion

        public void setHaveVersion​(byte bt_version,
                                   byte az_version)
      • queueHaveMessage

        public void queueHaveMessage​(int piece_number,
                                     boolean force)
        Queue a new have message for aggregated sending.
        Parameters:
        piece_number - of the have message
        force - if true, send this and any other pending haves right away
      • destroy

        public void destroy()
        Destroy the aggregator, along with any pending messages.
      • forceSendOfPending

        public void forceSendOfPending()
        Force send of any aggregated/pending have messages.
      • hasPending

        public boolean hasPending()
        Are there Haves messages pending?
        Returns:
        true if there are any unsent haves, false otherwise
      • sendPendingHaves

        private void sendPendingHaves()