Class RankCalculatorReal
java.lang.Object
com.biglybt.plugin.startstoprules.defaultplugin.RankCalculatorReal
- All Implemented Interfaces:
DownloadManagerStateAttributeListener
,DefaultRankCalculator
,Comparable<DefaultRankCalculator>
public class RankCalculatorReal
extends Object
implements DefaultRankCalculator, DownloadManagerStateAttributeListener
-
Nested Class Summary
Nested Classes -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate String
private String
private static final ThreadPool
private static final int
Wait XX ms before really changing activity (DL or CDing) state when state changes via speed changeprivate boolean
private boolean
private static boolean
private static boolean
private static boolean
private boolean
private static boolean
private static COConfigurationListener
For loading config settingsprivate final DownloadManager
private final Download
private long
private boolean
private int
private long
private long
private long
private int
private int
private AEMonitor
private RankCalculatorReal.SR
private static final int
Force torrent to be "Actively Seeding/Downloading" for this many ms upon start of torrent.private static final long
private static final long
private static int
private static int
private static int
private static int
private static int
private static int
private static int
private static int
private static int
private static int
private static int
private static int
Ranking System to useprivate static int
private static int
private long
(package private) int
(package private) int
(package private) int
(package private) boolean
private long
private long
private long
private long
private long
private static int
Min # of Peers needed before boosting the rank of downloads with no seedsprivate static int
private static int
Min Speed needed to count a incomplete download as being actively downloadingprivate static int
Min speed needed to count a complete download as being actively seedingprivate static long
private static final TagFeatureRateLimit[]
private static int
private RankCalculatorSlotReserver
private final StartStopRulesDefaultPlugin
private static int
Amount to shift over the rank of the SEEDONLY ranking type, to make room in case the user has fallback to SPRATIO set.private static int
Maximium ranking that a torrent can get using the SPRATIO ranking typeprivate static final long
private long
private long
private String
private TagFeatureRateLimit[]
private TagFeatureRateLimit[]
Fields inherited from interface com.biglybt.plugin.startstoprules.defaultplugin.DefaultRankCalculator
DOWNLOAD_ORDER_ETA, DOWNLOAD_ORDER_FILE_PRIORITIES, DOWNLOAD_ORDER_INDEX, DOWNLOAD_ORDER_REMAINING, DOWNLOAD_ORDER_REVERSE_SEED_COUNT, DOWNLOAD_ORDER_REVERSE_SIZE, DOWNLOAD_ORDER_SEED_COUNT, DOWNLOAD_ORDER_SIZE, DOWNLOAD_ORDER_SPEED, FIRSTPRIORITY_ALL, FIRSTPRIORITY_ANY, SR_0PEERS, SR_COMPLETE_STARTS_AT, SR_FP_SPRATIOMET, SR_FP0PEERS, SR_IGNORED_LESS_THAN, SR_NEGATIVE_DEBUG, SR_NOSCRAPE, SR_NOTQUEUED, SR_NUMSEEDSMET, SR_RATIOMET, SR_SHARERATIOMET, SR_TIMED_QUEUED_ENDS_AT
Fields inherited from interface com.biglybt.core.download.DownloadManagerStateAttributeListener
WILL_BE_READ, WRITTEN
-
Constructor Summary
ConstructorsConstructorDescriptionRankCalculatorReal
(StartStopRulesDefaultPlugin _rules, Download _dl) Default Initializer -
Method Summary
Modifier and TypeMethodDescriptionprivate int
_recalcSeedingRankSupport
(boolean ignore0Peers, int oldSR, boolean is_test) boolean
activationRequest
(Runnable to_do) void
addStateAttributeListener
(DownloadManagerStateAttributeListener l, String attribute, int event_type) void
appendTrace
(String str) void
attributeEventOccurred
(DownloadManager download, String attribute, int event_type) private int
Get # of peers not including usprivate int
calcPeersNoUs
(Download download, DownloadScrapeResult sr) int
private int
calcSeedsNoUs
(Download download, DownloadScrapeResult sr) Get # of seeds, not including us, AND including fake full copiesprivate int
calcSeedsNoUs
(Download download, DownloadScrapeResult sr, int numPeers) Get # of seeds, not including us, AND including fake full copiesboolean
Check Seeders for various changes not triggered by listenersint
Sort first by SeedingRank Descending, then by Position Ascending.int
void
destroy()
boolean
Retrieves whether the torrent is "actively" downloadingboolean
Retrieves whether the torrent is "actively" seedinggetAggregatedScrapeResult
(boolean b) boolean
int
long
int
long
long
int[]
int
int
boolean
long
getName()
int
long
int
Assign Seeding Rank based on RankTypeint
long
int
getState()
long
getTrace()
long
getUserData
(Object key) void
boolean
boolean
boolean
boolean
boolean
Does the torrent match First Priority criteria?boolean
boolean
boolean
isMoving()
boolean
isQueued()
void
moveTo
(int pos) private boolean
pisFirstPriority
(boolean ignore0Peers, boolean is_test, boolean for_tag_fp) void
static void
Load config values into the static variablesvoid
removeStateAttributeListener
(DownloadManagerStateAttributeListener l, String attribute, int event_type) void
void
restart()
void
scrapeReceived
(DownloadScrapeResult result) boolean
void
setDLRActive
(long time) void
setDLRComplete
(long time) void
void
setPosition
(int pos) void
private void
void
setUserData
(Object key, Object value) void
start()
void
boolean
toString()
boolean
updateLightSeedEligibility
(boolean has_slots) private void
-
Field Details
-
NO_TAG_LIMITS
-
FORCE_ACTIVE_FOR
private static final int FORCE_ACTIVE_FORForce torrent to be "Actively Seeding/Downloading" for this many ms upon start of torrent.- See Also:
-
ACTIVE_CHANGE_WAIT
private static final int ACTIVE_CHANGE_WAITWait XX ms before really changing activity (DL or CDing) state when state changes via speed change- See Also:
-
SPRATIO_BASE_LIMIT
private static int SPRATIO_BASE_LIMITMaximium ranking that a torrent can get using the SPRATIO ranking type -
SEEDONLY_SHIFT
private static int SEEDONLY_SHIFTAmount to shift over the rank of the SEEDONLY ranking type, to make room in case the user has fallback to SPRATIO set. -
HIGH_LATENCY_MILLIS
private static final long HIGH_LATENCY_MILLIS- See Also:
-
HIGH_LATENCY_RECOVERY_MILLIS
private static final long HIGH_LATENCY_RECOVERY_MILLIS- See Also:
-
configListener
For loading config settings -
STALE_REFRESH_INTERVAL
private static final long STALE_REFRESH_INTERVAL- See Also:
-
iRankType
private static int iRankTypeRanking System to use -
minPeersToBoostNoSeeds
private static int minPeersToBoostNoSeedsMin # of Peers needed before boosting the rank of downloads with no seeds -
minSpeedForActiveDL
private static int minSpeedForActiveDLMin Speed needed to count a incomplete download as being actively downloading -
minSpeedForActiveSeeding
private static int minSpeedForActiveSeedingMin speed needed to count a complete download as being actively seeding -
iIgnoreSeedCount
private static int iIgnoreSeedCount -
bIgnore0Peers
private static boolean bIgnore0Peers -
iIgnoreRatioPeers
private static int iIgnoreRatioPeers -
iIgnoreRatioPeers_SeedStart
private static int iIgnoreRatioPeers_SeedStart -
iRankTypeSeedFallback
private static int iRankTypeSeedFallback -
bPreferLargerSwarms
private static boolean bPreferLargerSwarms -
iFirstPriorityIgnoreSPRatio
private static int iFirstPriorityIgnoreSPRatio -
bFirstPriorityIgnore0Peer
private static boolean bFirstPriorityIgnore0Peer -
iFirstPriorityType
private static int iFirstPriorityType -
iFirstPrioritySeedingMinutes
private static int iFirstPrioritySeedingMinutes -
iFirstPriorityActiveMinutes
private static int iFirstPriorityActiveMinutes -
iFirstPriorityIgnoreIdleMinutes
private static int iFirstPriorityIgnoreIdleMinutes -
minTimeAlive
private static long minTimeAlive -
bAutoStart0Peers
private static boolean bAutoStart0Peers -
iTimed_MinSeedingTimeWithPeers
private static int iTimed_MinSeedingTimeWithPeers -
numPeersAsFullCopy
private static int numPeersAsFullCopy -
iFakeFullCopySeedStart
private static int iFakeFullCopySeedStart -
dl
-
core_dm
-
bActivelyDownloading
private boolean bActivelyDownloading -
lDLActivelyChangedOnMono
private long lDLActivelyChangedOnMono -
lDownloadingHighLatencyTimeMono
private long lDownloadingHighLatencyTimeMono -
downloadSR
-
bActivelySeeding
private boolean bActivelySeeding -
lCDActivelyChangedOnMono
private long lCDActivelyChangedOnMono -
lSeedingHighLatencyTimeMono
private long lSeedingHighLatencyTimeMono -
staleCDSinceMono
private long staleCDSinceMono -
staleCDOffset
private long staleCDOffset -
lastStaleCDRefreshMono
private long lastStaleCDRefreshMono -
bIsFirstPriority
private boolean bIsFirstPriority -
dlLastActiveTime
private long dlLastActiveTime -
_sExplainFP
-
_sExplainSR
-
sTrace
-
downloadData_this_mon
-
rules
-
tagsWithDLLimits
-
tagsWithCDLimits
-
lastModifiedScrapeResultPeers
int lastModifiedScrapeResultPeers -
lastModifiedScrapeResultSeeds
int lastModifiedScrapeResultSeeds -
lastScrapeResultOk
boolean lastScrapeResultOk -
reservedSlot
-
lastActivationAnnounce
private long lastActivationAnnounce -
userData
-
dlr_test_active
private boolean dlr_test_active -
dlr_test_start_time
private long dlr_test_start_time -
dlr_test_bytes_start
private long dlr_test_bytes_start -
dlr_test_average_bytes_per_sec
private int dlr_test_average_bytes_per_sec -
dlr_test_eta
private long dlr_test_eta -
activate_pool
-
-
Constructor Details
-
RankCalculatorReal
Default Initializer- Parameters:
_rules
-_dl
-
-
-
Method Details
-
attributeEventOccurred
- Specified by:
attributeEventOccurred
in interfaceDownloadManagerStateAttributeListener
-
destroy
public void destroy()- Specified by:
destroy
in interfaceDefaultRankCalculator
-
reloadConfigParams
Load config values into the static variables- Parameters:
cfg
-
-
compareTo
Sort first by SeedingRank Descending, then by Position Ascending.- Specified by:
compareTo
in interfaceComparable<DefaultRankCalculator>
-
compareToIgnoreStopped
- Specified by:
compareToIgnoreStopped
in interfaceDefaultRankCalculator
-
getRelatedTo
- Specified by:
getRelatedTo
in interfaceDefaultRankCalculator
-
getName
- Specified by:
getName
in interfaceDefaultRankCalculator
-
getState
public int getState()- Specified by:
getState
in interfaceDefaultRankCalculator
-
getCoreState
public int getCoreState()- Specified by:
getCoreState
in interfaceDefaultRankCalculator
-
addStateAttributeListener
public void addStateAttributeListener(DownloadManagerStateAttributeListener l, String attribute, int event_type) - Specified by:
addStateAttributeListener
in interfaceDefaultRankCalculator
-
removeStateAttributeListener
public void removeStateAttributeListener(DownloadManagerStateAttributeListener l, String attribute, int event_type) - Specified by:
removeStateAttributeListener
in interfaceDefaultRankCalculator
-
supportsPosition
public boolean supportsPosition()- Specified by:
supportsPosition
in interfaceDefaultRankCalculator
-
getPosition
public int getPosition()- Specified by:
getPosition
in interfaceDefaultRankCalculator
-
setPosition
public void setPosition(int pos) - Specified by:
setPosition
in interfaceDefaultRankCalculator
-
moveTo
public void moveTo(int pos) - Specified by:
moveTo
in interfaceDefaultRankCalculator
-
isControllable
public boolean isControllable()- Specified by:
isControllable
in interfaceDefaultRankCalculator
-
isForceActive
public boolean isForceActive()- Specified by:
isForceActive
in interfaceDefaultRankCalculator
-
isQueued
public boolean isQueued()- Specified by:
isQueued
in interfaceDefaultRankCalculator
-
isDownloading
public boolean isDownloading()- Specified by:
isDownloading
in interfaceDefaultRankCalculator
-
isChecking
public boolean isChecking()- Specified by:
isChecking
in interfaceDefaultRankCalculator
-
isMoving
public boolean isMoving()- Specified by:
isMoving
in interfaceDefaultRankCalculator
-
isForceStart
public boolean isForceStart()- Specified by:
isForceStart
in interfaceDefaultRankCalculator
-
isComplete
public boolean isComplete()- Specified by:
isComplete
in interfaceDefaultRankCalculator
-
initialize
- Specified by:
initialize
in interfaceDefaultRankCalculator
- Throws:
DownloadException
-
start
- Specified by:
start
in interfaceDefaultRankCalculator
- Throws:
DownloadException
-
restart
- Specified by:
restart
in interfaceDefaultRankCalculator
- Throws:
DownloadException
-
stopAndQueue
- Specified by:
stopAndQueue
in interfaceDefaultRankCalculator
- Throws:
DownloadException
-
getUploadAverage
public long getUploadAverage()- Specified by:
getUploadAverage
in interfaceDefaultRankCalculator
-
getDownloadAverage
public long getDownloadAverage()- Specified by:
getDownloadAverage
in interfaceDefaultRankCalculator
-
getTimeStarted
public long getTimeStarted()- Specified by:
getTimeStarted
in interfaceDefaultRankCalculator
-
getSizeExcludingDND
public long getSizeExcludingDND()- Specified by:
getSizeExcludingDND
in interfaceDefaultRankCalculator
-
getRemainingExcludingDND
public long getRemainingExcludingDND()- Specified by:
getRemainingExcludingDND
in interfaceDefaultRankCalculator
-
getFilePriorityStats
public int[] getFilePriorityStats()- Specified by:
getFilePriorityStats
in interfaceDefaultRankCalculator
-
getAggregatedScrapeResult
- Specified by:
getAggregatedScrapeResult
in interfaceDefaultRankCalculator
-
scrapeResultOk
public boolean scrapeResultOk()- Specified by:
scrapeResultOk
in interfaceDefaultRankCalculator
-
calcSeedsNoUs
public int calcSeedsNoUs()- Specified by:
calcSeedsNoUs
in interfaceDefaultRankCalculator
-
calcSeedsNoUs
Get # of seeds, not including us, AND including fake full copies- Parameters:
download
- Download to get # of seeds for- Returns:
- seed count
-
calcSeedsNoUs
Get # of seeds, not including us, AND including fake full copies- Parameters:
download
- Download to get # of seeds fornumPeers
- # peers we know of, required to calculate Fake Full Copies- Returns:
- seed count
-
calcPeersNoUs
private int calcPeersNoUs()Get # of peers not including us -
calcPeersNoUs
-
getActivelyDownloading
public boolean getActivelyDownloading()Retrieves whether the torrent is "actively" downloading- Specified by:
getActivelyDownloading
in interfaceDefaultRankCalculator
- Returns:
- true: actively downloading
-
getActivelySeeding
public boolean getActivelySeeding()Retrieves whether the torrent is "actively" seeding- Specified by:
getActivelySeeding
in interfaceDefaultRankCalculator
- Returns:
- true: actively seeding
-
setupTagData
private void setupTagData() -
getTagsWithDLLimits
- Specified by:
getTagsWithDLLimits
in interfaceDefaultRankCalculator
-
getTagsWithCDLimits
- Specified by:
getTagsWithCDLimits
in interfaceDefaultRankCalculator
-
getLastScrapeResultOk
public boolean getLastScrapeResultOk()- Specified by:
getLastScrapeResultOk
in interfaceDefaultRankCalculator
-
scrapeReceived
- Specified by:
scrapeReceived
in interfaceDefaultRankCalculator
-
updateScrapeCache
private void updateScrapeCache() -
getLastModifiedScrapeResultPeers
public int getLastModifiedScrapeResultPeers()- Specified by:
getLastModifiedScrapeResultPeers
in interfaceDefaultRankCalculator
-
getLastModifiedScrapeResultSeeds
public int getLastModifiedScrapeResultSeeds()- Specified by:
getLastModifiedScrapeResultSeeds
in interfaceDefaultRankCalculator
-
getExplainFP
- Specified by:
getExplainFP
in interfaceDefaultRankCalculator
-
getExplainSR
- Specified by:
getExplainSR
in interfaceDefaultRankCalculator
-
resetTrace
public void resetTrace()- Specified by:
resetTrace
in interfaceDefaultRankCalculator
-
appendTrace
- Specified by:
appendTrace
in interfaceDefaultRankCalculator
-
getTrace
- Specified by:
getTrace
in interfaceDefaultRankCalculator
-
getSeedingRank
public int getSeedingRank()Assign Seeding Rank based on RankType- Specified by:
getSeedingRank
in interfaceDefaultRankCalculator
- Returns:
- New Seeding Rank Value
-
recalcSeedingRank
public void recalcSeedingRank()- Specified by:
recalcSeedingRank
in interfaceDefaultRankCalculator
-
_recalcSeedingRankSupport
private int _recalcSeedingRankSupport(boolean ignore0Peers, int oldSR, boolean is_test) -
isFirstPriority
public boolean isFirstPriority()Does the torrent match First Priority criteria?- Specified by:
isFirstPriority
in interfaceDefaultRankCalculator
- Returns:
- FP State
-
pisFirstPriority
private boolean pisFirstPriority(boolean ignore0Peers, boolean is_test, boolean for_tag_fp) -
getCachedIsFP
public boolean getCachedIsFP()- Specified by:
getCachedIsFP
in interfaceDefaultRankCalculator
- Returns:
- last calculated FP state
-
setDLRInactive
public void setDLRInactive()- Specified by:
setDLRInactive
in interfaceDefaultRankCalculator
-
setDLRActive
public void setDLRActive(long time) - Specified by:
setDLRActive
in interfaceDefaultRankCalculator
-
setDLRComplete
public void setDLRComplete(long time) - Specified by:
setDLRComplete
in interfaceDefaultRankCalculator
-
getDLRLastTestTime
public long getDLRLastTestTime()- Specified by:
getDLRLastTestTime
in interfaceDefaultRankCalculator
-
getDLRLastTestSpeed
public int getDLRLastTestSpeed()- Specified by:
getDLRLastTestSpeed
in interfaceDefaultRankCalculator
-
getDLRLastTestETA
public long getDLRLastTestETA()- Specified by:
getDLRLastTestETA
in interfaceDefaultRankCalculator
-
getDLRTrace
- Specified by:
getDLRTrace
in interfaceDefaultRankCalculator
-
toString
-
changeChecker
public boolean changeChecker()Check Seeders for various changes not triggered by listeners- Specified by:
changeChecker
in interfaceDefaultRankCalculator
- Returns:
- True: something changed
-
getLightSeedEligibility
public long getLightSeedEligibility()- Specified by:
getLightSeedEligibility
in interfaceDefaultRankCalculator
-
updateLightSeedEligibility
public boolean updateLightSeedEligibility(boolean has_slots) - Specified by:
updateLightSeedEligibility
in interfaceDefaultRankCalculator
-
getReservedSlot
- Specified by:
getReservedSlot
in interfaceDefaultRankCalculator
-
setReservedSlot
- Specified by:
setReservedSlot
in interfaceDefaultRankCalculator
-
activationRequest
- Specified by:
activationRequest
in interfaceDefaultRankCalculator
-
setUserData
- Specified by:
setUserData
in interfaceDefaultRankCalculator
-
getUserData
- Specified by:
getUserData
in interfaceDefaultRankCalculator
-