Class PingSourceManager
- java.lang.Object
-
- com.biglybt.core.speedmanager.impl.v2.PingSourceManager
-
public class PingSourceManager extends java.lang.Object
This class manage cycling though the PingSources. It keep track of PingSource stats and applies rules on if/when to cycle though a ping-source. #1) If the slowest ping-source is 10x the the best for a 1 min average. kick it. #2) If a ping-source is slower then two combined sources (2x) for a 5 min average. then kick it. #3) Every 30 minutes kick the slowest ping source and request a new one. Just to keep things fresh. Also maintain logic do determine if a new source is better then the previous one. (To determine if these rules lead to good data.)
-
-
Field Summary
Fields Modifier and Type Field Description private long
lastPingRemoval
private java.util.Map
pingAverages
private static long
TIME_BETWEEN_BAD_PING_REMOVALS
private static long
TIME_BETWEEN_FORCED_CYCLE_REMOVALS
private static long
TIME_BETWEEN_SLOW_PING_REMOVALS
-
Constructor Summary
Constructors Constructor Description PingSourceManager()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addPingTime(SpeedManagerPingSource source)
private boolean
checkForBadPing(SpeedManagerPingSource[] sources)
If the slowest ping in 10x the fastest then remove it.private boolean
checkForSlowSource(SpeedManagerPingSource[] sources)
A slow source is something that is 2x the slower then the two fastest.void
checkPingSources(SpeedManagerPingSource[] sources)
Determine if we should drop any ping sources.private boolean
forcePingSourceChange(SpeedManagerPingSource[] sources)
If one ping source is twice the fastest then replace it.void
pingSourceFailed(SpeedManagerPingSource source)
void
pingSourceFound(SpeedManagerPingSource source, boolean is_replacement)
private void
resetTimer()
After a ping-source has been removed, need to resetTimer the timer.
-
-
-
Field Detail
-
pingAverages
private final java.util.Map pingAverages
-
lastPingRemoval
private long lastPingRemoval
-
TIME_BETWEEN_BAD_PING_REMOVALS
private static final long TIME_BETWEEN_BAD_PING_REMOVALS
- See Also:
- Constant Field Values
-
TIME_BETWEEN_SLOW_PING_REMOVALS
private static final long TIME_BETWEEN_SLOW_PING_REMOVALS
- See Also:
- Constant Field Values
-
TIME_BETWEEN_FORCED_CYCLE_REMOVALS
private static final long TIME_BETWEEN_FORCED_CYCLE_REMOVALS
- See Also:
- Constant Field Values
-
-
Method Detail
-
checkPingSources
public void checkPingSources(SpeedManagerPingSource[] sources)
Determine if we should drop any ping sources. Sort them, if one significantly higher then the other two. then drop it.- Parameters:
sources
- - SpeedManagerPingSource[] inputs
-
forcePingSourceChange
private boolean forcePingSourceChange(SpeedManagerPingSource[] sources)
If one ping source is twice the fastest then replace it. Otherwise reset the timer.- Parameters:
sources
- -- Returns:
- - true is a souce has been changed.
-
checkForSlowSource
private boolean checkForSlowSource(SpeedManagerPingSource[] sources)
A slow source is something that is 2x the slower then the two fastest.- Parameters:
sources
- -- Returns:
- - true is a source has been removed.
-
checkForBadPing
private boolean checkForBadPing(SpeedManagerPingSource[] sources)
If the slowest ping in 10x the fastest then remove it.- Parameters:
sources
- -- Returns:
- - true is a source has been removed.
-
pingSourceFound
public void pingSourceFound(SpeedManagerPingSource source, boolean is_replacement)
-
pingSourceFailed
public void pingSourceFailed(SpeedManagerPingSource source)
-
addPingTime
public void addPingTime(SpeedManagerPingSource source)
-
resetTimer
private void resetTimer()
After a ping-source has been removed, need to resetTimer the timer.
-
-