亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關于我們
? 蟲蟲下載站

?? defaultrankcalculator.java

?? 基于JXTA開發平臺的下載軟件開發源代碼
?? JAVA
?? 第 1 頁 / 共 2 頁
字號:
/*
 * Copyright (C) 2005, 2006 Aelitis, All Rights Reserved.
 *
 * This program is free software; you can redistribute it and/or
 * modify it under the terms of the GNU General Public License
 * as published by the Free Software Foundation; either version 2
 * of the License, or (at your option) any later version.
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
 *
 * AELITIS, SAS au capital de 46,603.30 euros
 * 8 Allee Lenotre, La Grille Royale, 78600 Le Mesnil le Roi, France.
 * 
 */
package com.aelitis.azureus.plugins.startstoprules.defaultplugin;

import org.gudy.azureus2.core3.config.COConfigurationListener;
import org.gudy.azureus2.core3.config.COConfigurationManager;
import org.gudy.azureus2.core3.util.AEMonitor;
import org.gudy.azureus2.core3.util.SystemTime;
import org.gudy.azureus2.plugins.PluginConfig;
import org.gudy.azureus2.plugins.download.Download;
import org.gudy.azureus2.plugins.download.DownloadScrapeResult;
import org.gudy.azureus2.plugins.download.DownloadStats;
import org.gudy.azureus2.plugins.logging.LoggerChannel;

/**
 * @author TuxPaper
 * @created Dec 13, 2005
 *
 */
public class DefaultRankCalculator implements Comparable {
	/** All of the First Priority rules must match */
	public static final int FIRSTPRIORITY_ALL = 0;

	/** Any of the First Priority rules must match */
	public static final int FIRSTPRIORITY_ANY = 1;

	/** 
	 * Force torrent to be "Actively Seeding/Downloading" for this many ms upon
	 * start of torrent.
	 */
	private static final int FORCE_ACTIVE_FOR = 30000;

	/** 
	 * Wait XX ms before really changing activity (DL or CDing) state when
	 * state changes via speed change
	 */
	private static final int ACTIVE_CHANGE_WAIT = 10000;

	/** Maximium ranking that a torrent can get using the SPRATIO ranking type */
	private static int SPRATIO_BASE_LIMIT = 99999;

	/** 
	 * Amount to shift over the rank of the SEEDONLY ranking type, to make room
	 * in case the user has fallback to SPRATIO set.
	 */
	private static int SEEDONLY_SHIFT = SPRATIO_BASE_LIMIT + 1;

	/**
	 * For loading config settings
	 */
	private static COConfigurationListener configListener = null;

	//
	// Seeding Rank (SR) Limits and Values

	/** Rank that complete starts at (and incomplete ends at + 1) */
	public static final int SR_COMPLETE_STARTS_AT = 1000000000; // billion

	/** Maximimum ranking for time queue mode. 1 unit is a second */
	public static final int SR_TIMED_QUEUED_ENDS_AT = 999999; // 11.57 days

	/** Ranks below this value are for torrents to be ignored (moved to bottom & queued) */
	public static final int SR_IGNORED_LESS_THAN = -1;

	/** Seeding Rank value when download is marked as not queued */
	public static final int SR_NOTQUEUED = -2;

	/** Seeding Rank value when download is marked as S:P Ratio Met for FP */
	public static final int SR_FP_SPRATIOMET = -3;

	/** Seeding Rank value when download is marked as P:1S Ratio Met */
	public static final int SR_RATIOMET = -4;

	/** Seeding Rank value when download is marked as # Seeds Met */
	public static final int SR_NUMSEEDSMET = -5;

	/** Seeding Rank value when download is marked as 0 Peers and FP */
	public static final int SR_FP0PEERS = -6;

	/** Seeding Rank value when download is marked as 0 Peers */
	public static final int SR_0PEERS = -7;

	/** Seeding Rank value when download is marked as Share Ratio Met */
	public static final int SR_SHARERATIOMET = -8;

	//
	// Static config values

	/** Ranking System to use */
	protected static int iRankType = -1;

	/** Min # of Peers needed before boosting the rank of downloads with no seeds */
	private static int minPeersToBoostNoSeeds;

	/** Min Speed needed to count a incomplete download as being actively downloading */
	private static int minSpeedForActiveDL;

	/** Min speed needed to count a complete download as being actively seeding */
	private static int minSpeedForActiveSeeding;

