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 class
private class
This class check if the somethingChanged flag and call process() when its set.private static class
private static class
private static class
private static class
private static class
Running totals and stuff that gets used during a process run.private class
A simple timer task to recalculate all seeding ranks.private class
private class
Update SeedingRank when a new scrape result comes in.private class
private class
Listen to Download changes and recalc SR if neededprivate class
private class
static interface
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate int
private int
private boolean
private static boolean
private boolean
private boolean
protected boolean
Whether Debug Info is written to the log and tooltipprivate boolean
private boolean
private boolean
private boolean
private int
private boolean
private boolean
private long
private long
private long
private static final int
Check for non triggerable changes ever period of time (in ms)private boolean
private TableContextMenuItem
protected LoggerChannel
private DefaultRankCalculator
private long
private DownloadManager
private final boolean
private static final int
Force at least one check every period of time (in ms).private Tag
private int
private Average
private int
private int
private int
private int
private int
private static final float
private boolean
private int
Ranking System to use.private CopyOnWriteList
protected LoggerChannel
private int
private int
private int
Maximum # of stalled torrents that are in seeding modeprivate static final int
private static final int
Wait at least xx ms for first scrape, before starting completed torrentsprivate static final int
Wait xx ms before starting completed torrents (so scrapes can come in)private int
private int
private long
private long
When rules class started.private int
static boolean
private PluginInterface
protected PluginConfig
private static final int
Interval in ms between checks to see if thesomethingChanged
flag changedprivate long
private long
private long
private long
Request that the startstop rules process.private long
private long
private long
private long
static final int
Do not rank completed torrentsstatic final int
Rank completed torrents using the peers count, weighted by the seeds to peers ratiostatic final int
Rank completed torrents using Seed Count methodstatic final int
Rank completed torrents using Seeds:Peer Ratiostatic final int
Rank 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 AEMonitor
Used only for RANK_TIMED.private LinkedList<RankCalculatorSlotReserver>
private Set<DefaultRankCalculator>
private String
private static final int
private static final int
private boolean
private 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 String
private boolean
private TagManager
private boolean
private AEMonitor
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoid
addListener
(StartStopRulesFPListener listener) private String
boolDebug
(boolean b) private int
calcMaxSeeders
(int iDLs) void
void
generate
(IndentWriter writer) protected int
private int
static DefaultRankCalculator
protected String
protected boolean
getTagFP()
private void
handleCompletedDownload
(DefaultRankCalculator dlData, StartStopRulesDefaultPlugin.ProcessVars vars, StartStopRulesDefaultPlugin.ProcessTagVarsComplete[] tagVars, StartStopRulesDefaultPlugin.TotalsStats totals) Process Completed (Seeding) downloads, starting and stopping as neededprivate void
handleInCompleteDownload
(DefaultRankCalculator dlData, StartStopRulesDefaultPlugin.ProcessVars vars, StartStopRulesDefaultPlugin.ProcessTagVarsIncomplete[] tagVars, StartStopRulesDefaultPlugin.TotalsStats totals) boolean
void
initialize
(PluginInterface _plugin_interface) This method is called when the Plugin is loaded by the clientstatic void
load
(PluginInterface plugin_interface) private void
printDebugChanges
(String sPrefixFirstLine, String[] oldEntries, String[] newEntries, String sDebugLine, String sPrefix, boolean bAlwaysPrintNoChangeLine, DefaultRankCalculator dlData) protected void
process()
private void
processDownloadingRules
(List<DefaultRankCalculator> downloads) private void
private void
void
removeListener
(StartStopRulesFPListener listener) void
requestProcessCycle
(DefaultRankCalculator rankToRecalc) protected void
setFPTagStatus
(DownloadManager dm, boolean is_fp) Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface com.biglybt.pif.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 thesomethingChanged
flag 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:
-
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 int globalDownloadLimit -
globalUploadLimit
private int globalUploadLimit -
globalUploadWhenSeedingLimit
private int globalUploadWhenSeedingLimit -
maxConfiguredDownloads
private int maxConfiguredDownloads -
bMaxDownloadIgnoreChecking
private boolean bMaxDownloadIgnoreChecking -
minDownloads
private int minDownloads -
bAutoReposition
private boolean bAutoReposition -
minTimeAlive
private long minTimeAlive -
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 -
processLastComplete
private long processLastComplete -
processTotalGap
private long processTotalGap -
processTotalRecalcs
private long processTotalRecalcs -
processTotalZeroRecalcs
private long processTotalZeroRecalcs -
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:Plugin
This method is called when the Plugin is loaded by the client- Specified by:
initialize
in 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:
configurationSaved
in 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) Process Completed (Seeding) downloads, starting and stopping as needed- Parameters:
dlDataArray
- All download data (rank objects) we handledlData
- Current download data (rank object) we are processingvars
- Running calculationstotals
- Summary values used in logic
-
boolDebug
-
printDebugChanges
-
requestProcessCycle
-
getTagFP
protected boolean getTagFP() -
setFPTagStatus
-
getSlotStatus
-
generate
- Specified by:
generate
in interfaceAEDiagnosticsEvidenceGenerator
-
addListener
-
removeListener
-
getFPListeners
-