Search in sources :

Example 1 with PeerManagerStats

use of com.biglybt.pif.peers.PeerManagerStats in project BiglyBT by BiglySoftware.

the class TranscodeJobImpl method updateStatus.

protected void updateStatus(boolean report_change) {
    synchronized (this) {
        if (download_ok) {
            return;
        }
        long downloaded = file.getDownloaded();
        long length = file.getLength();
        if (download == null || downloaded == length) {
            download_ok = true;
        } else {
            int percent_done = (int) (100 * downloaded / length);
            if (percent_done >= TRANSCODE_OK_DL_PERCENT) {
                download_ok = true;
            } else {
                PeerManager pm = download.getPeerManager();
                if (pm != null) {
                    PeerManagerStats stats = pm.getStats();
                    int connected_seeds = stats.getConnectedSeeds();
                    int connected_leechers = stats.getConnectedLeechers();
                    if (connected_seeds > 10 && connected_seeds > connected_leechers) {
                        download_ok = true;
                    }
                } else {
                    int state = download.getState();
                    if (state == Download.ST_STOPPED) {
                        try {
                            download.restart();
                        } catch (Throwable e) {
                            Debug.out(e);
                        }
                    }
                }
            }
        }
    }
    if (download_ok && report_change) {
        queue.jobChanged(this, true, false);
    }
}
Also used : PeerManager(com.biglybt.pif.peers.PeerManager) PeerManagerStats(com.biglybt.pif.peers.PeerManagerStats)

Aggregations

PeerManager (com.biglybt.pif.peers.PeerManager)1 PeerManagerStats (com.biglybt.pif.peers.PeerManagerStats)1