- All Known Implementing Classes:
BandwidthManager, Peer, PeerCoordinator, WebPeer
public interface BandwidthListener
Bandwidth and bandwidth limits.
Maintain three bandwidth estimators: Sent, received, and requested.
Method Summary
All MethodsModifier and TypeMethodDescriptionvoiddownloaded(int size) Called when bytes are unconditionally received.longReturns the current download bandwidth limit in bytes per second.longReturns the average download rate in bytes per second.longReturns the current upload bandwidth limit in bytes per second.longReturns the average upload rate in bytes per second.booleanChecks if the current download bandwidth is over the limit.booleanChecks if the current upload bandwidth is over the limit.booleanshouldRequest(Peer peer, int size) Checks if we should request the given number of bytes from a peer.booleanshouldSend(int size) Checks if we should send the given number of bytes.voiduploaded(int size) Called when bytes are unconditionally sent.
Method Details
getUploadRate
long getUploadRate()Returns the average upload rate in bytes per second.- Returns:
- the average upload rate in Bps
getDownloadRate
long getDownloadRate()Returns the average download rate in bytes per second.- Returns:
- the average download rate in Bps
uploaded
void uploaded(int size) Called when bytes are unconditionally sent.- Parameters:
size- the number of bytes sent
downloaded
void downloaded(int size) Called when bytes are unconditionally received.- Parameters:
size- the number of bytes received
shouldSend
boolean shouldSend(int size) Checks if we should send the given number of bytes. Do NOT calluploaded(int)if this returns true.- Parameters:
size- the number of bytes to send- Returns:
- true if the bytes should be sent, false otherwise
shouldRequest
Checks if we should request the given number of bytes from a peer.- Parameters:
peer- the peer the bytes would be requested fromsize- the number of bytes to request- Returns:
- true if the request should be made, false otherwise
getUpBWLimit
long getUpBWLimit()Returns the current upload bandwidth limit in bytes per second.- Returns:
- the upload limit in Bps
getDownBWLimit
long getDownBWLimit()Returns the current download bandwidth limit in bytes per second.- Returns:
- the download limit in Bps
overUpBWLimit
boolean overUpBWLimit()Checks if the current upload bandwidth is over the limit.- Returns:
- true if over the upload limit, false otherwise
overDownBWLimit
boolean overDownBWLimit()Checks if the current download bandwidth is over the limit.- Returns:
- true if over the download limit, false otherwise