com.echomine.net
Class SimpleConnectionThrottler

java.lang.Object
  extended by com.echomine.net.SimpleConnectionThrottler
All Implemented Interfaces:
ConnectionThrottler

public class SimpleConnectionThrottler
extends java.lang.Object
implements ConnectionThrottler

This 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
SimpleConnectionThrottler(int bps_in)
          Constructor that accepts the rate limit in KBytes/sec.
 
Method Summary
 int getBPS()
           
 void setBPS(int bps_in)
           
 void throttle(ConnectionModel cmodel)
          Throttles the data transfer rate based on the information provided by the connection model.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SimpleConnectionThrottler

public SimpleConnectionThrottler(int bps_in)
Constructor that accepts the rate limit in KBytes/sec.

Method Detail

throttle

public void throttle(ConnectionModel cmodel)
Description copied from interface: ConnectionThrottler
Throttles the data transfer rate based on the information provided by the connection model. Most likely you'll be using the calculated transfer rate and do some sort of sleep to slow down the transfer rate.

Specified by:
throttle in interface ConnectionThrottler

getBPS

public int getBPS()

setBPS

public void setBPS(int bps_in)


Copyright © 2001-2005 Echomine. All Rights Reserved.