Esempio n. 1
0
  /**
   * Display information about the BitTorrent client state.
   *
   * <p>This emits an information line in the log about this client's state. It includes the number
   * of choked peers, number of connected peers, number of known peers, information about the
   * torrent availability and completion and current transmission rates.
   */
  public synchronized void info() {
    float dl = 0;
    float ul = 0;
    int numConnected = 0;
    for (SharingPeer peer : getConnectedPeers()) {
      dl += peer.getDLRate().get();
      ul += peer.getULRate().get();
      numConnected++;
    }

    for (SharedTorrent torrent : this.torrents.values()) {
      logger.debug(
          "{} {}/{} pieces ({}%) [{}/{}] with {}/{} peers at {}/{} kB/s.",
          new Object[] {
            torrent.getClientState().name(),
            torrent.getCompletedPieces().cardinality(),
            torrent.getPieceCount(),
            String.format("%.2f", torrent.getCompletion()),
            torrent.getAvailablePieces().cardinality(),
            torrent.getRequestedPieces().cardinality(),
            numConnected,
            this.peers.size(),
            String.format("%.2f", dl / 1024.0),
            String.format("%.2f", ul / 1024.0),
          });
    }
  }