|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.echomine.net.SimpleTransferRateThrottler
public class SimpleTransferRateThrottler
This transfer rate throttler simply throttles the rate by checking to see if the rate is above the rate limit, and if it is, sleep occurs so that the rate is decreased (since rate is calculated as data transferred over a period of time). The throttling algorithm is to simply sleep and wait for the next checkup. Sleep interval will actually double each time a checkup occurs and the rate is above the limit. Sleep interval will get reset once rate goes below the limit. The problem with this throttler is that if the remote client is sending at an extremely high speed, you will get a massively long interval which may not be what you want.
Also make sure that you don't use this for global throttling. This class is not multi-thread safe and must not be used as a such (ie. controlling throttling limited to a global transfer rate averaged across all the uploads).
Constructor Summary | |
---|---|
SimpleTransferRateThrottler(int bps_in)
Constructor that accepts the rate limit in KBytes/sec. |
Method Summary | |
---|---|
int |
getBPS()
|
void |
setBPS(int bps_in)
|
void |
throttle(FileModel filemodel)
Throttles the transfer rate based on the information provided by the file model. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public SimpleTransferRateThrottler(int bps_in)
Method Detail |
---|
public void throttle(FileModel filemodel)
TransferRateThrottler
throttle
in interface TransferRateThrottler
public int getBPS()
public void setBPS(int bps_in)
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |