Class NetworkAdminSpeedTestScheduledTestImpl
- java.lang.Object
-
- com.biglybt.core.networkmanager.admin.impl.NetworkAdminSpeedTestScheduledTestImpl
-
- All Implemented Interfaces:
NetworkAdminSpeedTestScheduledTest
public class NetworkAdminSpeedTestScheduledTestImpl extends java.lang.Object implements NetworkAdminSpeedTestScheduledTest
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description (package private) class
NetworkAdminSpeedTestScheduledTestImpl.SpeedTestDownloadState
Preservers the state of all the downloads before the speed test started.
-
Field Summary
Fields Modifier and Type Field Description (package private) boolean
aborted
private byte[]
challenge_id
private static long
CHALLENGE_REPLY
(package private) long
delay_millis
private java.lang.String
detectedRouter
private CopyOnWriteList
listeners
(package private) long
max_speed
(package private) PluginInterface
plugin
private NetworkAdminSpeedTestScheduledTestImpl.SpeedTestDownloadState
preTestSettings
private static long
REQUEST_TEST
private static long
TEST_RESULT
(package private) TOTorrent
test_torrent
(package private) NetworkAdminSpeedTesterImpl
tester
private static int
ZERO_DOWNLOAD_SETTING
-
Constructor Summary
Constructors Modifier Constructor Description protected
NetworkAdminSpeedTestScheduledTestImpl(PluginInterface _plugin, NetworkAdminSpeedTesterImpl _tester)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
abort()
void
abort(java.lang.String reason)
void
addListener(NetworkAdminSpeedTestScheduledTestListener listener)
private java.util.Map
getBEncodedMapFromRequest(java.net.URL url)
Read from URL and return byte array.long
getMaxDownBytePerSec()
long
getMaxUpBytePerSec()
These are the limits up to which the test can run, not the result of the testNetworkAdminSpeedTester
getTester()
private java.lang.String
getVersionFromJAR(java.io.File jar_file)
private java.util.Map
handleChallengeFromSpeedTestService(java.io.File jar_file, java.util.Map result)
void
removeListener(NetworkAdminSpeedTestScheduledTestListener listener)
protected void
reportComplete()
protected void
reportStage(java.lang.String str)
protected void
resetSpeedLimits()
Restore all the downloads the state before the speed test started.private boolean
schedule()
Request a test from the speed testing service, handle the "challenge" if request and then get the id for the test.private java.util.Map
sendRequest(java.util.Map request)
(package private) void
sendResult(NetworkAdminSpeedTesterResult result)
protected void
setSpeedLimits()
Preserve all the data about the downloads while the test is running.boolean
start()
-
-
-
Field Detail
-
REQUEST_TEST
private static final long REQUEST_TEST
- See Also:
- Constant Field Values
-
CHALLENGE_REPLY
private static final long CHALLENGE_REPLY
- See Also:
- Constant Field Values
-
TEST_RESULT
private static final long TEST_RESULT
- See Also:
- Constant Field Values
-
ZERO_DOWNLOAD_SETTING
private static final int ZERO_DOWNLOAD_SETTING
- See Also:
- Constant Field Values
-
plugin
final PluginInterface plugin
-
tester
final NetworkAdminSpeedTesterImpl tester
-
detectedRouter
private java.lang.String detectedRouter
-
preTestSettings
private NetworkAdminSpeedTestScheduledTestImpl.SpeedTestDownloadState preTestSettings
-
challenge_id
private byte[] challenge_id
-
delay_millis
long delay_millis
-
max_speed
long max_speed
-
test_torrent
TOTorrent test_torrent
-
aborted
volatile boolean aborted
-
listeners
private final CopyOnWriteList listeners
-
-
Constructor Detail
-
NetworkAdminSpeedTestScheduledTestImpl
protected NetworkAdminSpeedTestScheduledTestImpl(PluginInterface _plugin, NetworkAdminSpeedTesterImpl _tester)
-
-
Method Detail
-
getTester
public NetworkAdminSpeedTester getTester()
- Specified by:
getTester
in interfaceNetworkAdminSpeedTestScheduledTest
-
getMaxUpBytePerSec
public long getMaxUpBytePerSec()
Description copied from interface:NetworkAdminSpeedTestScheduledTest
These are the limits up to which the test can run, not the result of the test- Specified by:
getMaxUpBytePerSec
in interfaceNetworkAdminSpeedTestScheduledTest
- Returns:
-
getMaxDownBytePerSec
public long getMaxDownBytePerSec()
- Specified by:
getMaxDownBytePerSec
in interfaceNetworkAdminSpeedTestScheduledTest
-
start
public boolean start()
- Specified by:
start
in interfaceNetworkAdminSpeedTestScheduledTest
-
abort
public void abort()
- Specified by:
abort
in interfaceNetworkAdminSpeedTestScheduledTest
-
abort
public void abort(java.lang.String reason)
-
schedule
private boolean schedule()
Request a test from the speed testing service, handle the "challenge" if request and then get the id for the test. Per spec all request are BEncoded maps.- Returns:
- boolean - true if the test has been reserved with the service.
-
getVersionFromJAR
private java.lang.String getVersionFromJAR(java.io.File jar_file)
-
handleChallengeFromSpeedTestService
private java.util.Map handleChallengeFromSpeedTestService(java.io.File jar_file, java.util.Map result) throws java.io.IOException
- Parameters:
jar_file
- - File Azureus jar used to load classes.result
- - Map from the previous response- Returns:
- Map - from the current response.
- Throws:
java.io.IOException
-
sendResult
void sendResult(NetworkAdminSpeedTesterResult result)
-
sendRequest
private java.util.Map sendRequest(java.util.Map request) throws java.io.IOException
- Throws:
java.io.IOException
-
getBEncodedMapFromRequest
private java.util.Map getBEncodedMapFromRequest(java.net.URL url) throws java.io.IOException
Read from URL and return byte array.- Parameters:
url
- -- Returns:
- byte[] of the results. Max size currently 100k.
- Throws:
java.io.IOException
- -
-
resetSpeedLimits
protected void resetSpeedLimits()
Restore all the downloads the state before the speed test started.
-
setSpeedLimits
protected void setSpeedLimits()
Preserve all the data about the downloads while the test is running.
-
reportStage
protected void reportStage(java.lang.String str)
-
reportComplete
protected void reportComplete()
-
addListener
public void addListener(NetworkAdminSpeedTestScheduledTestListener listener)
- Specified by:
addListener
in interfaceNetworkAdminSpeedTestScheduledTest
-
removeListener
public void removeListener(NetworkAdminSpeedTestScheduledTestListener listener)
- Specified by:
removeListener
in interfaceNetworkAdminSpeedTestScheduledTest
-
-