public Integer getActiveTorrents() {
    for (TorrentHandle t : session.getTorrents()) {}

    return 0;
  }
  public void startSeedingLibrary() {

    Tools.dbInit();
    List<Library> library = LIBRARY.findAll();
    library.isEmpty();
    Tools.dbClose();

    // start sharing them
    Integer i = 0;
    while (i < library.size()) {
      log.info("File #" + i.toString() + "/" + library.size() + " songs in library");
      Library track = library.get(i);
      String torrentPath = track.getString("torrent_path");
      String filePath = track.getString("file_path");

      File outputParent = new File(filePath).getParentFile();

      TorrentHandle torrent = addTorrent(outputParent, new File(torrentPath));

      // Set up the scanInfo
      ScanInfo si = ScanInfo.create(new File(filePath));
      si.setStatus(ScanStatus.Seeding);
      si.setMbid(track.getString("mbid"));
      scanInfos.add(si);

      // Do increments of every x, but only after the x'th torrent announce was a success
      if (i % 25 == 0) {
        //				log.info("active torrents:" + session.getStatus().get)
        torrent.setAutoManaged(false);
        torrent.resume();
        torrent.forceReannounce();
        try {
          final CountDownLatch signal = new CountDownLatch(1);

          session.addListener(
              new TorrentAlertAdapter(torrent) {
                @Override
                public void trackerReply(TrackerReplyAlert alert) {
                  log.info("Tracked reply received for torrent " + torrent.getName());
                  signal.countDown();
                  torrent.setAutoManaged(true);
                }

                @Override
                public void peerConnect(PeerConnectAlert alert) {
                  log.info("Peer connect alert received for torrent " + torrent.getName());
                  signal.countDown();
                  torrent.setAutoManaged(true);
                }
              });

          signal.await();
        } catch (InterruptedException e) {
          // TODO Auto-generated catch block
          e.printStackTrace();
        }
      }

      i++;
    }

    log.info("Done seeding library, total of " + session.getTorrents().size() + " torrents shared");
  }