Class MultiPeerUploader

java.lang.Object
com.biglybt.core.networkmanager.impl.RateControlledMultipleEntity
com.biglybt.core.networkmanager.impl.MultiPeerUploader
All Implemented Interfaces:
ControllerAllocationManagement, RateControlledEntity

public class MultiPeerUploader extends RateControlledMultipleEntity
A rate-controlled write entity backed by multiple peer connections, with an emphasis on transmitting packets with full payloads, i.e. it writes to the transport in mss-sized chunks if at all possible. It also employs fair, round-robin write scheduling, where connections each take turns writing a single full packet per round.
  • Field Details

  • Constructor Details

    • MultiPeerUploader

      public MultiPeerUploader(RateHandler rate_handler)
      Create a new packet-filling multi-peer upload entity, rate-controlled by the given handler.
      Parameters:
      rate_handler - listener to handle upload rate limits
  • Method Details

    • getRateHandler

      public RateHandler getRateHandler()
    • getPartitionID

      public int getPartitionID()
      Description copied from interface: RateControlledEntity
      Is ready for a processing op.
      Returns:
      true if it can process >0 bytes, false if not ready
    • flushCheck

      private void flushCheck()
      Checks the connections in the waiting list to see if it's time to be force-flushed.
    • destroy

      public void destroy()
      Destroy this upload entity. Note: Removes all peer connections in the process.
    • addPeerConnection

      public void addPeerConnection(NetworkConnectionBase peer_connection)
      Add the given connection to be managed by this upload entity.
      Parameters:
      peer_connection - to be write managed
    • removePeerConnection

      public boolean removePeerConnection(NetworkConnectionBase peer_connection)
      Remove the given connection from this upload entity.
      Parameters:
      peer_connection - to be removed
      Returns:
      true if the connection was found and removed, false if not removed
    • addToWaitingList

      private void addToWaitingList(NetworkConnectionBase conn)
    • addToReadyList

      void addToReadyList(NetworkConnectionBase conn)
    • write

      private long write(EventWaiter waiter, long num_bytes_to_write, boolean protocol_is_free)
    • getBytesReadyToWrite

      public long getBytesReadyToWrite()
    • getConnectionCount

      public int getConnectionCount(EventWaiter _waiter)
      Description copied from interface: RateControlledEntity
      If there are no connections then the waiter will be kicked when a connection arrives
      Parameters:
      _waiter -
      Returns:
    • getReadyConnectionCount

      public int getReadyConnectionCount(EventWaiter waiter)
      Description copied from interface: RateControlledEntity
      The waiter is kicked if the ready condition changes
      Parameters:
      waiter -
      Returns:
    • canProcess

      public boolean canProcess(EventWaiter waiter)
      ///////////// RateControlledWriteEntity implementation ////////////////////
    • doProcessing

      public long doProcessing(EventWaiter waiter, int max_bytes)
      Description copied from interface: RateControlledEntity
      Attempt to do a processing operation.
      Returns:
      true if >0 bytes were processed (success), false if 0 bytes were processed (failure)
    • getPriority

      public int getPriority()
      Description copied from interface: RateControlledEntity
      Get this entity's priority level.
      Returns:
      priority
    • getPriorityBoost

      public boolean getPriorityBoost()
      Description copied from interface: RateControlledEntity
      stats functions
      Returns:
    • getString

      private String getString(long[] a)
    • getString

      public String getString()