Class TransferProcessor
- java.lang.Object
-
- com.biglybt.core.networkmanager.impl.TransferProcessor
-
public class TransferProcessor extends java.lang.Object
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description private static class
TransferProcessor.ConnectionData
private static class
TransferProcessor.GroupData
-
Field Summary
Fields Modifier and Type Field Description private java.util.HashMap<NetworkConnectionBase,TransferProcessor.ConnectionData>
connections
(package private) AEMonitor
connections_mon
private java.util.HashMap<LimitedRateGroup,TransferProcessor.GroupData>
group_buckets
(package private) ByteBucket
main_bucket
private EntityHandler
main_controller
private RateHandler
main_rate_handler
(package private) LimitedRateGroup
max_rate
private boolean
multi_threaded
(package private) int
processor_type
(package private) static boolean
RATE_LIMIT_DOWN_INCLUDES_PROTOCOL
private static boolean
RATE_LIMIT_LAN_TOO
(package private) static boolean
RATE_LIMIT_UP_INCLUDES_PROTOCOL
static int
TYPE_DOWNLOAD
static int
TYPE_UPLOAD
-
Constructor Summary
Constructors Constructor Description TransferProcessor(NetworkManager net_man, int _processor_type, LimitedRateGroup max_rate_limit, boolean multi_threaded)
Create new transfer processor for the given read/write type, limited to the given max rate.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addRateLimiter(NetworkConnectionBase connection, LimitedRateGroup group)
private ByteBucket
createBucket(int bytes_per_sec)
boolean
deregisterPeerConnection(NetworkConnectionBase connection)
Cancel upload handling for the given peer connection.void
downgradePeerConnection(NetworkConnectionBase connection)
Downgrade the given connection back to a normal-speed transfer handler.java.util.List<NetworkConnectionBase>
getConnections()
RateHandler
getRateHandler()
RateHandler
getRateHandler(NetworkConnectionBase connection)
boolean
isRegistered(NetworkConnectionBase connection)
void
registerPeerConnection(NetworkConnectionBase connection, boolean upload)
Register peer connection for upload handling.void
removeRateLimiter(NetworkConnectionBase connection, LimitedRateGroup group)
void
setRateLimiterFreezeState(boolean frozen)
void
upgradePeerConnection(NetworkConnectionBase connection, int partition_id)
Upgrade the given connection to a high-speed transfer handler.
-
-
-
Field Detail
-
RATE_LIMIT_LAN_TOO
private static final boolean RATE_LIMIT_LAN_TOO
- See Also:
- Constant Field Values
-
RATE_LIMIT_UP_INCLUDES_PROTOCOL
static boolean RATE_LIMIT_UP_INCLUDES_PROTOCOL
-
RATE_LIMIT_DOWN_INCLUDES_PROTOCOL
static boolean RATE_LIMIT_DOWN_INCLUDES_PROTOCOL
-
TYPE_UPLOAD
public static final int TYPE_UPLOAD
- See Also:
- Constant Field Values
-
TYPE_DOWNLOAD
public static final int TYPE_DOWNLOAD
- See Also:
- Constant Field Values
-
processor_type
final int processor_type
-
max_rate
final LimitedRateGroup max_rate
-
main_rate_handler
private final RateHandler main_rate_handler
-
main_bucket
final ByteBucket main_bucket
-
main_controller
private final EntityHandler main_controller
-
group_buckets
private final java.util.HashMap<LimitedRateGroup,TransferProcessor.GroupData> group_buckets
-
connections
private final java.util.HashMap<NetworkConnectionBase,TransferProcessor.ConnectionData> connections
-
connections_mon
final AEMonitor connections_mon
-
multi_threaded
private final boolean multi_threaded
-
-
Constructor Detail
-
TransferProcessor
public TransferProcessor(NetworkManager net_man, int _processor_type, LimitedRateGroup max_rate_limit, boolean multi_threaded)
Create new transfer processor for the given read/write type, limited to the given max rate.- Parameters:
processor_type
- read or write processormax_rate_limit
- to use
-
-
Method Detail
-
registerPeerConnection
public void registerPeerConnection(NetworkConnectionBase connection, boolean upload)
Register peer connection for upload handling. NOTE: The given max rate limit is ignored until the connection is upgraded.- Parameters:
connection
- to registergroup
- rate limit group
-
getConnections
public java.util.List<NetworkConnectionBase> getConnections()
-
isRegistered
public boolean isRegistered(NetworkConnectionBase connection)
-
deregisterPeerConnection
public boolean deregisterPeerConnection(NetworkConnectionBase connection)
Cancel upload handling for the given peer connection.- Parameters:
connection
- to cancel
-
setRateLimiterFreezeState
public void setRateLimiterFreezeState(boolean frozen)
-
addRateLimiter
public void addRateLimiter(NetworkConnectionBase connection, LimitedRateGroup group)
-
removeRateLimiter
public void removeRateLimiter(NetworkConnectionBase connection, LimitedRateGroup group)
-
upgradePeerConnection
public void upgradePeerConnection(NetworkConnectionBase connection, int partition_id)
Upgrade the given connection to a high-speed transfer handler.- Parameters:
connection
- to upgrade
-
downgradePeerConnection
public void downgradePeerConnection(NetworkConnectionBase connection)
Downgrade the given connection back to a normal-speed transfer handler.- Parameters:
connection
- to downgrade
-
getRateHandler
public RateHandler getRateHandler()
-
getRateHandler
public RateHandler getRateHandler(NetworkConnectionBase connection)
-
createBucket
private ByteBucket createBucket(int bytes_per_sec)
-
-