Package com.aelitis.azureus.core.speedmanager

Examples of com.aelitis.azureus.core.speedmanager.SpeedManagerPingSource


        if(sources.length<3){
            return false;
        }

        //just find the slowest ping-source and remove it.
        SpeedManagerPingSource slowestSource = null;
        double slowestPing = 0.0;
        double fastestPing = 10000.0;

        int len = sources.length;
        for(int i=0; i<len; i++){
            PingSourceStats pss = (PingSourceStats) pingAverages.get(sources[i]);
            Average ave = pss.getHistory();
            double pingTime = ave.getAverage();

            //find slowest
            if( pingTime>slowestPing ){
                slowestPing = pingTime;
                slowestSource=sources[i];
            }

            //find sped of fastest.
            if( pingTime<fastestPing ){
                fastestPing = pingTime;
            }

        }//for

        //regardless of result, resetTimer the timer.
        resetTimer();
        //only replace the slowest if it is twice the fastest.
        if( slowestPing > 2*fastestPing ){
            if(slowestSource!=null){
                slowestSource.destroy();
                return true;
            }
        }

        return false;
View Full Code Here


        long currTime = SystemTime.getCurrentTime();
        if( currTime<lastPingRemoval+ TIME_BETWEEN_SLOW_PING_REMOVALS){
            return false;
        }

        SpeedManagerPingSource slowestSource = null;
        if( sources.length<3 ){
            return false;
        }

        double fastA = 10000.0;
        double fastB = 10000.0;
        double slowest = 0.0;
        int len = sources.length;
        for(int i=0; i<len; i++){
            PingSourceStats pss = (PingSourceStats) pingAverages.get(sources[i]);
            Average ave = pss.getHistory();
            double pingTime = ave.getAverage();

            //determine fastest or second fastest.
            if(pingTime<fastA){
                fastB=fastA;
                fastA=pingTime;
            }else if(pingTime<fastB){
                fastB=pingTime;
            }

            //determine slowest.
            if(pingTime>slowest){
                slowest = pingTime;
                slowestSource = sources[i];
                resetTimer();
            }
        }//for

        double sumFastest = fastA+fastB;

        boolean removedSource = false;
        if( sumFastest*2 < slowest ){
            //destroy this source. It is a bit too slow.
            if(slowestSource!=null){
                slowestSource.destroy();
                SpeedManagerLogger.log("dropping ping source: "+slowestSource.getAddress()+" for being 2x slower then two fastest.");
                removedSource = true;
                resetTimer();
            }
        }//if

View Full Code Here

        if( currTime<lastPingRemoval+ TIME_BETWEEN_BAD_PING_REMOVALS){
            return false;
        }

        double highestLongTermPing=0.0;
        SpeedManagerPingSource highestSource=null;
        double lowestLongTermPing=10000.0;

        int len = sources.length;
        for(int i=0; i<len; i++){
            PingSourceStats pss = (PingSourceStats) pingAverages.get(sources[i]);
           
            if ( pss == null ){
              continue;
            }
            Average a = pss.getLongTermAve();
            double avePingTime = a.getAverage();

            //is this a new highest value?
            if( avePingTime>highestLongTermPing ){
                highestLongTermPing = avePingTime;
                highestSource = sources[i];
            }

            //is this a new lowest value?
            if( avePingTime<lowestLongTermPing ){
                lowestLongTermPing = avePingTime;
            }
        }//for

        boolean removedSource = false;
        //if the highest value is 8x the lowest then find another source.
        if( lowestLongTermPing*8 < highestLongTermPing ){
            //remove the slow source we will get a new one to replace it.
            if( highestSource!=null ){
                SpeedManagerLogger.log("dropping ping source: "+highestSource.getAddress()+" for being 8x greater then min source.");
                highestSource.destroy();
                removedSource = true;
                resetTimer();
            }
        }//if

View Full Code Here

  public void periodicUpdate() {
    if (speedManager == null) {
      return;
    }
    if(speedManager.isAvailable()){// && speedManager.isEnabled()) {
      SpeedManagerPingSource sources[] = speedManager.getPingSources();
      if(sources.length > 0) {
        int[] pings = new int[sources.length];
        for(int i = 0 ; i < sources.length ; i++) {
          pings[i] = sources[i].getPingTime();
        }
View Full Code Here

TOP

Related Classes of com.aelitis.azureus.core.speedmanager.SpeedManagerPingSource

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.