Class DownloadManagerStatsImpl
- java.lang.Object
-
- com.biglybt.core.download.impl.DownloadManagerStatsImpl
-
- All Implemented Interfaces:
DownloadManagerStats
public class DownloadManagerStatsImpl extends java.lang.Object implements DownloadManagerStats
-
-
Field Summary
-
Constructor Summary
Constructors Modifier Constructor Description protected
DownloadManagerStatsImpl(DownloadManagerImpl dm)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description private void
checkShareRatioProgress()
protected void
generateEvidence(IndentWriter writer)
float
getAvailability()
long
getAvailWentBadTime()
long
getBytesUnavailable()
int
getCompleted()
Find out percentage done of current statelong
getDataReceiveRate()
long
getDataSendRate()
long
getDiscarded()
private DiskManager
getDiskManagerIfNotTransient()
int
getDownloadCompleted(boolean bLive)
Retrieve the level of download completion, *including* DND files.long
getDownloadCompletedBytes()
Get the number of bytes of the download that we currently have.int
getDownloadRateLimitBytesPerSecond()
Get the max download rate allowed for this download.java.lang.String
getElapsedTime()
long
getETA()
*deprecated - use getSmoothedETA as the unstability of getETA is pretty badlong
getHashFailBytes()
long
getHashFailCount()
long
getPeakDataReceiveRate()
long
getPeakDataSendRate()
int
getPercentDoneExcludingDND()
long
getProtocolReceiveRate()
long
getProtocolSendRate()
int[][]
getRecentHistory()
Get any recent history.long
getRemaining()
Returns the bytes remaining.long
getRemainingExcludingDND()
long
getSecondsDownloading()
long
getSecondsOnlySeeding()
long
getSessionDataBytesReceived()
long
getSessionDataBytesSent()
int
getShareRatio()
Gives the share ratio of the torrent in 1000ths (i.e.long
getSizeExcludingDND()
private long
getSkippedFileSetSize()
long
getSmoothedDataReceiveRate()
long
getSmoothedDataSendRate()
long
getSmoothedETA()
int
getTimeSinceLastDataReceivedInSeconds(boolean this_session)
int
getTimeSinceLastDataSentInSeconds(boolean this_session)
long
getTimeStarted()
private long
getTimeStarted(boolean mono)
long
getTimeStartedSeeding()
private long
getTimeStartedSeeding(boolean mono)
long
getTotalAverage()
Swarm speedlong
getTotalAveragePerPeer()
Average for a peer in the swarmlong
getTotalDataBytesReceived()
Get the total number of bytes ever downloaded.long
getTotalDataBytesSent()
Get the total number of bytes ever uploaded.long
getTotalGoodDataBytesReceived()
data bytes received minus discards and hashfailslong
getTotalProtocolBytesReceived()
long
getTotalProtocolBytesSent()
protected long[]
getTrackerReportedStats(java.net.URL url)
int
getUploadRateLimitBytesPerSecond()
Get the max upload rate allowed for this download.private void
loadTrackerStats()
void
recalcDownloadCompleteBytes()
void
resetTotalBytesSentReceived(long new_sent, long new_received)
Resets the total bytes sent/received - will stop and start the download if it is runningvoid
restoreSessionTotals(long _saved_data_bytes_downloaded, long _saved_data_bytes_uploaded, long _saved_discarded, long _saved_hashfails, long _saved_SecondsDownloading, long _saved_SecondsOnlySeeding)
protected void
saveSessionTotals()
private void
saveTrackerStats()
void
setCompleted(int _completed)
void
setDownloadCompletedBytes(long completedBytes)
void
setDownloadRateLimitBytesPerSecond(int max_rate_bps)
Set the max download rate allowed for this download.void
setRecentHistoryRetention(boolean required)
In general history isn't available, however if this method is called it will start retention for a certain period of timeprotected void
setSavedDownloadedUploaded(long d, long u)
void
setShareRatio(int ratio)
void
setSkippedFileStats(long skipped_file_set_size, long skipped_but_downloaded)
void
setUploadRateLimitBytesPerSecond(int max_rate_bps)
Set the max upload rate allowed for this download.protected void
timerTick(int tick_count)
protected void
updateTrackerSession(TRTrackerAnnouncerRequest request)
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface com.biglybt.core.download.DownloadManagerStats
getTimeSinceLastDataReceivedInSeconds, getTimeSinceLastDataSentInSeconds
-
-
-
-
Field Detail
-
all_trackers
private static final AllTrackersManager.AllTrackers all_trackers
-
share_ratio_progress_interval
static int share_ratio_progress_interval
-
download_manager
private final DownloadManagerImpl download_manager
-
completed
private int completed
-
saved_data_bytes_downloaded
private long saved_data_bytes_downloaded
-
saved_protocol_bytes_downloaded
private long saved_protocol_bytes_downloaded
-
saved_data_bytes_uploaded
private long saved_data_bytes_uploaded
-
saved_protocol_bytes_uploaded
private long saved_protocol_bytes_uploaded
-
session_start_data_bytes_downloaded
private long session_start_data_bytes_downloaded
-
session_start_data_bytes_uploaded
private long session_start_data_bytes_uploaded
-
saved_discarded
private long saved_discarded
-
saved_hashfails
private long saved_hashfails
-
saved_SecondsDownloading
private long saved_SecondsDownloading
-
saved_SecondsOnlySeeding
private long saved_SecondsOnlySeeding
-
session_SecondsSinceDownload
private int session_SecondsSinceDownload
-
session_SecondsSinceUpload
private int session_SecondsSinceUpload
-
saved_SecondsSinceDownload
private int saved_SecondsSinceDownload
-
saved_SecondsSinceUpload
private int saved_SecondsSinceUpload
-
saved_peak_receive_rate
private long saved_peak_receive_rate
-
saved_peak_send_rate
private long saved_peak_send_rate
-
saved_skipped_file_set_size
private long saved_skipped_file_set_size
-
saved_skipped_but_downloaded
private long saved_skipped_but_downloaded
-
saved_completed_download_bytes
private long saved_completed_download_bytes
-
max_upload_rate_bps
private int max_upload_rate_bps
-
max_download_rate_bps
private int max_download_rate_bps
-
HISTORY_MAX_SECS
private static final int HISTORY_MAX_SECS
- See Also:
- Constant Field Values
-
history_retention_required
private volatile boolean history_retention_required
-
history_last_tick
private int history_last_tick
-
history
private long[][] history
-
history_pos
private int history_pos
-
history_wrapped
private boolean history_wrapped
-
last_sr_progress
private int last_sr_progress
-
HISTORY_RATE_DIV
private static final int HISTORY_RATE_DIV
- See Also:
- Constant Field Values
-
HISTORY_TIME_DIV
private static final int HISTORY_TIME_DIV
- See Also:
- Constant Field Values
-
tracker_session_stats
java.util.Map<java.lang.String,java.util.Map<java.lang.Long,long[]>> tracker_session_stats
-
stats_saver
FrequencyLimitedDispatcher stats_saver
-
-
Constructor Detail
-
DownloadManagerStatsImpl
protected DownloadManagerStatsImpl(DownloadManagerImpl dm)
-
-
Method Detail
-
getDataReceiveRate
public long getDataReceiveRate()
- Specified by:
getDataReceiveRate
in interfaceDownloadManagerStats
-
getProtocolReceiveRate
public long getProtocolReceiveRate()
- Specified by:
getProtocolReceiveRate
in interfaceDownloadManagerStats
-
getDataSendRate
public long getDataSendRate()
- Specified by:
getDataSendRate
in interfaceDownloadManagerStats
-
getProtocolSendRate
public long getProtocolSendRate()
- Specified by:
getProtocolSendRate
in interfaceDownloadManagerStats
-
getPeakDataReceiveRate
public long getPeakDataReceiveRate()
- Specified by:
getPeakDataReceiveRate
in interfaceDownloadManagerStats
-
getPeakDataSendRate
public long getPeakDataSendRate()
- Specified by:
getPeakDataSendRate
in interfaceDownloadManagerStats
-
getSmoothedDataReceiveRate
public long getSmoothedDataReceiveRate()
- Specified by:
getSmoothedDataReceiveRate
in interfaceDownloadManagerStats
-
getSmoothedDataSendRate
public long getSmoothedDataSendRate()
- Specified by:
getSmoothedDataSendRate
in interfaceDownloadManagerStats
-
getETA
public long getETA()
Description copied from interface:DownloadManagerStats
*deprecated - use getSmoothedETA as the unstability of getETA is pretty bad- Specified by:
getETA
in interfaceDownloadManagerStats
- Returns:
-
getSmoothedETA
public long getSmoothedETA()
- Specified by:
getSmoothedETA
in interfaceDownloadManagerStats
-
getCompleted
public int getCompleted()
Description copied from interface:DownloadManagerStats
Find out percentage done of current stateUse getDownloadCompleted() if you wish to find out a torrents download completion level
- Specified by:
getCompleted
in interfaceDownloadManagerStats
- Returns:
- 0 to 1000, 0% to 100% respectively When state is Allocating, Checking, or Initializing, this returns the % done of that task Any other state MAY return getDownloadCompleted()
-
setCompleted
public void setCompleted(int _completed)
- Specified by:
setCompleted
in interfaceDownloadManagerStats
-
getDownloadCompleted
public int getDownloadCompleted(boolean bLive)
Description copied from interface:DownloadManagerStats
Retrieve the level of download completion, *including* DND files.To understand the bLive parameter, you must know a bit about the Torrent activation process:
1) Torrent goes into ST_WAITING
2) Torrent moves to ST_PREPARING
3) Torrent moves to ST_DOWNLOADING or ST_SEEDINGWhile in ST_PREPARING, Completion Level is rebuilt (either via Fast Resume or via piece checking). Quite often, the download completion level before ST_PREPARING and after ST_PREPARING are identical.
Before going into ST_PREPARING, we store the download completion level. If you wish to retrieve this value instead of the live "building" one, pass false for the parameter.
- Specified by:
getDownloadCompleted
in interfaceDownloadManagerStats
- Parameters:
bLive
- true - Always returns the known completion level of the torrentfalse - In the case of ST_PREPARING, return completion level before of the torrent ST_PREPARING started. Otherwise, same as true.
- Returns:
- 0 - 1000
-
setDownloadCompletedBytes
public void setDownloadCompletedBytes(long completedBytes)
- Specified by:
setDownloadCompletedBytes
in interfaceDownloadManagerStats
-
recalcDownloadCompleteBytes
public void recalcDownloadCompleteBytes()
- Specified by:
recalcDownloadCompleteBytes
in interfaceDownloadManagerStats
-
getDownloadCompletedBytes
public long getDownloadCompletedBytes()
Description copied from interface:DownloadManagerStats
Get the number of bytes of the download that we currently have.Includes bytes downloaded for files marked as DND/Skipped
- Specified by:
getDownloadCompletedBytes
in interfaceDownloadManagerStats
-
getElapsedTime
public java.lang.String getElapsedTime()
- Specified by:
getElapsedTime
in interfaceDownloadManagerStats
-
getTimeStarted
public long getTimeStarted()
- Specified by:
getTimeStarted
in interfaceDownloadManagerStats
-
getTimeStarted
private long getTimeStarted(boolean mono)
-
getTimeStartedSeeding
public long getTimeStartedSeeding()
- Specified by:
getTimeStartedSeeding
in interfaceDownloadManagerStats
-
getTimeStartedSeeding
private long getTimeStartedSeeding(boolean mono)
-
getTotalDataBytesReceived
public long getTotalDataBytesReceived()
Description copied from interface:DownloadManagerStats
Get the total number of bytes ever downloaded.- Specified by:
getTotalDataBytesReceived
in interfaceDownloadManagerStats
- Returns:
- total bytes downloaded
-
getSessionDataBytesReceived
public long getSessionDataBytesReceived()
- Specified by:
getSessionDataBytesReceived
in interfaceDownloadManagerStats
-
getTotalGoodDataBytesReceived
public long getTotalGoodDataBytesReceived()
Description copied from interface:DownloadManagerStats
data bytes received minus discards and hashfails- Specified by:
getTotalGoodDataBytesReceived
in interfaceDownloadManagerStats
- Returns:
-
getTotalProtocolBytesReceived
public long getTotalProtocolBytesReceived()
- Specified by:
getTotalProtocolBytesReceived
in interfaceDownloadManagerStats
-
resetTotalBytesSentReceived
public void resetTotalBytesSentReceived(long new_sent, long new_received)
Description copied from interface:DownloadManagerStats
Resets the total bytes sent/received - will stop and start the download if it is running- Specified by:
resetTotalBytesSentReceived
in interfaceDownloadManagerStats
-
getTotalDataBytesSent
public long getTotalDataBytesSent()
Description copied from interface:DownloadManagerStats
Get the total number of bytes ever uploaded.- Specified by:
getTotalDataBytesSent
in interfaceDownloadManagerStats
- Returns:
- total bytes uploaded
-
getTotalProtocolBytesSent
public long getTotalProtocolBytesSent()
- Specified by:
getTotalProtocolBytesSent
in interfaceDownloadManagerStats
-
getSessionDataBytesSent
public long getSessionDataBytesSent()
- Specified by:
getSessionDataBytesSent
in interfaceDownloadManagerStats
-
setRecentHistoryRetention
public void setRecentHistoryRetention(boolean required)
Description copied from interface:DownloadManagerStats
In general history isn't available, however if this method is called it will start retention for a certain period of time- Specified by:
setRecentHistoryRetention
in interfaceDownloadManagerStats
-
getRecentHistory
public int[][] getRecentHistory()
Description copied from interface:DownloadManagerStats
Get any recent history. Returned values are send rate, receive rate, peer-swarm average and eta- Specified by:
getRecentHistory
in interfaceDownloadManagerStats
- Returns:
-
checkShareRatioProgress
private void checkShareRatioProgress()
-
timerTick
protected void timerTick(int tick_count)
-
getRemaining
public long getRemaining()
Description copied from interface:DownloadManagerStats
Returns the bytes remaining. *Includes* DND files- Specified by:
getRemaining
in interfaceDownloadManagerStats
-
getDiskManagerIfNotTransient
private DiskManager getDiskManagerIfNotTransient()
-
getDiscarded
public long getDiscarded()
- Specified by:
getDiscarded
in interfaceDownloadManagerStats
-
getHashFailCount
public long getHashFailCount()
- Specified by:
getHashFailCount
in interfaceDownloadManagerStats
-
getHashFailBytes
public long getHashFailBytes()
- Specified by:
getHashFailBytes
in interfaceDownloadManagerStats
-
getTotalAverage
public long getTotalAverage()
Description copied from interface:DownloadManagerStats
Swarm speed- Specified by:
getTotalAverage
in interfaceDownloadManagerStats
- Returns:
-
getTotalAveragePerPeer
public long getTotalAveragePerPeer()
Description copied from interface:DownloadManagerStats
Average for a peer in the swarm- Specified by:
getTotalAveragePerPeer
in interfaceDownloadManagerStats
- Returns:
-
getShareRatio
public int getShareRatio()
Description copied from interface:DownloadManagerStats
Gives the share ratio of the torrent in 1000ths (i.e. 1000 = share ratio of 1) -1 if actually infinite (downloaded = 0, uploaded > 0 ), Integer.MAX_VALUE if massive- Specified by:
getShareRatio
in interfaceDownloadManagerStats
-
setShareRatio
public void setShareRatio(int ratio)
- Specified by:
setShareRatio
in interfaceDownloadManagerStats
-
getSecondsDownloading
public long getSecondsDownloading()
- Specified by:
getSecondsDownloading
in interfaceDownloadManagerStats
-
getSecondsOnlySeeding
public long getSecondsOnlySeeding()
- Specified by:
getSecondsOnlySeeding
in interfaceDownloadManagerStats
-
getAvailability
public float getAvailability()
- Specified by:
getAvailability
in interfaceDownloadManagerStats
-
getBytesUnavailable
public long getBytesUnavailable()
- Specified by:
getBytesUnavailable
in interfaceDownloadManagerStats
-
getUploadRateLimitBytesPerSecond
public int getUploadRateLimitBytesPerSecond()
Description copied from interface:DownloadManagerStats
Get the max upload rate allowed for this download.- Specified by:
getUploadRateLimitBytesPerSecond
in interfaceDownloadManagerStats
- Returns:
- upload rate in bytes per second, 0 for unlimited, -1 for upload disabled
-
setUploadRateLimitBytesPerSecond
public void setUploadRateLimitBytesPerSecond(int max_rate_bps)
Description copied from interface:DownloadManagerStats
Set the max upload rate allowed for this download.- Specified by:
setUploadRateLimitBytesPerSecond
in interfaceDownloadManagerStats
- Parameters:
max_rate_bps
- limit in bytes per second, 0 for unlimited, -1 for upload disabled
-
getDownloadRateLimitBytesPerSecond
public int getDownloadRateLimitBytesPerSecond()
Description copied from interface:DownloadManagerStats
Get the max download rate allowed for this download.- Specified by:
getDownloadRateLimitBytesPerSecond
in interfaceDownloadManagerStats
- Returns:
- download rate in bytes per second, 0 for unlimited, -1 for download disabled
-
setDownloadRateLimitBytesPerSecond
public void setDownloadRateLimitBytesPerSecond(int max_rate_bps)
Description copied from interface:DownloadManagerStats
Set the max download rate allowed for this download.- Specified by:
setDownloadRateLimitBytesPerSecond
in interfaceDownloadManagerStats
- Parameters:
max_rate_bps
- limit in bytes per second, 0 for unlimited, -1 for download disabled
-
getTimeSinceLastDataReceivedInSeconds
public int getTimeSinceLastDataReceivedInSeconds(boolean this_session)
- Specified by:
getTimeSinceLastDataReceivedInSeconds
in interfaceDownloadManagerStats
-
getTimeSinceLastDataSentInSeconds
public int getTimeSinceLastDataSentInSeconds(boolean this_session)
- Specified by:
getTimeSinceLastDataSentInSeconds
in interfaceDownloadManagerStats
-
getAvailWentBadTime
public long getAvailWentBadTime()
- Specified by:
getAvailWentBadTime
in interfaceDownloadManagerStats
-
loadTrackerStats
private void loadTrackerStats()
-
saveTrackerStats
private void saveTrackerStats()
-
updateTrackerSession
protected void updateTrackerSession(TRTrackerAnnouncerRequest request)
-
getTrackerReportedStats
protected long[] getTrackerReportedStats(java.net.URL url)
-
saveSessionTotals
protected void saveSessionTotals()
-
setSavedDownloadedUploaded
protected void setSavedDownloadedUploaded(long d, long u)
-
restoreSessionTotals
public void restoreSessionTotals(long _saved_data_bytes_downloaded, long _saved_data_bytes_uploaded, long _saved_discarded, long _saved_hashfails, long _saved_SecondsDownloading, long _saved_SecondsOnlySeeding)
- Specified by:
restoreSessionTotals
in interfaceDownloadManagerStats
-
setSkippedFileStats
public void setSkippedFileStats(long skipped_file_set_size, long skipped_but_downloaded)
-
getSkippedFileSetSize
private long getSkippedFileSetSize()
-
getRemainingExcludingDND
public long getRemainingExcludingDND()
- Specified by:
getRemainingExcludingDND
in interfaceDownloadManagerStats
-
getSizeExcludingDND
public long getSizeExcludingDND()
- Specified by:
getSizeExcludingDND
in interfaceDownloadManagerStats
-
getPercentDoneExcludingDND
public int getPercentDoneExcludingDND()
- Specified by:
getPercentDoneExcludingDND
in interfaceDownloadManagerStats
-
generateEvidence
protected void generateEvidence(IndentWriter writer)
-
-