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 Stringprivate Stringprivate static final ThreadPoolprivate static final intWait XX ms before really changing activity (DL or CDing) state when state changes via speed changeprivate booleanprivate booleanprivate static booleanprivate static booleanprivate static booleanprivate booleanprivate static booleanprivate static COConfigurationListenerFor loading config settingsprivate final DownloadManagerprivate final Downloadprivate longprivate booleanprivate intprivate longprivate longprivate longprivate intprivate intprivate AEMonitorprivate RankCalculatorReal.SRprivate static final intForce torrent to be "Actively Seeding/Downloading" for this many ms upon start of torrent.private static final longprivate static final longprivate static intprivate static intprivate static intprivate static intprivate static intprivate static intprivate static intprivate static intprivate static intprivate static intprivate static intprivate static intRanking System to useprivate static intprivate static intprivate static intprivate long(package private) int(package private) int(package private) int(package private) booleanprivate longprivate longprivate longprivate longprivate longprivate static intMin # of Peers needed before boosting the rank of downloads with no seedsprivate static intprivate static intMin Speed needed to count a incomplete download as being actively downloadingprivate static intMin speed needed to count a complete download as being actively seedingprotected static longprivate static longprivate static final TagFeatureRateLimit[]private static intprivate RankCalculatorSlotReserverprivate final StartStopRulesDefaultPluginprivate static intAmount to shift over the rank of the SEEDONLY ranking type, to make room in case the user has fallback to SPRATIO set.private static intMaximium ranking that a torrent can get using the SPRATIO ranking typeprivate static final longprivate longprivate longprivate Stringprivate TagFeatureRateLimit[]private TagFeatureRateLimit[]private longprivate longFields inherited from interface 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_ATFields inherited from interface 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) booleanactivationRequest(Runnable to_do) voidaddStateAttributeListener(DownloadManagerStateAttributeListener l, String attribute, int event_type) voidappendTrace(String str) voidattributeEventOccurred(DownloadManager download, String attribute, int event_type) private intGet # of peers not including usprivate intcalcPeersNoUs(Download download, DownloadScrapeResult sr) intprivate intcalcSeedsNoUs(Download download, DownloadScrapeResult sr) Get # of seeds, not including us, AND including fake full copiesprivate intcalcSeedsNoUs(Download download, DownloadScrapeResult sr, int numPeers) Get # of seeds, not including us, AND including fake full copiesbooleanCheck Seeders for various changes not triggered by listenersprivate static voidcheckConfigListener(PluginConfig config) intSort first by SeedingRank Descending, then by Position Ascending.intvoiddestroy()booleanRetrieves whether the torrent is "actively" downloadingbooleanRetrieves whether the torrent is "actively" seedinggetAggregatedScrapeResult(boolean b) booleanintlongintlonglongint[]intintbooleanlonglonggetName()intlongintAssign Seeding Rank based on RankTypeintlongintgetState()longgetTrace()longgetUserData(Object key) voidbooleanbooleanbooleanbooleanbooleanDoes the torrent match First Priority criteria?booleanbooleanbooleanisMoving()booleanisQueued()voidmoveTo(int pos) private booleanpisFirstPriority(boolean ignore0Peers, boolean is_test, boolean for_tag_fp) voidstatic voidLoad config values into the static variablesvoidremoveStateAttributeListener(DownloadManagerStateAttributeListener l, String attribute, int event_type) voidvoidvoidscrapeReceived(DownloadScrapeResult result) booleanvoidsetDLRActive(long time) voidsetDLRComplete(long time) voidvoidsetPosition(int pos) voidprivate voidvoidsetUserData(Object key, Object value) voidvoidstopAndQueue(String reason) booleantoString()booleanupdateLightSeedEligibility(boolean has_slots) private voidMethods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface DownloadManagerStateAttributeListener
alwaysInform
-
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
protected static long minTimeAlive -
minTimeAliveWhenActive
private static long minTimeAliveWhenActive -
bAutoStart0Peers
private static boolean bAutoStart0Peers -
iTimed_MinSeedingTimeWithPeers
private static int iTimed_MinSeedingTimeWithPeers -
iTimed_MaxSeedingTimeWithPeers
private static int iTimed_MaxSeedingTimeWithPeers -
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 -
timedRotationSeedingStart
private long timedRotationSeedingStart -
timedRotationSeedingStartMinSeeding
private long timedRotationSeedingStartMinSeeding -
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
-
checkConfigListener
-
attributeEventOccurred
- Specified by:
attributeEventOccurredin interfaceDownloadManagerStateAttributeListener
-
destroy
public void destroy()- Specified by:
destroyin interfaceDefaultRankCalculator
-
reloadConfigParams
Load config values into the static variables- Parameters:
cfg-
-
compareTo
Sort first by SeedingRank Descending, then by Position Ascending.- Specified by:
compareToin interfaceComparable<DefaultRankCalculator>
-
compareToIgnoreStopped
- Specified by:
compareToIgnoreStoppedin interfaceDefaultRankCalculator
-
getRelatedTo
- Specified by:
getRelatedToin interfaceDefaultRankCalculator
-
getName
- Specified by:
getNamein interfaceDefaultRankCalculator
-
getState
public int getState()- Specified by:
getStatein interfaceDefaultRankCalculator
-
getCoreState
public int getCoreState()- Specified by:
getCoreStatein interfaceDefaultRankCalculator
-
addStateAttributeListener
public void addStateAttributeListener(DownloadManagerStateAttributeListener l, String attribute, int event_type) - Specified by:
addStateAttributeListenerin interfaceDefaultRankCalculator
-
removeStateAttributeListener
public void removeStateAttributeListener(DownloadManagerStateAttributeListener l, String attribute, int event_type) - Specified by:
removeStateAttributeListenerin interfaceDefaultRankCalculator
-
supportsPosition
public boolean supportsPosition()- Specified by:
supportsPositionin interfaceDefaultRankCalculator
-
getPosition
public int getPosition()- Specified by:
getPositionin interfaceDefaultRankCalculator
-
setPosition
public void setPosition(int pos) - Specified by:
setPositionin interfaceDefaultRankCalculator
-
moveTo
public void moveTo(int pos) - Specified by:
moveToin interfaceDefaultRankCalculator
-
isControllable
public boolean isControllable()- Specified by:
isControllablein interfaceDefaultRankCalculator
-
isForceActive
public boolean isForceActive()- Specified by:
isForceActivein interfaceDefaultRankCalculator
-
isQueued
public boolean isQueued()- Specified by:
isQueuedin interfaceDefaultRankCalculator
-
isDownloading
public boolean isDownloading()- Specified by:
isDownloadingin interfaceDefaultRankCalculator
-
isChecking
public boolean isChecking()- Specified by:
isCheckingin interfaceDefaultRankCalculator
-
isMoving
public boolean isMoving()- Specified by:
isMovingin interfaceDefaultRankCalculator
-
isForceStart
public boolean isForceStart()- Specified by:
isForceStartin interfaceDefaultRankCalculator
-
isComplete
public boolean isComplete()- Specified by:
isCompletein interfaceDefaultRankCalculator
-
initialize
- Specified by:
initializein interfaceDefaultRankCalculator- Throws:
DownloadException
-
start
- Specified by:
startin interfaceDefaultRankCalculator- Throws:
DownloadException
-
restart
- Specified by:
restartin interfaceDefaultRankCalculator- Throws:
DownloadException
-
stopAndQueue
- Specified by:
stopAndQueuein interfaceDefaultRankCalculator- Throws:
DownloadException
-
getUploadAverage
public long getUploadAverage()- Specified by:
getUploadAveragein interfaceDefaultRankCalculator
-
getDownloadAverage
public long getDownloadAverage()- Specified by:
getDownloadAveragein interfaceDefaultRankCalculator
-
getTimeStarted
public long getTimeStarted()- Specified by:
getTimeStartedin interfaceDefaultRankCalculator
-
getSizeExcludingDND
public long getSizeExcludingDND()- Specified by:
getSizeExcludingDNDin interfaceDefaultRankCalculator
-
getRemainingExcludingDND
public long getRemainingExcludingDND()- Specified by:
getRemainingExcludingDNDin interfaceDefaultRankCalculator
-
getFilePriorityStats
public int[] getFilePriorityStats()- Specified by:
getFilePriorityStatsin interfaceDefaultRankCalculator
-
getAggregatedScrapeResult
- Specified by:
getAggregatedScrapeResultin interfaceDefaultRankCalculator
-
scrapeResultOk
public boolean scrapeResultOk()- Specified by:
scrapeResultOkin interfaceDefaultRankCalculator
-
calcSeedsNoUs
public int calcSeedsNoUs()- Specified by:
calcSeedsNoUsin 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:
getActivelyDownloadingin interfaceDefaultRankCalculator- Returns:
- true: actively downloading
-
getMinTimeSeedingMillis
public long getMinTimeSeedingMillis()- Specified by:
getMinTimeSeedingMillisin interfaceDefaultRankCalculator
-
getActivelySeeding
public boolean getActivelySeeding()Retrieves whether the torrent is "actively" seeding- Specified by:
getActivelySeedingin interfaceDefaultRankCalculator- Returns:
- true: actively seeding
-
setupTagData
private void setupTagData() -
getTagsWithDLLimits
- Specified by:
getTagsWithDLLimitsin interfaceDefaultRankCalculator
-
getTagsWithCDLimits
- Specified by:
getTagsWithCDLimitsin interfaceDefaultRankCalculator
-
getLastScrapeResultOk
public boolean getLastScrapeResultOk()- Specified by:
getLastScrapeResultOkin interfaceDefaultRankCalculator
-
scrapeReceived
- Specified by:
scrapeReceivedin interfaceDefaultRankCalculator
-
updateScrapeCache
private void updateScrapeCache() -
getLastModifiedScrapeResultPeers
public int getLastModifiedScrapeResultPeers()- Specified by:
getLastModifiedScrapeResultPeersin interfaceDefaultRankCalculator
-
getLastModifiedScrapeResultSeeds
public int getLastModifiedScrapeResultSeeds()- Specified by:
getLastModifiedScrapeResultSeedsin interfaceDefaultRankCalculator
-
getExplainFP
- Specified by:
getExplainFPin interfaceDefaultRankCalculator
-
getExplainSR
- Specified by:
getExplainSRin interfaceDefaultRankCalculator
-
resetTrace
public void resetTrace()- Specified by:
resetTracein interfaceDefaultRankCalculator
-
appendTrace
- Specified by:
appendTracein interfaceDefaultRankCalculator
-
getTrace
- Specified by:
getTracein interfaceDefaultRankCalculator
-
getSeedingRank
public int getSeedingRank()Assign Seeding Rank based on RankType- Specified by:
getSeedingRankin interfaceDefaultRankCalculator- Returns:
- New Seeding Rank Value
-
recalcSeedingRank
public void recalcSeedingRank()- Specified by:
recalcSeedingRankin 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:
isFirstPriorityin interfaceDefaultRankCalculator- Returns:
- FP State
-
pisFirstPriority
private boolean pisFirstPriority(boolean ignore0Peers, boolean is_test, boolean for_tag_fp) -
getCachedIsFP
public boolean getCachedIsFP()- Specified by:
getCachedIsFPin interfaceDefaultRankCalculator- Returns:
- last calculated FP state
-
setDLRInactive
public void setDLRInactive()- Specified by:
setDLRInactivein interfaceDefaultRankCalculator
-
setDLRActive
public void setDLRActive(long time) - Specified by:
setDLRActivein interfaceDefaultRankCalculator
-
setDLRComplete
public void setDLRComplete(long time) - Specified by:
setDLRCompletein interfaceDefaultRankCalculator
-
getDLRLastTestTime
public long getDLRLastTestTime()- Specified by:
getDLRLastTestTimein interfaceDefaultRankCalculator
-
getDLRLastTestSpeed
public int getDLRLastTestSpeed()- Specified by:
getDLRLastTestSpeedin interfaceDefaultRankCalculator
-
getDLRLastTestETA
public long getDLRLastTestETA()- Specified by:
getDLRLastTestETAin interfaceDefaultRankCalculator
-
getDLRTrace
- Specified by:
getDLRTracein interfaceDefaultRankCalculator
-
toString
-
changeChecker
public boolean changeChecker()Check Seeders for various changes not triggered by listeners- Specified by:
changeCheckerin interfaceDefaultRankCalculator- Returns:
- True: something changed
-
getLightSeedEligibility
public long getLightSeedEligibility()- Specified by:
getLightSeedEligibilityin interfaceDefaultRankCalculator
-
updateLightSeedEligibility
public boolean updateLightSeedEligibility(boolean has_slots) - Specified by:
updateLightSeedEligibilityin interfaceDefaultRankCalculator
-
getReservedSlot
- Specified by:
getReservedSlotin interfaceDefaultRankCalculator
-
setReservedSlot
- Specified by:
setReservedSlotin interfaceDefaultRankCalculator
-
activationRequest
- Specified by:
activationRequestin interfaceDefaultRankCalculator
-
setUserData
- Specified by:
setUserDatain interfaceDefaultRankCalculator
-
getUserData
- Specified by:
getUserDatain interfaceDefaultRankCalculator
-