use of com.biglybt.core.speedmanager.SpeedManagerLimitEstimate in project BiglyBT by BiglySoftware.
the class PingSpaceMon method getDownloadLimit.
/**
* Get the current estimated download limit from the ping mapper.
* @return - SpeedManagerLimitEstimate
*/
public static SpeedManagerLimitEstimate getDownloadLimit() {
try {
SMInstance pm = SMInstance.getInstance();
SpeedManagerAlgorithmProviderAdapter adapter = pm.getAdapter();
SpeedManagerPingMapper persistentMap = adapter.getPingMapper();
SpeedManagerLimitEstimate downEst = persistentMap.getEstimatedDownloadLimit(true);
return downEst;
} catch (Throwable t) {
// log this event and
SpeedManagerLogger.log(t.toString());
t.printStackTrace();
// something to return 0 and -1.0f results.
return new DefaultLimitEstimate();
}
}
use of com.biglybt.core.speedmanager.SpeedManagerLimitEstimate in project BiglyBT by BiglySoftware.
the class PingSpaceMon method getDownloadEstCapacity.
// getDownloadLimit
/**
* Get the estimated download capacity from the SpeedManager.
* @return - SpeedManagerLimitEstimate
*/
public static SpeedManagerLimitEstimate getDownloadEstCapacity() {
try {
SMInstance pm = SMInstance.getInstance();
SpeedManagerAlgorithmProviderAdapter adapter = pm.getAdapter();
SpeedManager sm = adapter.getSpeedManager();
SpeedManagerLimitEstimate downEstCapacity = sm.getEstimatedDownloadCapacityBytesPerSec();
return downEstCapacity;
} catch (Throwable t) {
// log this event and
SpeedManagerLogger.log(t.toString());
t.printStackTrace();
// something to return 0 and -1.0f results.
return new DefaultLimitEstimate();
}
}
use of com.biglybt.core.speedmanager.SpeedManagerLimitEstimate in project BiglyBT by BiglySoftware.
the class SpeedLimitListener method propertyChanged.
@Override
public void propertyChanged(int property) {
String type = "unknown";
if (property == SpeedManagerListener.PR_ASN) {
type = "ASN change";
mon.readFromPersistentMap();
mon.updateFromCOConfigManager();
SMSearchLogger.log("ASN change.");
} else if (property == SpeedManagerListener.PR_DOWN_CAPACITY) {
type = "download capacity";
SpeedManagerLimitEstimate pmEst = PingSpaceMon.getDownloadLimit();
SpeedManagerLimitEstimate smEst = PingSpaceMon.getDownloadEstCapacity();
SMSearchLogger.log(" download - persistent limit: " + pmEst.getString());
SMSearchLogger.log(" download - estimated capacity: " + smEst.getString());
mon.notifyDownload(smEst);
} else if (property == SpeedManagerListener.PR_UP_CAPACITY) {
type = "upload capacity";
SpeedManagerLimitEstimate shortTermLimit = PingSpaceMon.getUploadLimit(false);
SpeedManagerLimitEstimate pmEst = PingSpaceMon.getUploadLimit(true);
SpeedManagerLimitEstimate smEst = PingSpaceMon.getUploadEstCapacity();
SMSearchLogger.log(" upload - short term limit: " + shortTermLimit.getString());
SMSearchLogger.log(" upload - persistent limit: " + pmEst.getString());
SMSearchLogger.log(" upload - estimated capacity: " + smEst.getString());
mon.notifyUpload(smEst);
}
SpeedManagerLogger.log("Updated from SpeedManagerPingMapper property=" + type);
}
use of com.biglybt.core.speedmanager.SpeedManagerLimitEstimate in project BiglyBT by BiglySoftware.
the class SpeedLimitMonitor method logPingMapData.
// hadChockingPing
/**
* Just log this data until we decide if it is useful.
*/
public void logPingMapData() {
if (!useVariancePingMap) {
int downLimGuess = pingMapOfDownloadMode.guessDownloadLimit();
int upLimGuess = pingMapOfDownloadMode.guessUploadLimit();
int seedingUpLimGuess = pingMapOfSeedingMode.guessUploadLimit();
StringBuilder sb = new StringBuilder("ping-map: ");
sb.append(":down=").append(downLimGuess);
sb.append(":up=").append(upLimGuess);
sb.append(":(seed)up=").append(seedingUpLimGuess);
SpeedManagerLogger.log(sb.toString());
} else {
SMInstance pm = SMInstance.getInstance();
SpeedManagerAlgorithmProviderAdapter adapter = pm.getAdapter();
SpeedManagerPingMapper persistentMap = adapter.getPingMapper();
SpeedManagerLimitEstimate estUp = persistentMap.getEstimatedUploadLimit(false);
SpeedManagerLimitEstimate estDown = persistentMap.getEstimatedDownloadLimit(false);
int downLimGuess = estDown.getBytesPerSec();
float downConf = estDown.getMetricRating();
int upLimGuess = estUp.getBytesPerSec();
float upConf = estUp.getMetricRating();
String name = persistentMap.getName();
StringBuilder sb = new StringBuilder("new-ping-map: ");
sb.append(" name=").append(name);
sb.append(", down=").append(downLimGuess);
sb.append(", down-conf=").append(downConf);
sb.append(", up=").append(upLimGuess);
sb.append(", up-conf=").append(upConf);
SpeedManagerLogger.log(sb.toString());
}
}
use of com.biglybt.core.speedmanager.SpeedManagerLimitEstimate in project BiglyBT by BiglySoftware.
the class SpeedLimitMonitor method readFromPersistentMap.
// updateFromCOConfigManager
/**
* replaces - updateFromCOConfigManager()
*/
public void readFromPersistentMap() {
// get persistent mapper.
SpeedManager sm = CoreFactory.getSingleton().getSpeedManager();
// get upload estimate.
SpeedManagerLimitEstimate uEst = SMConst.filterEstimate(sm.getEstimatedUploadCapacityBytesPerSec(), SMConst.START_UPLOAD_RATE_MAX);
int upPingMapLimit = uEst.getBytesPerSec();
if (upPingMapLimit < SMConst.START_UPLOAD_RATE_MAX) {
// will find upload limit via slow search.
uploadLimitMax = SMConst.START_UPLOAD_RATE_MAX;
} else {
uploadLimitMax = upPingMapLimit;
}
uploadLimitMin = SMConst.calculateMinUpload(uploadLimitMax);
// get download estimate.
SpeedManagerLimitEstimate dEst = SMConst.filterEstimate(sm.getEstimatedDownloadCapacityBytesPerSec(), SMConst.START_DOWNLOAD_RATE_MAX);
int downPingMapLimit = dEst.getBytesPerSec();
if (isSettingDownloadUnlimited()) {
slider.setDownloadUnlimitedMode(true);
} else {
slider.setDownloadUnlimitedMode(false);
}
if (downPingMapLimit < SMConst.START_DOWNLOAD_RATE_MAX) {
downloadLimitMax = SMConst.START_DOWNLOAD_RATE_MAX;
} else {
downloadLimitMax = downPingMapLimit;
}
downloadLimitMin = SMConst.calculateMinDownload(downloadLimitMax);
uploadLimitConf = SpeedLimitConfidence.convertType(uEst.getEstimateType());
downloadLimitConf = SpeedLimitConfidence.convertType(dEst.getEstimateType());
percentUploadCapacityDownloadMode = (float) COConfigurationManager.getIntParameter(SpeedLimitMonitor.USED_UPLOAD_CAPACITY_DOWNLOAD_MODE, 60) / 100.0f;
saveToCOConfiguration();
}
Aggregations