Class NetworkAdminSpeedTesterBTImpl.TorrentSpeedTestMonitorThread

  • All Implemented Interfaces:
    java.lang.Runnable
    Enclosing class:
    NetworkAdminSpeedTesterBTImpl

    private class NetworkAdminSpeedTesterBTImpl.TorrentSpeedTestMonitorThread
    extends java.lang.Thread
    -------------------- helper class to monitor test. -------------------
    • Nested Class Summary

      • Nested classes/interfaces inherited from class java.lang.Thread

        java.lang.Thread.State, java.lang.Thread.UncaughtExceptionHandler
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      private java.util.Map calculate​(java.util.List history)
      Calculate the avererage and standard deviation for a history.
      (package private) NetworkAdminSpeedTesterResult calculateDownloadRate()
      Based on the previous data cancluate an average and a standard deviation.
      (package private) long checkForNewPeakValue​(DownloadStats stat, long lastTotalDownload, long currTime)
      We set a new "peak" value if it has exceeded the previous peak value by 10%.
      (package private) boolean checkForTestDone()
      In this version the test is limited to MAX_TEST_TIME since the start of the test of MAX_PEAK_TIME (i.e.
      private java.util.List convertSumToDeltas​(java.util.List sumHistory)
      Convert a list of sums into a list of download rates per second.
      private int findIndexPeak​(int numStats)  
      void run()  
      void updateTestProgress​(long currTime, DownloadStats stats)
      Calculate the test progression as a value between 0-100.
      • Methods inherited from class java.lang.Thread

        activeCount, checkAccess, clone, countStackFrames, currentThread, dumpStack, enumerate, getAllStackTraces, getContextClassLoader, getDefaultUncaughtExceptionHandler, getId, getName, getPriority, getStackTrace, getState, getThreadGroup, getUncaughtExceptionHandler, holdsLock, interrupt, interrupted, isAlive, isDaemon, isInterrupted, join, join, join, onSpinWait, resume, setContextClassLoader, setDaemon, setDefaultUncaughtExceptionHandler, setName, setPriority, setUncaughtExceptionHandler, sleep, sleep, start, stop, suspend, toString, yield
      • Methods inherited from class java.lang.Object

        equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
    • Field Detail

      • historyDownloadSpeed

        final java.util.List historyDownloadSpeed
      • historyUploadSpeed

        final java.util.List historyUploadSpeed
      • timestamps

        final java.util.List timestamps
      • testDownload

        final Download testDownload
      • startTime

        long startTime
      • peakTime

        long peakTime
      • peakRate

        long peakRate
    • Constructor Detail

      • TorrentSpeedTestMonitorThread

        public TorrentSpeedTestMonitorThread​(Download d)
    • Method Detail

      • run

        public void run()
        Specified by:
        run in interface java.lang.Runnable
        Overrides:
        run in class java.lang.Thread
      • updateTestProgress

        public void updateTestProgress​(long currTime,
                                       DownloadStats stats)
        Calculate the test progression as a value between 0-100.
        Parameters:
        currTime - - current time as long.
        stats - - Download stats
      • calculate

        private java.util.Map calculate​(java.util.List history)
        Calculate the avererage and standard deviation for a history.
        Parameters:
        history - - List of Long values but that contains the sum downloaded at that time.
        Returns:
        Map with values "ave" and "stddev" set
      • convertSumToDeltas

        private java.util.List convertSumToDeltas​(java.util.List sumHistory)
        Convert a list of sums into a list of download rates per second.
        Parameters:
        sumHistory - - List with download sum for each second.
        Returns:
        - List with the download rate for each second.
      • findIndexPeak

        private int findIndexPeak​(int numStats)
      • calculateDownloadRate

        NetworkAdminSpeedTesterResult calculateDownloadRate()
        Based on the previous data cancluate an average and a standard deviation. Return this data in a Map object.
        Returns:
        Map as a contain for stats. Map keys are "ave" and "dev".
      • checkForTestDone

        boolean checkForTestDone()
        In this version the test is limited to MAX_TEST_TIME since the start of the test of MAX_PEAK_TIME (i.e. time since the peak download rate has been reached). Which ever condition is first will finish the download.
        Returns:
        true if the test done condition has been reached.
      • checkForNewPeakValue

        long checkForNewPeakValue​(DownloadStats stat,
                                  long lastTotalDownload,
                                  long currTime)
        We set a new "peak" value if it has exceeded the previous peak value by 10%.
        Parameters:
        stat - -
        lastTotalDownload - -
        currTime - -
        Returns:
        total downloaded so far.