Class StartStopRulesDefaultPlugin
java.lang.Object
com.biglybt.plugin.startstoprules.defaultplugin.StartStopRulesDefaultPlugin
- All Implemented Interfaces:
COConfigurationListener, AEDiagnosticsEvidenceGenerator, Plugin
public class StartStopRulesDefaultPlugin
extends Object
implements Plugin, COConfigurationListener, AEDiagnosticsEvidenceGenerator
Handles Starting and Stopping of torrents.
TODO: RANK_TIMED is quite a hack and is spread all over. It needs to be
redone, probably with a timer on each seeding torrent which triggers
when time is up and it needs to stop.
BUG: When "AutoStart 0 Peers" is on, and minSpeedForActivelySeeding is
enabled, the 0 peer torrents will continuously switch from seeding to
queued, probably due to the connection attempt registering speed.
This might be fixed by the "wait XX ms before switching active state"
code.
Other Notes:
"CD" is often used to refer to "Seed" or "Seeding", because "C" sounds like
"See"
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprivate classprivate classThis class check if the somethingChanged flag and call process() when its set.private static classprivate static classprivate static classprivate static classprivate static classRunning totals and stuff that gets used during a process run.private classA simple timer task to recalculate all seeding ranks.private classprivate classUpdate SeedingRank when a new scrape result comes in.private classprivate classListen to Download changes and recalc SR if neededprivate classprivate classstatic interface -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate intprivate intprivate booleanprivate static booleanprivate booleanprivate booleanprotected booleanWhether Debug Info is written to the log and tooltipprivate booleanprivate booleanprivate booleanprivate booleanprivate intprivate booleanprivate booleanprivate longprivate longprivate longprivate static final intCheck for non triggerable changes ever period of time (in ms)private booleanprivate static final Objectprivate TableContextMenuItemprotected LoggerChannelprivate DefaultRankCalculatorprivate longprivate DownloadManagerstatic booleanprivate final booleanprivate static final intForce at least one check every period of time (in ms).private Tagprivate longprivate Averageprivate longprivate longprivate intprivate intprivate intprivate static final floatprivate booleanprivate intRanking System to use.private longprivate CopyOnWriteListprotected LoggerChannelprivate intprivate intprivate intMaximum # of stalled torrents that are in seeding modeprivate static final intprivate static final intWait at least xx ms for first scrape, before starting completed torrentsprivate static final intWait xx ms before starting completed torrents (so scrapes can come in)private intprivate intprivate longWhen rules class started.private intstatic booleanprivate PluginInterfaceprotected PluginConfigprivate static final intInterval in ms between checks to see if thesomethingChangedflag changedprivate longprivate longprivate longprivate longRequest that the startstop rules process.private longprivate longprivate longprivate longstatic final intDo not rank completed torrentsstatic final intRank completed torrents using the peers count, weighted by the seeds to peers ratiostatic final intRank completed torrents using Seed Count methodstatic final intRank completed torrents using Seeds:Peer Ratiostatic final intRank completed torrents using a timed rotation of minTimeAliveprivate static Map<Object, DefaultRankCalculator> Map to relate downloadData to a Download OR reserved slotprivate Set<DefaultRankCalculator> private AEMonitorUsed only for RANK_TIMED.private LinkedList<RankCalculatorSlotReserver> private Set<DefaultRankCalculator> private Stringprivate static final intprivate static final intprivate booleanprivate DefaultRankCalculator[]this is used to reduce the number of comperator invocations by keeping a mostly sorted copy around, must be nulled whenever the map is changedprivate static final Stringprivate booleanprivate TagManagerprivate booleanprivate AEMonitor -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidaddListener(StartStopRulesFPListener listener) private StringboolDebug(boolean b) private intcalcMaxSeeders(int iDLs) voidvoidgenerate(IndentWriter writer) protected intprivate intstatic DefaultRankCalculatorprotected Stringprotected booleangetTagFP()private voidhandleCompletedDownload(DefaultRankCalculator dlData, StartStopRulesDefaultPlugin.ProcessVars vars, StartStopRulesDefaultPlugin.ProcessTagVarsComplete[] tagVars, StartStopRulesDefaultPlugin.TotalsStats totals, boolean debugNoChange) Process Completed (Seeding) downloads, starting and stopping as neededprivate voidhandleInCompleteDownload(DefaultRankCalculator dlData, StartStopRulesDefaultPlugin.ProcessVars vars, StartStopRulesDefaultPlugin.ProcessTagVarsIncomplete[] tagVars, StartStopRulesDefaultPlugin.TotalsStats totals) booleanvoidinitialize(PluginInterface _plugin_interface) This method is called when the Plugin is loaded by the clientstatic voidload(PluginInterface plugin_interface) private voidprintDebugChanges(String sPrefixFirstLine, String[] oldEntries, String[] newEntries, String sDebugLine, String sPrefix, boolean bAlwaysPrintNoChangeLine, DefaultRankCalculator dlData) protected voidprocess()private voidprocessDownloadingRules(List<DefaultRankCalculator> downloads) private voidprivate voidvoidremoveListener(StartStopRulesFPListener listener) voidrequestProcessCycle(DefaultRankCalculator rankToRecalc) protected voidsetFPTagStatus(DownloadManager dm, boolean is_fp) Methods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface Plugin
getInitialProperties
-
Field Details
-
sStates
- See Also:
-
RANK_NONE
public static final int RANK_NONEDo not rank completed torrents- See Also:
-
RANK_SPRATIO
public static final int RANK_SPRATIORank completed torrents using Seeds:Peer Ratio- See Also:
-
RANK_SEEDCOUNT
public static final int RANK_SEEDCOUNTRank completed torrents using Seed Count method- See Also:
-
RANK_TIMED
public static final int RANK_TIMEDRank completed torrents using a timed rotation of minTimeAlive- See Also:
-
RANK_PEERCOUNT
public static final int RANK_PEERCOUNTRank completed torrents using the peers count, weighted by the seeds to peers ratio- See Also:
-
FORCE_CHECK_PERIOD
private static final int FORCE_CHECK_PERIODForce at least one check every period of time (in ms). Used in ChangeFlagCheckerTask- See Also:
-
CHECK_FOR_GROSS_CHANGE_PERIOD
private static final int CHECK_FOR_GROSS_CHANGE_PERIODCheck for non triggerable changes ever period of time (in ms)- See Also:
-
PROCESS_CHECK_PERIOD
private static final int PROCESS_CHECK_PERIODInterval in ms between checks to see if thesomethingChangedflag changed- See Also:
-
MIN_SEEDING_STARTUP_WAIT
private static final int MIN_SEEDING_STARTUP_WAITWait xx ms before starting completed torrents (so scrapes can come in)- See Also:
-
MIN_FIRST_SCRAPE_WAIT
private static final int MIN_FIRST_SCRAPE_WAITWait at least xx ms for first scrape, before starting completed torrents- See Also:
-
IGNORE_SLOT_THRESHOLD_FACTOR
private static final float IGNORE_SLOT_THRESHOLD_FACTOR- See Also:
-
MIN_DOWNLOADING_STARTUP_WAIT
private static final int MIN_DOWNLOADING_STARTUP_WAIT- See Also:
-
SMOOTHING_PERIOD_SECS
private static final int SMOOTHING_PERIOD_SECS- See Also:
-
SMOOTHING_PERIOD
private static final int SMOOTHING_PERIOD- See Also:
-
DEBUG_LINE_KEY
-
DROO_FEATURES_ENABLE
public static boolean DROO_FEATURES_ENABLE -
tag_manager
-
tagsHaveDLorCDLimits
private volatile boolean tagsHaveDLorCDLimits -
globalDownloadSpeedAverage
-
this_mon
-
pi
-
plugin_config
-
download_manager
-
log
-
ENABLE_DLOG
private final boolean ENABLE_DLOG- See Also:
-
dlog
-
recalcSeedingRanksTask
Used only for RANK_TIMED. Recalculate ranks on a timer -
rankCalculatorMap
Map to relate downloadData to a Download OR reserved slot -
sortedArrayCache
this is used to reduce the number of comperator invocations by keeping a mostly sorted copy around, must be nulled whenever the map is changed -
closingDown
private volatile boolean closingDown -
somethingChanged
private volatile boolean somethingChanged -
ranksToRecalc
-
ranksToRecalc_mon
-
monoStartedOn
private long monoStartedOnWhen rules class started. Used for initial waiting logic -
bDebugLog
protected boolean bDebugLogWhether Debug Info is written to the log and tooltip -
iRankType
private int iRankTypeRanking System to use. One of RANK_* constants -
minSpeedForActiveSeeding
private int minSpeedForActiveSeeding -
maxStalledSeeding
private int maxStalledSeedingMaximum # of stalled torrents that are in seeding mode -
maxOverLimitSeeding
private int maxOverLimitSeeding -
stalledSeedingIgnoreZP
private boolean stalledSeedingIgnoreZP -
_maxActive
private int _maxActive -
_maxActiveWhenSeedingEnabled
private boolean _maxActiveWhenSeedingEnabled -
_maxActiveWhenSeeding
private int _maxActiveWhenSeeding -
globalDownloadLimit
private long globalDownloadLimit -
globalUploadLimit
private long globalUploadLimit -
globalUploadWhenSeedingLimit
private long globalUploadWhenSeedingLimit -
maxConfiguredDownloads
private int maxConfiguredDownloads -
bMaxDownloadIgnoreChecking
private boolean bMaxDownloadIgnoreChecking -
minDownloads
private int minDownloads -
bAutoReposition
private boolean bAutoReposition -
bAutoStart0Peers
private boolean bAutoStart0Peers -
bStopOnceBandwidthMet
private boolean bStopOnceBandwidthMet -
bStartNoMoreSeedsWhenUpLimitMet
private boolean bStartNoMoreSeedsWhenUpLimitMet -
bStartNoMoreSeedsWhenUpLimitMetPercent
private boolean bStartNoMoreSeedsWhenUpLimitMetPercent -
bStartNoMoreSeedsWhenUpLimitMetSlack
private int bStartNoMoreSeedsWhenUpLimitMetSlack -
iDownloadSortType
private int iDownloadSortType -
iDownloadTestTimeMillis
private int iDownloadTestTimeMillis -
iDownloadReTestMillis
private int iDownloadReTestMillis -
bDownloadTestActive
private boolean bDownloadTestActive -
bTagFirstPriority
private boolean bTagFirstPriority -
bAlreadyInitialized
private static boolean bAlreadyInitialized -
debugMenuItem
-
swt_ui
-
listenersFP
-
pauseChangeFlagChecker
public static boolean pauseChangeFlagChecker -
fp_tag
-
numReservedSeedingSlots
private volatile int numReservedSeedingSlots -
reservedSlots
-
reservedSlotsAllocated
-
slotStatus
-
immediateProcessingScheduled
private volatile boolean immediateProcessingScheduled -
changeCheckCount
private long changeCheckCount -
changeCheckTotalMS
private long changeCheckTotalMS -
changeCheckMaxMS
private long changeCheckMaxMS -
processCount
private long processCount -
processTotalMS
private long processTotalMS -
processMaxMS
private long processMaxMS -
processLastCompleteMono
private long processLastCompleteMono -
processTotalGap
private long processTotalGap -
processTotalRecalcs
private long processTotalRecalcs -
processTotalZeroRecalcs
private long processTotalZeroRecalcs -
lastDebugNoChangesMono
private long lastDebugNoChangesMono -
dlr_current_active
-
dlr_max_rate_time
private long dlr_max_rate_time -
processMergeCount
private long processMergeCountRequest that the startstop rules process. Used when it's known that something has changed that will effect torrent's state/position/rank.
-
-
Constructor Details
-
StartStopRulesDefaultPlugin
public StartStopRulesDefaultPlugin()
-
-
Method Details
-
load
-
initialize
Description copied from interface:PluginThis method is called when the Plugin is loaded by the client- Specified by:
initializein interfacePlugin- Parameters:
_plugin_interface- the interface that the plugin must use to communicate with the client
-
getRankCalculator
-
getTagManager
-
hasTagDLorCDLimits
public boolean hasTagDLorCDLimits() -
recalcAllSeedingRanks
private void recalcAllSeedingRanks() -
configurationSaved
public void configurationSaved()- Specified by:
configurationSavedin interfaceCOConfigurationListener
-
reloadConfigParams
private void reloadConfigParams() -
calcMaxSeeders
private int calcMaxSeeders(int iDLs) -
getMaxActive
protected int getMaxActive() -
process
protected void process() -
processDownloadingRules
-
getMaxDownloads
private int getMaxDownloads() -
handleInCompleteDownload
private void handleInCompleteDownload(DefaultRankCalculator dlData, StartStopRulesDefaultPlugin.ProcessVars vars, StartStopRulesDefaultPlugin.ProcessTagVarsIncomplete[] tagVars, StartStopRulesDefaultPlugin.TotalsStats totals) - Parameters:
dlData-vars-totals-
-
handleCompletedDownload
private void handleCompletedDownload(DefaultRankCalculator dlData, StartStopRulesDefaultPlugin.ProcessVars vars, StartStopRulesDefaultPlugin.ProcessTagVarsComplete[] tagVars, StartStopRulesDefaultPlugin.TotalsStats totals, boolean debugNoChange) Process Completed (Seeding) downloads, starting and stopping as needed- Parameters:
dlData- Current download data (rank object) we are processingvars- Running calculationstotals- Summary values used in logicdlDataArray- All download data (rank objects) we handle
-
boolDebug
-
printDebugChanges
-
requestProcessCycle
-
getTagFP
protected boolean getTagFP() -
setFPTagStatus
-
getSlotStatus
-
generate
- Specified by:
generatein interfaceAEDiagnosticsEvidenceGenerator
-
addListener
-
removeListener
-
getFPListeners
-