	// Ignore torrent if seed count is at least..
	private static int iIgnoreSeedCount;

	// Ignore even when First Priority
	private static boolean bIgnore0Peers;

	private static int iIgnoreShareRatio;

	private static int iIgnoreShareRatio_SeedStart;

	private static int iIgnoreRatioPeers;

	private static int iIgnoreRatioPeers_SeedStart;

	private static int iRankTypeSeedFallback;

	private static boolean bPreferLargerSwarms;

	private static int minQueueingShareRatio;

	// Ignore First Priority
	private static int iFirstPriorityIgnoreSPRatio;

	private static boolean bFirstPriorityIgnore0Peer;

	private static int iFirstPriorityType;

	private static int iFirstPrioritySeedingMinutes;

	private static int iFirstPriorityDLMinutes;

	private static long minTimeAlive;

	private static boolean bAutoStart0Peers;

	//
	// Class variables

	protected Download dl;

	private boolean bActivelyDownloading;

	private long lDLActivelyChangedOn;

	private boolean bActivelySeeding;

	private long lCDActivelyChangedOn;

	private boolean bIsFirstPriority;

	/** Public for tooltip to access it */
	public String sExplainFP = "";

	/** Public for tooltip to access it */
	public String sExplainSR = "";

	/** Public for tooltip to access it */
	public String sTrace = "";

	private AEMonitor downloadData_this_mon = new AEMonitor(
			"StartStopRules:downloadData");

	private final StartStopRulesDefaultPlugin rules;

	/**
	 * Default Initializer
	 * 
	 * @param _rules
	 * @param _dl
	 */
	public DefaultRankCalculator(StartStopRulesDefaultPlugin _rules, Download _dl) {
		rules = _rules;
		dl = _dl;

		try {
			downloadData_this_mon.enter();

			if (configListener == null) {

				configListener = new COConfigurationListener() {
					public void configurationSaved() {
						reloadConfigParams(rules.plugin_config);
					}
				};

				COConfigurationManager.addListener(configListener);
				configListener.configurationSaved();
			}
		} finally {
			downloadData_this_mon.exit();
		}
	}

	/**
	 * Load config values into the static variables
	 * 
	 * @param cfg
	 */
	public static void reloadConfigParams(PluginConfig cfg) {
		final String PREFIX = "StartStopManager_";

		iRankType = cfg.getIntParameter(PREFIX + "iRankType");

		minPeersToBoostNoSeeds = cfg.getIntParameter(PREFIX
				+ "iMinPeersToBoostNoSeeds");
		minSpeedForActiveDL = cfg.getIntParameter(PREFIX + "iMinSpeedForActiveDL");
		minSpeedForActiveSeeding = cfg.getIntParameter(PREFIX
				+ "iMinSpeedForActiveSeeding");

		iRankTypeSeedFallback = cfg.getIntParameter(PREFIX
				+ "iRankTypeSeedFallback");
		bPreferLargerSwarms = cfg.getBooleanParameter(PREFIX
				+ "bPreferLargerSwarms");
		minTimeAlive = cfg.getIntParameter(PREFIX + "iMinSeedingTime") * 1000;
		bAutoStart0Peers = cfg.getBooleanParameter(PREFIX + "bAutoStart0Peers");

		// Ignore torrent if seed count is at least..
		iIgnoreSeedCount = cfg.getIntParameter(PREFIX + "iIgnoreSeedCount");
		bIgnore0Peers = cfg.getBooleanParameter(PREFIX + "bIgnore0Peers");
		iIgnoreShareRatio = (int) (1000 * cfg.getFloatParameter("Stop Ratio"));
		iIgnoreShareRatio_SeedStart = cfg.getIntParameter(PREFIX
				+ "iIgnoreShareRatioSeedStart");
		iIgnoreRatioPeers = cfg.getIntParameter("Stop Peers Ratio", 0);
		iIgnoreRatioPeers_SeedStart = cfg.getIntParameter(PREFIX
				+ "iIgnoreRatioPeersSeedStart", 0);

		minQueueingShareRatio = cfg.getIntParameter(PREFIX
				+ "iFirstPriority_ShareRatio");
		iFirstPriorityType = cfg.getIntParameter(PREFIX + "iFirstPriority_Type");
		iFirstPrioritySeedingMinutes = cfg.getIntParameter(PREFIX
				+ "iFirstPriority_SeedingMinutes");
		iFirstPriorityDLMinutes = cfg.getIntParameter(PREFIX
				+ "iFirstPriority_DLMinutes");
		// Ignore FP
		iFirstPriorityIgnoreSPRatio = cfg.getIntParameter(PREFIX
				+ "iFirstPriority_ignoreSPRatio");
		bFirstPriorityIgnore0Peer = cfg.getBooleanParameter(PREFIX
				+ "bFirstPriority_ignore0Peer");
	}

