Class MultiPeerUploader
java.lang.Object
com.biglybt.core.networkmanager.impl.RateControlledMultipleEntity
com.biglybt.core.networkmanager.impl.MultiPeerUploader
- All Implemented Interfaces:
ControllerAllocationManagement, 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.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprivate static classDoes this entity have data ready for writing. -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate booleanprivate static final intprivate static final intprivate long(package private) final AEMonitorprivate final intprivate booleanprivate final RateHandlerprivate final LinkedList<NetworkConnectionBase> private final ConcurrentLinkedQueue<NetworkConnectionBase> private EventWaiter(package private) final HashMap<NetworkConnectionBase, MultiPeerUploader.PeerData> Fields inherited from interface ControllerAllocationManagement
UNALLOCATED_PARTITIONFields inherited from interface RateControlledEntity
PRIORITY_HIGH, PRIORITY_NORMAL -
Constructor Summary
ConstructorsConstructorDescriptionMultiPeerUploader(RateHandler rate_handler) Create a new packet-filling multi-peer upload entity, rate-controlled by the given handler. -
Method Summary
Modifier and TypeMethodDescriptionvoidaddPeerConnection(NetworkConnectionBase peer_connection) Add the given connection to be managed by this upload entity.(package private) voidprivate voidbooleancanProcess(EventWaiter waiter) ///////////// RateControlledWriteEntity implementation ////////////////////voiddestroy()Destroy this upload entity.longdoProcessing(EventWaiter waiter, int max_bytes) Attempt to do a processing operation.private voidChecks the connections in the waiting list to see if it's time to be force-flushed.longintgetConnectionCount(EventWaiter _waiter) If there are no connections then the waiter will be kicked when a connection arrivesintIs ready for a processing op.intGet this entity's priority level.booleanstats functionsintgetReadyConnectionCount(EventWaiter waiter) The waiter is kicked if the ready condition changesprivate StringgetString(long[] a) booleanremovePeerConnection(NetworkConnectionBase peer_connection) Remove the given connection from this upload entity.private longwrite(EventWaiter waiter, long num_bytes_to_write, boolean protocol_is_free)
-
Field Details
-
FLUSH_CHECK_LOOP_TIME
private static final int FLUSH_CHECK_LOOP_TIME- See Also:
-
FLUSH_WAIT_TIME
private static final int FLUSH_WAIT_TIME- See Also:
-
partition_id
private final int partition_id- See Also:
-
last_flush_check_time
private long last_flush_check_time -
rate_handler
-
destroyed
private boolean destroyed -
waiting_connections
-
ready_connections
-
lists_lock
-
waiter
-
processing
private volatile boolean processing -
to_deactivate
-
-
Constructor Details
-
MultiPeerUploader
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
-
getPartitionID
public int getPartitionID()Description copied from interface:RateControlledEntityIs 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
Add the given connection to be managed by this upload entity.- Parameters:
peer_connection- to be write managed
-
removePeerConnection
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
-
addToReadyList
-
write
-
getBytesReadyToWrite
public long getBytesReadyToWrite() -
getConnectionCount
Description copied from interface:RateControlledEntityIf there are no connections then the waiter will be kicked when a connection arrives- Parameters:
_waiter-- Returns:
-
getReadyConnectionCount
Description copied from interface:RateControlledEntityThe waiter is kicked if the ready condition changes- Parameters:
waiter-- Returns:
-
canProcess
///////////// RateControlledWriteEntity implementation //////////////////// -
doProcessing
Description copied from interface:RateControlledEntityAttempt 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:RateControlledEntityGet this entity's priority level.- Returns:
- priority
-
getPriorityBoost
public boolean getPriorityBoost()Description copied from interface:RateControlledEntitystats functions- Returns:
-
getString
-
getString
-