FileDocCategorySizeDatePackage
TransferMode.javaAPI DocAzureus 3.0.3.44578Fri Jul 06 16:35:40 BST 2007com.aelitis.azureus.core.speedmanager.impl.v2

TransferMode

public class TransferMode extends Object
Is the application in a "download" mode? Or is it in a "seeding" mode? This is used to determine up we cut back on upload bandwidth limit. Here is how to determine the mode. If the download rate is LOW compared to the capacity for five minutes continously then it will be considered in a SEEDING mode. If the download bandwidth ever goes into the MED range then it switches to DOWNLOADING mode immediately. The application will favor DOWNLOADING mode to SEEDING mode.

Fields Summary
private State
mode
private long
lastTimeDownloadDetected
private static final long
WAIT_TIME_FOR_SEEDING_MODE
Constructors Summary
public TransferMode()




     
    

    
Methods Summary
public com.aelitis.azureus.core.speedmanager.impl.v2.TransferMode$StategetMode()

        return mode;
    
public java.lang.StringgetString()

        return mode.getString();
    
public booleanisConfTestingLimits()
We have two types of limit testing. If we are doing a "confidence test" for the limits then return true. This mode is putting one value at the min setting and the other at unlimited.

return
- true if doing a "conf test of the limits"

        return ( mode==State.DOWNLOAD_LIMIT_SEARCH || mode==State.UPLOAD_LIMIT_SEARCH );
    
public booleanisDownloadMode()
Are we in downloading mode?

return
- boolean - true if in downloading mode. Otherwise false.


        return ( mode==State.DOWNLOADING );

    
public voidsetMode(com.aelitis.azureus.core.speedmanager.impl.v2.TransferMode$State newMode)


        SpeedManagerLogger.trace( " setting transfer mode to: "+newMode.getString() );

        mode = newMode;
    
public voidupdateStatus(SaturatedMode downloadBandwidth)
If the download bandwidth is ever in MED or above switch immediately to DOWNLOADING mode. If th download bandwidth is LOW or less for more then 5 min, switch to SEEDING mode.

param
downloadBandwidth - current download status.


        //this setting have no effect while testing the limits.
        if( isConfTestingLimits() ){
            if( mode==State.DOWNLOAD_LIMIT_SEARCH ){
                lastTimeDownloadDetected = SystemTime.getCurrentTime();
            }
            return;
        }

        if( downloadBandwidth.compareTo(SaturatedMode.LOW)<=0 ){
            //we don't seem to be downloading at the moment.
            //see if this state has persisted for more then five minutes.
            long time = SystemTime.getCurrentTime();

            if( time > lastTimeDownloadDetected+WAIT_TIME_FOR_SEEDING_MODE ){
                mode = State.SEEDING;
            }

        }else{
            //Some downloading is happening. Remove from SEEDING mode.
            mode = State.DOWNLOADING;
            lastTimeDownloadDetected = SystemTime.getCurrentTime();      
        }