/** * Sets whether or not this throttle is switching bandwidth on/off. */ public void setSwitching(boolean switching) { log.debug("setSwitching:" + switching); if(this.switching != switching) { fixBytesPerTick(switching); } this.switching = switching; }
/** * Sets the throttle to the given throttle rate. The default windows size * T is used. The bytes per windows N is calculated from bytesPerSecond. * * @param bytesPerSecond the limits in bytes (not bits!) per second * (not milliseconds!) */ public void setRate(float bytesPerSecond) { if(bytesPerSecond < 0) { rate = UNLIMITED; } else { if(log.isDebugEnabled()) { log.debug(String.format("Set rate to %s bytes per second", bytesPerSecond)); } rate = bytesPerSecond; bytesPerTick = (int) (bytesPerSecond / TICKS_PER_SECOND); } if(switching) { this.fixBytesPerTick(true); } }