	/** Sort first by SeedingRank Descending, then by Position Ascending.
	 */
	public int compareTo(Object obj) {
		DefaultRankCalculator dlData = (DefaultRankCalculator) obj;
		// Test Completeness
		boolean aIsComplete = dlData.dl.getStats().getDownloadCompleted(false) == 1000;
		boolean bIsComplete = dl.getStats().getDownloadCompleted(false) == 1000;
		if (aIsComplete && !bIsComplete)
			return 1;
		if (!aIsComplete && bIsComplete)
			return -1;

		// Test FP
		if (dlData.bIsFirstPriority && !bIsFirstPriority)
			return 1;
		if (!dlData.bIsFirstPriority && bIsFirstPriority)
			return -1;

		if (iRankType == StartStopRulesDefaultPlugin.RANK_NONE) {
			return dl.getPosition() - dlData.dl.getPosition();
		}

		// Check Rank
		int value = dlData.dl.getSeedingRank() - dl.getSeedingRank();
		if (value != 0)
			return value;

		if (iRankType != StartStopRulesDefaultPlugin.RANK_TIMED) {
			// Test Large/Small Swarm pref
			int numPeersThem = rules.calcPeersNoUs(dlData.dl);
			int numPeersUs = rules.calcPeersNoUs(dl);
			if (bPreferLargerSwarms)
				value = numPeersThem - numPeersUs;
			else
				value = numPeersUs - numPeersThem;
			if (value != 0)
				return value;

			// Test Share Ratio
			int shareRatioUs = dl.getStats().getShareRatio();
			int shareRatioThem = dlData.dl.getStats().getShareRatio();
			value = shareRatioUs - shareRatioThem;
			if (value != 0)
				return value;
		}

		// Test Position
		return dl.getPosition() - dlData.dl.getPosition();
	}

	public Download getDownloadObject() {
		return dl;
	}

	/**
	 * Retrieves whether the torrent is "actively" downloading
	 * 
	 * @return true: actively downloading
	 */
	public boolean getActivelyDownloading() {
		boolean bIsActive = false;
		DownloadStats stats = dl.getStats();
		int state = dl.getState();

		// In order to be active,
		// - Must be downloading (and thus incomplete)
		// - Must be above speed threshold, or started less than 30s ago
		if (state != Download.ST_DOWNLOADING) {
			bIsActive = false;
		} else if (System.currentTimeMillis() - stats.getTimeStarted() <= FORCE_ACTIVE_FOR) {
			bIsActive = true;
		} else {
			// activity based on DL Average
			bIsActive = (stats.getDownloadAverage() >= minSpeedForActiveDL);

			if (bActivelyDownloading != bIsActive) {
				long now = System.currentTimeMillis();
				// Change
				if (lDLActivelyChangedOn == -1) {
					// Start Timer
					lDLActivelyChangedOn = now;
					bIsActive = !bIsActive;
				} else if (now - lDLActivelyChangedOn < ACTIVE_CHANGE_WAIT) {
					// Continue as old state until timer finishes
					bIsActive = !bIsActive;
				}
			} else {
				// no change, reset timer
				lDLActivelyChangedOn = -1;
			}
		}

		if (bActivelyDownloading != bIsActive) {
			bActivelyDownloading = bIsActive;
			if (rules != null) {
				rules.requestProcessCycle();
				if (rules.bDebugLog)
					rules.log.log(dl.getTorrent(), LoggerChannel.LT_INFORMATION,
							"somethingChanged: ActivelyDownloading changed");
			}
		}
		return bActivelyDownloading;
	}

