com.aelitis.azureus.core.networkmanager.impl
Class MultiPeerUploader

java.lang.Object
  extended by com.aelitis.azureus.core.networkmanager.impl.MultiPeerUploader
All Implemented Interfaces:
RateControlledEntity

public class MultiPeerUploader
extends Object
implements RateControlledEntity

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 Summary
 
Fields inherited from interface com.aelitis.azureus.core.networkmanager.impl.RateControlledEntity
PRIORITY_HIGH, PRIORITY_NORMAL
 
Constructor Summary
MultiPeerUploader(RateHandler rate_handler)
          Create a new packet-filling multi-peer upload entity, rate-controlled by the given handler.
 
Method Summary
 void addPeerConnection(NetworkConnectionBase peer_connection)
          Add the given connection to be managed by this upload entity.
 boolean canProcess(EventWaiter waiter)
          Is ready for a processing op.
 void destroy()
          Destroy this upload entity.
 int doProcessing(EventWaiter waiter, int max_bytes)
          Attempt to do a processing operation.
 long getBytesReadyToWrite()
           
 int getConnectionCount(EventWaiter _waiter)
          If there are no connections then the waiter will be kicked when a connection arrives
 int getPriority()
          Get this entity's priority level.
 boolean getPriorityBoost()
          stats functions
 RateHandler getRateHandler()
           
 int getReadyConnectionCount(EventWaiter waiter)
          The waiter is kicked if the ready condition changes
 String getString()
           
 boolean removePeerConnection(NetworkConnectionBase peer_connection)
          Remove the given connection from this upload entity.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

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 Detail

getRateHandler

public RateHandler getRateHandler()
Specified by:
getRateHandler in interface RateControlledEntity

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

getBytesReadyToWrite

public long getBytesReadyToWrite()
Specified by:
getBytesReadyToWrite in interface RateControlledEntity

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

Specified by:
getConnectionCount in interface RateControlledEntity
Returns:

getReadyConnectionCount

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

Specified by:
getReadyConnectionCount in interface RateControlledEntity
Returns:

canProcess

public boolean canProcess(EventWaiter waiter)
Description copied from interface: RateControlledEntity
Is ready for a processing op.

Specified by:
canProcess in interface RateControlledEntity
Returns:
true if it can process >0 bytes, false if not ready

doProcessing

public int doProcessing(EventWaiter waiter,
                        int max_bytes)
Description copied from interface: RateControlledEntity
Attempt to do a processing operation.

Specified by:
doProcessing in interface RateControlledEntity
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.

Specified by:
getPriority in interface RateControlledEntity
Returns:
priority

getPriorityBoost

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

Specified by:
getPriorityBoost in interface RateControlledEntity
Returns:

getString

public String getString()
Specified by:
getString in interface RateControlledEntity