org.gudy.azureus2.core3.download.impl
Class DownloadManagerStatsImpl

java.lang.Object
  extended by org.gudy.azureus2.core3.download.impl.DownloadManagerStatsImpl
All Implemented Interfaces:
DownloadManagerStats

public class DownloadManagerStatsImpl
extends java.lang.Object
implements DownloadManagerStats


Constructor Summary
protected DownloadManagerStatsImpl(DownloadManagerImpl dm)
           
 
Method Summary
protected  void generateEvidence(IndentWriter writer)
           
 float getAvailability()
           
 long getAvailWentBadTime()
           
 long getBytesUnavailable()
           
 int getCompleted()
          Find out percentage done of current state
 long getDataReceiveRate()
           
 long getDataSendRate()
           
 long getDiscarded()
           
 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 bad
 long 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()
           
 long getSmoothedDataReceiveRate()
           
 long getSmoothedDataSendRate()
           
 long getSmoothedETA()
           
 int getTimeSinceLastDataReceivedInSeconds()
           
 int getTimeSinceLastDataSentInSeconds()
           
 long getTimeStarted()
           
 long getTimeStartedSeeding()
           
 long getTotalAverage()
          Swarm speed
 long getTotalAveragePerPeer()
          Average for a peer in the swarm
 long 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 hashfails
 long getTotalProtocolBytesReceived()
           
 long getTotalProtocolBytesSent()
           
 int getUploadRateLimitBytesPerSecond()
          Get the max upload rate allowed for this download.
 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 running
 void 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()
           
 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 time
protected  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)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DownloadManagerStatsImpl

protected DownloadManagerStatsImpl(DownloadManagerImpl dm)
Method Detail

getDataReceiveRate

public long getDataReceiveRate()
Specified by:
getDataReceiveRate in interface DownloadManagerStats

getProtocolReceiveRate

public long getProtocolReceiveRate()
Specified by:
getProtocolReceiveRate in interface DownloadManagerStats

getDataSendRate

public long getDataSendRate()
Specified by:
getDataSendRate in interface DownloadManagerStats

getProtocolSendRate

public long getProtocolSendRate()
Specified by:
getProtocolSendRate in interface DownloadManagerStats

getPeakDataReceiveRate

public long getPeakDataReceiveRate()
Specified by:
getPeakDataReceiveRate in interface DownloadManagerStats

getPeakDataSendRate

public long getPeakDataSendRate()
Specified by:
getPeakDataSendRate in interface DownloadManagerStats

getSmoothedDataReceiveRate

public long getSmoothedDataReceiveRate()
Specified by:
getSmoothedDataReceiveRate in interface DownloadManagerStats

getSmoothedDataSendRate

public long getSmoothedDataSendRate()
Specified by:
getSmoothedDataSendRate in interface DownloadManagerStats

getETA

public long getETA()
Description copied from interface: DownloadManagerStats
*deprecated - use getSmoothedETA as the unstability of getETA is pretty bad

Specified by:
getETA in interface DownloadManagerStats
Returns:

getSmoothedETA

public long getSmoothedETA()
Specified by:
getSmoothedETA in interface DownloadManagerStats

getCompleted

public int getCompleted()
Description copied from interface: DownloadManagerStats
Find out percentage done of current state

Use getDownloadCompleted() if you wish to find out a torrents download completion level

Specified by:
getCompleted in interface DownloadManagerStats
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 interface DownloadManagerStats

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_SEEDING

While 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 interface DownloadManagerStats
Parameters:
bLive - true - Always returns the known completion level of the torrent

false - 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 interface DownloadManagerStats

recalcDownloadCompleteBytes

public void recalcDownloadCompleteBytes()
Specified by:
recalcDownloadCompleteBytes in interface DownloadManagerStats

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 interface DownloadManagerStats

getElapsedTime

public java.lang.String getElapsedTime()
Specified by:
getElapsedTime in interface DownloadManagerStats

getTimeStarted

public long getTimeStarted()
Specified by:
getTimeStarted in interface DownloadManagerStats

getTimeStartedSeeding

public long getTimeStartedSeeding()
Specified by:
getTimeStartedSeeding in interface DownloadManagerStats

getTotalDataBytesReceived

public long getTotalDataBytesReceived()
Description copied from interface: DownloadManagerStats
Get the total number of bytes ever downloaded.

Specified by:
getTotalDataBytesReceived in interface DownloadManagerStats
Returns:
total bytes downloaded

getSessionDataBytesReceived

public long getSessionDataBytesReceived()
Specified by:
getSessionDataBytesReceived in interface DownloadManagerStats

getTotalGoodDataBytesReceived

public long getTotalGoodDataBytesReceived()
Description copied from interface: DownloadManagerStats
data bytes received minus discards and hashfails

Specified by:
getTotalGoodDataBytesReceived in interface DownloadManagerStats
Returns:

getTotalProtocolBytesReceived

public long getTotalProtocolBytesReceived()
Specified by:
getTotalProtocolBytesReceived in interface DownloadManagerStats

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 interface DownloadManagerStats

getTotalDataBytesSent

public long getTotalDataBytesSent()
Description copied from interface: DownloadManagerStats
Get the total number of bytes ever uploaded.

Specified by:
getTotalDataBytesSent in interface DownloadManagerStats
Returns:
total bytes uploaded

getTotalProtocolBytesSent

public long getTotalProtocolBytesSent()
Specified by:
getTotalProtocolBytesSent in interface DownloadManagerStats

getSessionDataBytesSent

public long getSessionDataBytesSent()
Specified by:
getSessionDataBytesSent in interface DownloadManagerStats

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 interface DownloadManagerStats

getRecentHistory

public int[][] getRecentHistory()
Description copied from interface: DownloadManagerStats
Get any recent history. Returned values are send rate, receive rate and peer-swarm average

Specified by:
getRecentHistory in interface DownloadManagerStats
Returns:

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 interface DownloadManagerStats

getDiscarded

public long getDiscarded()
Specified by:
getDiscarded in interface DownloadManagerStats

getHashFailCount

public long getHashFailCount()
Specified by:
getHashFailCount in interface DownloadManagerStats

getHashFailBytes

public long getHashFailBytes()
Specified by:
getHashFailBytes in interface DownloadManagerStats

getTotalAverage

public long getTotalAverage()
Description copied from interface: DownloadManagerStats
Swarm speed

Specified by:
getTotalAverage in interface DownloadManagerStats
Returns:

getTotalAveragePerPeer

public long getTotalAveragePerPeer()
Description copied from interface: DownloadManagerStats
Average for a peer in the swarm

Specified by:
getTotalAveragePerPeer in interface DownloadManagerStats
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)

Specified by:
getShareRatio in interface DownloadManagerStats

setShareRatio

public void setShareRatio(int ratio)
Specified by:
setShareRatio in interface DownloadManagerStats

getSecondsDownloading

public long getSecondsDownloading()
Specified by:
getSecondsDownloading in interface DownloadManagerStats

getSecondsOnlySeeding

public long getSecondsOnlySeeding()
Specified by:
getSecondsOnlySeeding in interface DownloadManagerStats

getAvailability

public float getAvailability()
Specified by:
getAvailability in interface DownloadManagerStats

getBytesUnavailable

public long getBytesUnavailable()
Specified by:
getBytesUnavailable in interface DownloadManagerStats

getUploadRateLimitBytesPerSecond

public int getUploadRateLimitBytesPerSecond()
Description copied from interface: DownloadManagerStats
Get the max upload rate allowed for this download.

Specified by:
getUploadRateLimitBytesPerSecond in interface DownloadManagerStats
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 interface DownloadManagerStats
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 interface DownloadManagerStats
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 interface DownloadManagerStats
Parameters:
max_rate_bps - limit in bytes per second, 0 for unlimited, -1 for download disabled

getTimeSinceLastDataReceivedInSeconds

public int getTimeSinceLastDataReceivedInSeconds()
Specified by:
getTimeSinceLastDataReceivedInSeconds in interface DownloadManagerStats

getTimeSinceLastDataSentInSeconds

public int getTimeSinceLastDataSentInSeconds()
Specified by:
getTimeSinceLastDataSentInSeconds in interface DownloadManagerStats

getAvailWentBadTime

public long getAvailWentBadTime()
Specified by:
getAvailWentBadTime in interface DownloadManagerStats

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 interface DownloadManagerStats

setSkippedFileStats

public void setSkippedFileStats(long skipped_file_set_size,
                                long skipped_but_downloaded)

getRemainingExcludingDND

public long getRemainingExcludingDND()
Specified by:
getRemainingExcludingDND in interface DownloadManagerStats

getSizeExcludingDND

public long getSizeExcludingDND()
Specified by:
getSizeExcludingDND in interface DownloadManagerStats

getPercentDoneExcludingDND

public int getPercentDoneExcludingDND()
Specified by:
getPercentDoneExcludingDND in interface DownloadManagerStats

generateEvidence

protected void generateEvidence(IndentWriter writer)