	/**
	 * Retrieves whether the torrent is "actively" seeding
	 * 
	 * @return true: actively seeding
	 */
	public boolean getActivelySeeding() {
		boolean bIsActive = false;
		DownloadStats stats = dl.getStats();
		int state = dl.getState();
		// Timed torrents don't use a speed threshold, since they are based on time!
		// However, First Priorities need to be checked for activity so that 
		// timed ones can start when FPs are below threshold.  Ditto for 0 Peers
		// when bAutoStart0Peers
		if (iRankType == StartStopRulesDefaultPlugin.RANK_TIMED
				&& !isFirstPriority()
				&& !(bAutoStart0Peers && rules.calcPeersNoUs(dl) == 0 && scrapeResultOk(dl))) {
			bIsActive = (state == Download.ST_SEEDING);

		} else if (state != Download.ST_SEEDING
				|| (bAutoStart0Peers && rules.calcPeersNoUs(dl) == 0)) {
			// Not active if we aren't seeding
			// Not active if we are AutoStarting 0 Peers, and peer count == 0
			bIsActive = false;
		} else if (System.currentTimeMillis() - stats.getTimeStarted() <= FORCE_ACTIVE_FOR) {
			bIsActive = true;
		} else {
			bIsActive = (stats.getUploadAverage() >= minSpeedForActiveSeeding);

			if (bActivelySeeding != bIsActive) {
				long now = System.currentTimeMillis();
				// Change
				if (lCDActivelyChangedOn == -1) {
					// Start Timer
					lCDActivelyChangedOn = now;
					bIsActive = !bIsActive;
				} else if (now - lCDActivelyChangedOn < ACTIVE_CHANGE_WAIT) {
					// Continue as old state until timer finishes
					bIsActive = !bIsActive;
				}
			} else {
				// no change, reset timer
				lCDActivelyChangedOn = -1;
			}
		}

		if (bActivelySeeding != bIsActive) {
			bActivelySeeding = bIsActive;
			if (rules != null) {
				rules.requestProcessCycle();
				if (rules.bDebugLog)
					rules.log.log(dl.getTorrent(), LoggerChannel.LT_INFORMATION,
							"somethingChanged: ActivelySeeding changed");

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
韩国午夜理伦三级不卡影院| 日本韩国欧美在线| 在线欧美日韩国产| 久久―日本道色综合久久| 亚洲靠逼com| 激情综合色播激情啊| 欧美久久一二区| 亚洲免费观看高清完整版在线观看熊 | 最新国产精品久久精品| 日韩精品午夜视频| 99re免费视频精品全部| 国产偷v国产偷v亚洲高清| 日本aⅴ精品一区二区三区 | 日韩午夜精品电影| 一区二区三区电影在线播| 高清av一区二区| 精品国产一二三区| 蜜桃精品视频在线| 欧美日韩午夜在线视频| 中文字幕日本乱码精品影院| 国产另类ts人妖一区二区| 精品久久久久久久久久久久久久久 | 成人免费观看av| 久久精品人人做| 韩国精品主播一区二区在线观看| 欧美高清www午色夜在线视频| 亚洲五码中文字幕| 在线欧美小视频| 亚洲一区二区五区| 欧美午夜片在线看| 亚洲一区二区不卡免费| 欧美三级乱人伦电影| 亚洲国产精品嫩草影院| 欧美日韩一区二区在线观看| 午夜精品久久久久久久蜜桃app| eeuss鲁片一区二区三区| 国产精品伦一区| av成人免费在线观看| 亚洲欧美偷拍三级| 99久久99久久精品国产片果冻 | 久久久久久夜精品精品免费| 美女爽到高潮91| 2017欧美狠狠色| 高清国产一区二区三区| 国产精品毛片无遮挡高清| 色婷婷综合在线| 午夜激情综合网| 日韩三级电影网址| 激情小说亚洲一区| 中文字幕一区二区日韩精品绯色| 99久久精品国产毛片| 亚洲一区二区三区爽爽爽爽爽| 91精品麻豆日日躁夜夜躁| 久久成人18免费观看| 国产欧美一区二区精品忘忧草| 成人性色生活片免费看爆迷你毛片| 国产精品久久网站| 欧美老年两性高潮| 国产中文一区二区三区| 亚洲欧洲另类国产综合| 欧美精品在线视频| 国产精品一区在线观看乱码| 亚洲视频一区二区在线| 91精品国产91久久久久久一区二区 | 日韩一级片在线播放| 国产美女视频一区| 亚洲狼人国产精品| 日韩三级.com| aaa国产一区| 免费视频一区二区| 国产精品免费看片| 欧美一级视频精品观看| 99久久伊人精品| 久热成人在线视频| 一区二区理论电影在线观看| 久久综合久久综合亚洲| 欧美一a一片一级一片| 国产一二精品视频| 婷婷开心激情综合| 亚洲欧美日韩在线| 精品国产乱码久久久久久免费 | 99久久99精品久久久久久| 青青青伊人色综合久久| 国产精品国产三级国产aⅴ原创 | 亚洲bdsm女犯bdsm网站| 国产人久久人人人人爽| 欧美一级日韩免费不卡| 欧亚一区二区三区| 99精品视频一区二区| 国产一区二区三区在线看麻豆| 一区二区三区欧美| 国产精品久久久久影视| 久久嫩草精品久久久久| 日韩欧美中文字幕一区| 欧美日韩你懂得| 在线观看日韩毛片| 99国产精品久久久久| 国产成人超碰人人澡人人澡| 久久99精品国产麻豆婷婷洗澡| 精品一区二区三区蜜桃| 日韩精品电影一区亚洲| 午夜精品久久久久久久久久久| 一区二区三区在线视频播放| 日韩一区日韩二区| 中文字幕中文字幕在线一区| 欧美激情中文不卡| 亚洲国产精品精华液ab| 国产精品全国免费观看高清| 久久久久久久久蜜桃| 久久综合色鬼综合色| 久久久蜜桃精品| 久久精品欧美一区二区三区不卡| 久久久久久久综合色一本| 久久只精品国产| 国产情人综合久久777777| 国产色产综合产在线视频| 欧美极品少妇xxxxⅹ高跟鞋 | 国产视频亚洲色图| 久久久五月婷婷| 久久综合av免费| 中文字幕免费观看一区| 国产精品剧情在线亚洲| 亚洲精品视频一区| 一区二区三区精品| 日本午夜一本久久久综合| 另类中文字幕网| 国产高清不卡一区| 不卡视频在线观看| 色94色欧美sute亚洲线路一久 | 91久久免费观看| 欧美日韩一区二区在线视频| 制服丝袜激情欧洲亚洲| 久久欧美中文字幕| 亚洲色图制服诱惑 | jlzzjlzz国产精品久久| 色菇凉天天综合网| 91精品国产综合久久久蜜臀粉嫩| 日韩一卡二卡三卡四卡| 久久久www免费人成精品| 中文字幕在线播放不卡一区| 亚洲国产一区二区a毛片| 日韩高清不卡一区二区| 国产iv一区二区三区| 欧美性猛片xxxx免费看久爱| 欧美白人最猛性xxxxx69交| 国产精品电影院| 日韩中文字幕麻豆| 国产精品夜夜嗨| 在线观看日韩国产| 久久久蜜桃精品| 亚洲一区二区视频在线| 激情伊人五月天久久综合| 91蜜桃免费观看视频| 精品国产123| 亚洲欧洲国产日本综合| 蜜臀a∨国产成人精品| av动漫一区二区| 91精品婷婷国产综合久久竹菊| 亚洲国产精品精华液ab| 日韩电影免费在线观看网站| 成人禁用看黄a在线| 日韩欧美在线不卡| 亚洲综合一区在线| 国产suv精品一区二区三区| 欧美喷水一区二区| 亚洲欧美在线高清| 国内精品免费**视频| 欧美精品在线观看一区二区| 日韩理论片在线| 国产成人自拍在线| 欧美大片一区二区三区| 亚洲一区二区精品3399| 成人99免费视频| 亚洲国产成人av网| 成人免费不卡视频| 久久亚洲精华国产精华液| 热久久国产精品| 欧美日韩小视频| 一区二区不卡在线视频 午夜欧美不卡在| 狠狠色狠狠色综合| 日韩一区二区在线观看| 亚洲国产视频一区| 色综合久久六月婷婷中文字幕| 久久精品一区二区三区av| 久久精品国产秦先生| 69av一区二区三区| 亚洲福中文字幕伊人影院| 色哟哟亚洲精品| 亚洲美女区一区| 色偷偷成人一区二区三区91| 18欧美亚洲精品| 99精品欧美一区二区三区综合在线| 欧美韩日一区二区三区四区| 国产精品亚洲а∨天堂免在线| 欧美精品一区二区三区视频| 精东粉嫩av免费一区二区三区| 日韩欧美久久一区| 美国毛片一区二区三区| 日韩三级视频在线看| 蜜臀av亚洲一区中文字幕|