Class TorrentStats

java.lang.Object
com.frostwire.jlibtorrent.TorrentStats

public final class TorrentStats extends Object
To be used in concert with SessionManager.

The call to SessionManager#postTorrentUpdates() is done approximately every second. This class holds a time series per metric and a time series for the sampling time.

  • Nested Class Summary

    Nested Classes
    Modifier and Type
    Class
    Description
    static enum 
     
  • Constructor Summary

    Constructors
    Constructor
    Description
    TorrentStats(Sha1Hash infoHash, int maxSamples)
     
  • Method Summary

    Modifier and Type
    Method
    Description
    long
    This is the accumulated download payload byte counters.
    long
    This is the accumulated upload payload byte counter.
    int
    The total transfer rate of payload only, not counting protocol chatter.
    int
    The total rates for all peers for this torrent.
    boolean
    Returns true if all pieces that have a priority > 0 are downloaded.
    boolean
    set to true if the torrent is paused and false otherwise.
    boolean
    true if all pieces have been downloaded.
    boolean
    true when the torrent is in sequential download mode.
    long
     
    int
    The number of seeds in our peer list and the total number of peers (including seeds).
    int
    The number of seeds in our peer list and the total number of peers (including seeds).
    int
     
    boolean
    true if this torrent has unsaved changes to its download state and statistics since the last resume data was saved.
    int
    Returns the number of peer connections this torrent has, including half-open connections that hasn't completed the bittorrent handshake yet.
    int
    The number of peers this torrent currently is connected to.
    int
    Returns the number of pieces that has been downloaded so you don't have to count yourself.
    int
    The number of peers that are seeding that this client is currently connected to.
    float
    A value in the range [0, 1], that represents the progress of the torrent's current task.
    int
    progress parts per million (progress * 1000000) when disabling floating point operations, this is the only option to query progress
     
    The main state the torrent is in.
    long
    The total number of bytes of the file(s) that we have.
    long
    The number of bytes downloaded and uploaded to all peers, accumulated, this session only.
    long
    Counts the amount of bytes received this session, but only the actual payload data (i.e the interesting data), these counters ignore any protocol overhead.
    long
    Counts the amount of bytes send this session, but only the actual payload data (i.e the interesting data), these counters ignore any protocol overhead.
    long
    The number of bytes downloaded and uploaded to all peers, accumulated, this session only.
    long
    The total number of bytes we want to download.
    long
    The number of bytes we have downloaded, only counting the pieces that we actually want to download.
    void
     
    int
    The total transfer rate of payload only, not counting protocol chatter.
    int
    The total rates for all peers for this torrent.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • TorrentStats

      public TorrentStats(Sha1Hash infoHash, int maxSamples)
  • Method Details

    • maxSamples

      public int maxSamples()
    • series

      public IntSeries series(TorrentStats.SeriesMetric metric)
    • last

      public long last(TorrentStats.SeriesMetric metric)
    • totalDownload

      public long totalDownload()
      The number of bytes downloaded and uploaded to all peers, accumulated, this session only. The session is considered to restart when a torrent is paused and restarted again. When a torrent is paused, these counters are reset to 0. If you want complete, persistent, stats, see allTimeUpload and allTimeDownload.
    • totalUpload

      public long totalUpload()
      The number of bytes downloaded and uploaded to all peers, accumulated, this session only. The session is considered to restart when a torrent is paused and restarted again. When a torrent is paused, these counters are reset to 0. If you want complete, persistent, stats, see allTimeUpload and allTimeDownload.
    • totalPayloadDownload

      public long totalPayloadDownload()
      Counts the amount of bytes received this session, but only the actual payload data (i.e the interesting data), these counters ignore any protocol overhead.
      Returns:
    • totalPayloadUpload

      public long totalPayloadUpload()
      Counts the amount of bytes send this session, but only the actual payload data (i.e the interesting data), these counters ignore any protocol overhead.
      Returns:
    • totalDone

      public long totalDone()
      The total number of bytes of the file(s) that we have. All this does not necessarily has to be downloaded during this session (that's total_payload_download).
      Returns:
      the value
    • totalWantedDone

      public long totalWantedDone()
      The number of bytes we have downloaded, only counting the pieces that we actually want to download. i.e. excluding any pieces that we have but have priority 0 (i.e. not wanted).
    • totalWanted

      public long totalWanted()
      The total number of bytes we want to download. This may be smaller than the total torrent size in case any pieces are prioritized to 0, i.e. not wanted.
    • allTimeUpload

      public long allTimeUpload()
      This is the accumulated upload payload byte counter. They are saved in and restored from resume data to keep totals across sessions.
    • allTimeDownload

      public long allTimeDownload()
      This is the accumulated download payload byte counters. They are saved in and restored from resume data to keep totals across sessions.
    • progress

      public float progress()
      A value in the range [0, 1], that represents the progress of the torrent's current task. It may be checking files or downloading.
      Returns:
      the progress in [0, 1]
    • progressPpm

      public int progressPpm()
      progress parts per million (progress * 1000000) when disabling floating point operations, this is the only option to query progress

      reflects the same value as ``progress``, but instead in a range [0, 1000000] (ppm = parts per million). When floating point operations are disabled, this is the only alternative to the floating point value in.

      Returns:
      the progress in parts per million (progress * 1000000)
    • downloadRate

      public int downloadRate()
      The total rates for all peers for this torrent. These will usually have better precision than summing the rates from all peers. The rates are given as the number of bytes per second.
    • uploadRate

      public int uploadRate()
      The total rates for all peers for this torrent. These will usually have better precision than summing the rates from all peers. The rates are given as the number of bytes per second.
    • downloadPayloadRate

      public int downloadPayloadRate()
      The total transfer rate of payload only, not counting protocol chatter. This might be slightly smaller than the other rates, but if projected over a long time (e.g. when calculating ETA:s) the difference may be noticeable.
    • uploadPayloadRate

      public int uploadPayloadRate()
      The total transfer rate of payload only, not counting protocol chatter. This might be slightly smaller than the other rates, but if projected over a long time (e.g. when calculating ETA:s) the difference may be noticeable.
    • numSeeds

      public int numSeeds()
      The number of peers that are seeding that this client is currently connected to.
    • numPeers

      public int numPeers()
      The number of peers this torrent currently is connected to. Peer connections that are in the half-open state (is attempting to connect) or are queued for later connection attempt do not count. Although they are visible in the peer list when you call get_peer_info().
    • listSeeds

      public int listSeeds()
      The number of seeds in our peer list and the total number of peers (including seeds). We are not necessarily connected to all the peers in our peer list. This is the number of peers we know of in total, including banned peers and peers that we have failed to connect to.
    • listPeers

      public int listPeers()
      The number of seeds in our peer list and the total number of peers (including seeds). We are not necessarily connected to all the peers in our peer list. This is the number of peers we know of in total, including banned peers and peers that we have failed to connect to.
    • numPieces

      public int numPieces()
      Returns the number of pieces that has been downloaded so you don't have to count yourself. This can be used to see if anything has updated since last time if you want to keep a graph of the pieces up to date.
      Returns:
      the number of pieces that has been downloaded
    • numConnections

      public int numConnections()
      Returns the number of peer connections this torrent has, including half-open connections that hasn't completed the bittorrent handshake yet.

      This is always >= num_peers.

      Returns:
      the number of peer connections
    • state

      public TorrentStatus.State state()
      The main state the torrent is in. See torrent_status::state_t.
      Returns:
      the state
    • needSaveResume

      public boolean needSaveResume()
      true if this torrent has unsaved changes to its download state and statistics since the last resume data was saved.
      Returns:
    • isPaused

      public boolean isPaused()
      set to true if the torrent is paused and false otherwise. It's only true if the torrent itself is paused. If the torrent is not running because the session is paused, this is still false. To know if a torrent is active or not, you need to inspect both ``torrent_status::paused`` and ``session::is_paused()``.
      Returns:
    • isSequentialDownload

      public boolean isSequentialDownload()
      true when the torrent is in sequential download mode. In this mode pieces are downloaded in order rather than rarest first.
      Returns:
    • isSeeding

      public boolean isSeeding()
      true if all pieces have been downloaded.
      Returns:
    • isFinished

      public boolean isFinished()
      Returns true if all pieces that have a priority > 0 are downloaded. There is only a distinction between finished and seeding if some pieces or files have been set to priority 0, i.e. are not downloaded.
      Returns:
      true if all pieces that have a priority > 0 are downloaded.
    • update

      public void update(TorrentStatus status)