|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object java.lang.Thread speedscheduler.SpeedSchedulerThread
public class SpeedSchedulerThread
This thread is responsible for monitoring the user-configured schedules and adjusting the Azureus max upload speed based thereupon.
Nested Class Summary |
---|
Nested classes/interfaces inherited from class java.lang.Thread |
---|
java.lang.Thread.State, java.lang.Thread.UncaughtExceptionHandler |
Field Summary | |
---|---|
private java.util.Vector |
activeSchedules
The list of schedules that are currently active based on day of week and time of day (the run() method chooses these). |
private static int |
DEFAULT_SLEEP_TIME
|
private int |
defaultMaxDownloadRate
|
private int |
defaultMaxUploadRate
When no schedule applies, the default rate is used. |
private static SpeedSchedulerThread |
instance
|
(package private) java.lang.String |
maxDownloadSpeedParam
To store the name of the configuration parameter we are interested in. |
(package private) java.lang.String |
maxUploadSpeedParam
To store the name of the configuration parameter we are interested in. |
private static int |
MIN_SLEEP_TIME
|
(package private) org.gudy.azureus2.plugins.PluginConfig |
pluginConfig
Interrace to Azureus configuration. |
(package private) org.gudy.azureus2.plugins.PluginInterface |
pluginInterface
Interrace to Azureus. |
private boolean |
runFlag
Flag that tells the thread's loop whether to continue or pause. |
private SpeedSchedulerThread |
runningThread
A reference to the running thread. |
private java.util.Vector |
schedules
The list of the user configured schedules. |
private java.util.Vector |
scheduleSelectionListeners
Maintains a list of the registered listeners. |
Fields inherited from class java.lang.Thread |
---|
MAX_PRIORITY, MIN_PRIORITY, NORM_PRIORITY |
Constructor Summary | |
---|---|
SpeedSchedulerThread()
Creates a new SpeedSchedulerThread, which registers a listener with the SchedulePersistencyManager. |
Method Summary | |
---|---|
private void |
addPausedDownload(org.gudy.azureus2.plugins.download.Download download)
Records that we paused the specified download in a persistent such that we will un-pause this download again when schedules indicate such. |
void |
addScheduleSelectionListener(ScheduleSelectionChangeListener listener)
Call this method to sign-up to receive notification when the SpeedSchedulerThread selects a new schedule to use when limiting download/upload speeds. |
private org.gudy.azureus2.plugins.download.Download |
getDownloadFromHash(java.lang.String hash)
Gets the download with the specified hash (if any). |
static SpeedSchedulerThread |
getInstance()
|
private org.gudy.azureus2.plugins.download.Download[] |
getPausedDownloads()
Gets all the Downloads that we have paused as a result of schedules. |
private java.lang.String |
getPausedDownloadsFile()
Gets the name of the file where paused download hashes are stored. |
private void |
notifyScheduleSelectionListeners(java.util.Vector schedules)
Helper function that notifies all ScheduleSelectionListeners that the SpeedSchedulerThread has chosen a new schedule. |
private void |
pauseTorrent(org.gudy.azureus2.plugins.download.Download download)
Pauses the specified download and adds it to the list of downloads that we have paused, that we can thereby recall later which downloads we have paused when it is time to un-pause them. |
private void |
removePausedDownload(org.gudy.azureus2.plugins.download.Download download)
Removes a download's hash from the persistent file of downloads that we have paused. |
void |
run()
Start your engines and never come back. |
void |
schedulesChanged(java.util.Vector newSchedules,
int newDefaultMaxUploadRate,
int newDefaultMaxDownloadRate)
Called by the SchedulePersistencyManager whenever the user changes the schedules. |
private void |
unPauseTorrent(org.gudy.azureus2.plugins.download.Download download)
Unpauses the specified download (ie, restarts it), and removes it from the persistent list of paused downloads. |
private boolean |
weAlreadyPausedDownload(org.gudy.azureus2.plugins.download.Download download)
Alias for wePausedDownload() |
private boolean |
wePausedTorrent(org.gudy.azureus2.plugins.download.Download download)
Returns whether we paused the specified download based on its hash and the contents of the persistent paused downloads file. |
Methods inherited from class java.lang.Thread |
---|
activeCount, checkAccess, countStackFrames, currentThread, destroy, dumpStack, enumerate, getAllStackTraces, getContextClassLoader, getDefaultUncaughtExceptionHandler, getId, getName, getPriority, getStackTrace, getState, getThreadGroup, getUncaughtExceptionHandler, holdsLock, interrupt, interrupted, isAlive, isDaemon, isInterrupted, join, join, join, resume, setContextClassLoader, setDaemon, setDefaultUncaughtExceptionHandler, setName, setPriority, setUncaughtExceptionHandler, sleep, sleep, start, stop, stop, suspend, toString, yield |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
private int defaultMaxUploadRate
private int defaultMaxDownloadRate
private static final int DEFAULT_SLEEP_TIME
private static final int MIN_SLEEP_TIME
private java.util.Vector schedules
private java.util.Vector activeSchedules
org.gudy.azureus2.plugins.PluginInterface pluginInterface
org.gudy.azureus2.plugins.PluginConfig pluginConfig
java.lang.String maxUploadSpeedParam
java.lang.String maxDownloadSpeedParam
private SpeedSchedulerThread runningThread
private static SpeedSchedulerThread instance
private boolean runFlag
private java.util.Vector scheduleSelectionListeners
Constructor Detail |
---|
public SpeedSchedulerThread()
Method Detail |
---|
public static SpeedSchedulerThread getInstance()
public void run()
run
in interface java.lang.Runnable
run
in class java.lang.Thread
private void pauseTorrent(org.gudy.azureus2.plugins.download.Download download)
download
- The download to pause.Download
private void addPausedDownload(org.gudy.azureus2.plugins.download.Download download)
download
- The download to pause and record as such.Download
private boolean wePausedTorrent(org.gudy.azureus2.plugins.download.Download download)
download
- The download to check.
Download
private boolean weAlreadyPausedDownload(org.gudy.azureus2.plugins.download.Download download)
wePausedDownload
,
Download
private java.lang.String getPausedDownloadsFile()
"C:/Documents and Settings/Dave/Application Data/Azureus/Plugins/SpeedScheduler/PausedTorrents.conf
"Download
private org.gudy.azureus2.plugins.download.Download[] getPausedDownloads()
Download
private org.gudy.azureus2.plugins.download.Download getDownloadFromHash(java.lang.String hash)
hash
- The hash of the Torrent, whose Download object to fetch.
private void unPauseTorrent(org.gudy.azureus2.plugins.download.Download download)
download
- The download to unpause.private void removePausedDownload(org.gudy.azureus2.plugins.download.Download download)
download
- The Download to remove from the file.public void schedulesChanged(java.util.Vector newSchedules, int newDefaultMaxUploadRate, int newDefaultMaxDownloadRate)
schedulesChanged
in interface ScheduleChangeListener
newSchedules
- The vector of schedules that are now selectednewDefaultMaxUploadRate
- The new default max upload ratenewDefaultMaxDownloadRate
- The new default max download ratepublic void addScheduleSelectionListener(ScheduleSelectionChangeListener listener)
listener
- The listener that implements the ScheduleSelectionLisetener interface
who will be notified.ScheduleSelectionChangeListener
private void notifyScheduleSelectionListeners(java.util.Vector schedules)
schedules
- Vector of Schedules that we just chose.ScheduleSelectionChangeListener
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |