use of com.biglybt.core.speedmanager.SpeedManager in project BiglyBT by BiglySoftware.
the class GlobalManagerImpl method statsRequest.
@Override
public void statsRequest(Map request, Map reply) {
Core core = CoreFactory.getSingleton();
Map glob = new HashMap();
reply.put("gm", glob);
try {
glob.put("u_rate", new Long(stats.getDataAndProtocolSendRate()));
glob.put("d_rate", new Long(stats.getDataAndProtocolReceiveRate()));
glob.put("d_lim", new Long(TransferSpeedValidator.getGlobalDownloadRateLimitBytesPerSecond()));
boolean auto_up = TransferSpeedValidator.isAutoSpeedActive(this) && TransferSpeedValidator.isAutoUploadAvailable(core);
glob.put("auto_up", new Long(auto_up ? COConfigurationManager.getLongParameter(SpeedManagerImpl.CONFIG_VERSION) : 0));
long up_lim = NetworkManager.getMaxUploadRateBPSNormal();
boolean seeding_only = NetworkManager.isSeedingOnlyUploadRate();
glob.put("so", new Long(seeding_only ? 1 : 0));
if (seeding_only) {
up_lim = NetworkManager.getMaxUploadRateBPSSeedingOnly();
}
glob.put("u_lim", new Long(up_lim));
SpeedManager sm = core.getSpeedManager();
if (sm != null) {
glob.put("u_cap", new Long(sm.getEstimatedUploadCapacityBytesPerSec().getBytesPerSec()));
glob.put("d_cap", new Long(sm.getEstimatedDownloadCapacityBytesPerSec().getBytesPerSec()));
}
List<DownloadManager> dms = getDownloadManagers();
int comp = 0;
int incomp = 0;
long comp_up = 0;
long incomp_up = 0;
long incomp_down = 0;
for (DownloadManager dm : dms) {
int state = dm.getState();
if (state == DownloadManager.STATE_SEEDING || state == DownloadManager.STATE_DOWNLOADING) {
DownloadManagerStats stats = dm.getStats();
if (dm.isDownloadComplete(false)) {
comp++;
comp_up += stats.getProtocolSendRate() + stats.getDataSendRate();
} else {
incomp++;
incomp_up += stats.getProtocolSendRate() + stats.getDataSendRate();
incomp_down += stats.getProtocolReceiveRate() + stats.getDataReceiveRate();
}
}
}
glob.put("dm_i", new Long(incomp));
glob.put("dm_c", new Long(comp));
glob.put("dm_i_u", new Long(incomp_up));
glob.put("dm_i_d", new Long(incomp_down));
glob.put("dm_c_u", new Long(comp_up));
glob.put("nat", new Long(nat_status));
boolean request_limiting = COConfigurationManager.getBooleanParameter("Use Request Limiting");
glob.put("req_lim", new Long(request_limiting ? 1 : 0));
if (request_limiting) {
glob.put("req_focus", new Long(COConfigurationManager.getBooleanParameter("Use Request Limiting Priorities") ? 1 : 0));
}
boolean bias_up = COConfigurationManager.getBooleanParameter("Bias Upload Enable");
glob.put("bias_up", new Long(bias_up ? 1 : 0));
if (bias_up) {
glob.put("bias_slack", new Long(COConfigurationManager.getLongParameter("Bias Upload Slack KBs")));
glob.put("bias_ulim", new Long(COConfigurationManager.getBooleanParameter("Bias Upload Handle No Limit") ? 1 : 0));
}
} catch (Throwable e) {
}
}
use of com.biglybt.core.speedmanager.SpeedManager in project BiglyBT by BiglySoftware.
the class SpeedLimitMonitor method logPMDataEx.
// logPMData
public void logPMDataEx() {
int tuploadLimitMax = COConfigurationManager.getIntParameter(SpeedManagerAlgorithmProviderV2.SETTING_UPLOAD_MAX_LIMIT);
int tdownloadLimitMax = COConfigurationManager.getIntParameter(SpeedManagerAlgorithmProviderV2.SETTING_DOWNLOAD_MAX_LIMIT);
// for testing.
SpeedManager sm = CoreFactory.getSingleton().getSpeedManager();
SpeedManagerLimitEstimate dEst = sm.getEstimatedDownloadCapacityBytesPerSec();
int tmpDMax = dEst.getBytesPerSec();
float tmpDMaxConf = dEst.getEstimateType();
// for testing.
SpeedManagerLimitEstimate uEst = sm.getEstimatedUploadCapacityBytesPerSec();
int tmpUMax = uEst.getBytesPerSec();
float tmpUMaxConf = uEst.getEstimateType();
SpeedLimitConfidence tuploadLimitConf = SpeedLimitConfidence.parseString(COConfigurationManager.getStringParameter(SpeedLimitMonitor.UPLOAD_CONF_LIMIT_SETTING));
SpeedLimitConfidence tdownloadLimitConf = SpeedLimitConfidence.parseString(COConfigurationManager.getStringParameter(SpeedLimitMonitor.DOWNLOAD_CONF_LIMIT_SETTING));
//
logPMData(tuploadLimitMax, tuploadLimitConf, tmpUMax, tmpUMaxConf, "check-upload");
logPMData(tdownloadLimitMax, tdownloadLimitConf, tmpDMax, tmpDMaxConf, "check-download");
}
use of com.biglybt.core.speedmanager.SpeedManager 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();
}
use of com.biglybt.core.speedmanager.SpeedManager 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.SpeedManager in project BiglyBT by BiglySoftware.
the class SpeedTestSetLimitPanel method show.
/**
* Panel has text at the top explaining the result.
* Then under that it has a label the measured upload value and the recommended value.
* Then a button with apply.
*/
@Override
public void show() {
wizard.setTitle(MessageText.getString("SpeedTestWizard.set.upload.title"));
wizard.setCurrentInfo(MessageText.getString("SpeedTestWizard.set.upload.hint"));
Composite rootPanel = wizard.getPanel();
GridLayout layout = new GridLayout();
layout.numColumns = 1;
rootPanel.setLayout(layout);
Composite panel = new Composite(rootPanel, SWT.NULL);
GridData gridData = new GridData(GridData.FILL_HORIZONTAL);
Utils.setLayoutData(panel, gridData);
layout = new GridLayout();
layout.numColumns = 4;
panel.setLayout(layout);
Label explain = new Label(panel, SWT.WRAP);
gridData = new GridData(GridData.FILL_HORIZONTAL);
gridData.horizontalSpan = 4;
Utils.setLayoutData(explain, gridData);
Messages.setLanguageText(explain, "SpeedTestWizard.set.upload.panel.explain");
// spacer line
Label spacer = new Label(panel, SWT.NULL);
gridData = new GridData();
gridData.horizontalSpan = 4;
Utils.setLayoutData(spacer, gridData);
Label spacer1 = new Label(panel, SWT.NULL);
gridData = new GridData();
spacer1.setLayoutData(gridData);
Label bytesCol = new Label(panel, SWT.NULL);
gridData = new GridData();
gridData.widthHint = 80;
Utils.setLayoutData(bytesCol, gridData);
Messages.setLanguageText(bytesCol, "SpeedTestWizard.set.upload.bytes.per.sec");
Label bitsCol = new Label(panel, SWT.NULL);
gridData = new GridData();
gridData.widthHint = 80;
Utils.setLayoutData(bitsCol, gridData);
Messages.setLanguageText(bitsCol, "SpeedTestWizard.set.upload.bits.per.sec");
Label confLevel = new Label(panel, SWT.NULL);
gridData = new GridData();
gridData.widthHint = 80;
Utils.setLayoutData(confLevel, gridData);
Messages.setLanguageText(confLevel, "SpeedTestWizard.set.limit.conf.level");
// upload limit label.
Label ul = new Label(panel, SWT.NULL);
gridData = new GridData();
Utils.setLayoutData(ul, gridData);
Messages.setLanguageText(ul, "SpeedView.stats.estupcap", new String[] { DisplayFormatters.getRateUnit(DisplayFormatters.UNIT_KB) });
final Text uploadLimitSetting = new Text(panel, SWT.BORDER);
gridData = new GridData(GridData.BEGINNING);
gridData.widthHint = 80;
Utils.setLayoutData(uploadLimitSetting, gridData);
int uploadCapacity = determineRateSettingEx(measuredUploadKbps, uploadTestRan, true);
// don't accept any value less the 20 kb/s
if (uploadCapacity < 20)
uploadCapacity = 20;
uploadLimitSetting.setText("" + uploadCapacity);
uploadLimitSetting.addListener(SWT.Verify, new NumberListener(uploadLimitSetting));
// echo
final Label echo = new Label(panel, SWT.NULL);
gridData = new GridData();
gridData.horizontalSpan = 1;
gridData.widthHint = 80;
Utils.setLayoutData(echo, gridData);
echo.setText(DisplayFormatters.formatByteCountToBitsPerSec(uploadCapacity * 1024));
// This space has a change listener the updates in bits/sec.
// want a change listener to update the echo label which has the value in bits/sec.
uploadLimitSetting.addListener(SWT.Modify, new ByteConversionListener(echo, uploadLimitSetting));
// confidence setting.
final String[] confName = helper.getSettableTypes();
final String[] confValue = helper.getSettableTypes();
// upload confidence setting.
int uploadDropIndex = setDefaultConfidenceLevelEx(measuredUploadKbps, uploadTestRan, true, confValue);
upConfLevelCombo = new Combo(panel, SWT.READ_ONLY);
addDropElements(upConfLevelCombo, confName);
upConfLevelCombo.select(uploadDropIndex);
// download limit label.
Label dl = new Label(panel, SWT.NULL);
gridData = new GridData();
Utils.setLayoutData(dl, gridData);
Messages.setLanguageText(dl, "SpeedView.stats.estdowncap", new String[] { DisplayFormatters.getRateUnit(DisplayFormatters.UNIT_KB) });
final Text downloadLimitSetting = new Text(panel, SWT.BORDER);
gridData = new GridData(GridData.BEGINNING);
gridData.widthHint = 80;
Utils.setLayoutData(downloadLimitSetting, gridData);
int bestDownloadSetting = determineRateSettingEx(measuredDownloadKbps, downloadTestRan, false);
downloadLimitSetting.setText("" + bestDownloadSetting);
downloadLimitSetting.addListener(SWT.Verify, new NumberListener(downloadLimitSetting));
// echo
final Label downEcho = new Label(panel, SWT.NULL);
gridData = new GridData();
gridData.horizontalSpan = 1;
gridData.widthHint = 80;
Utils.setLayoutData(downEcho, gridData);
downEcho.setText(DisplayFormatters.formatByteCountToBitsPerSec(bestDownloadSetting * 1024));
// convert bytes to bits on the fly for user.
downloadLimitSetting.addListener(SWT.Modify, new ByteConversionListener(downEcho, downloadLimitSetting));
int downIndex = setDefaultConfidenceLevelEx(measuredDownloadKbps, downloadTestRan, false, confValue);
downConfLevelCombo = new Combo(panel, SWT.READ_ONLY);
addDropElements(downConfLevelCombo, confName);
downConfLevelCombo.select(downIndex);
// spacer col
Label c1 = new Label(panel, SWT.NULL);
gridData = new GridData();
gridData.horizontalSpan = 1;
gridData.widthHint = 80;
c1.setLayoutData(gridData);
SpeedManager sm = CoreFactory.getSingleton().getSpeedManager();
if (uploadTestRan) {
// Since cable modems can over estimate upload need to drop type setting to estimate.
sm.setEstimatedUploadCapacityBytesPerSec(measuredUploadKbps * 1024, // parg: as far as I can tell this stuff is deliberate, probably because the 'measured' conf settings screwed things up
uploadHitLimit ? SpeedManagerLimitEstimate.TYPE_ESTIMATED : SpeedManagerLimitEstimate.TYPE_ESTIMATED);
}
if (downloadTestRan) {
sm.setEstimatedDownloadCapacityBytesPerSec(measuredDownloadKbps * 1024, downloadHitLimit ? SpeedManagerLimitEstimate.TYPE_MEASURED_MIN : SpeedManagerLimitEstimate.TYPE_MEASURED);
}
apply = new Button(panel, SWT.PUSH);
Messages.setLanguageText(apply, "SpeedTestWizard.set.upload.button.apply");
gridData = new GridData();
gridData.widthHint = 70;
Utils.setLayoutData(apply, gridData);
apply.addListener(SWT.Selection, new Listener() {
@Override
public void handleEvent(Event event) {
// Turn the string into an int and make it kbps.
int uploadLimitKBPS = Integer.parseInt(uploadLimitSetting.getText());
int downlaodLimitKBPS = Integer.parseInt(downloadLimitSetting.getText());
// No value less then 20 kpbs should be allowed.
if (uploadLimitKBPS < 20) {
uploadLimitKBPS = 20;
}
// download value can never be less then upload.
if (downlaodLimitKBPS < uploadLimitKBPS) {
downlaodLimitKBPS = uploadLimitKBPS;
}
// turn off auto-speed!
COConfigurationManager.setParameter(TransferSpeedValidator.AUTO_UPLOAD_ENABLED_CONFIGKEY, false);
COConfigurationManager.setParameter(TransferSpeedValidator.AUTO_UPLOAD_SEEDING_ENABLED_CONFIGKEY, false);
// set upload limits
COConfigurationManager.setParameter("AutoSpeed Max Upload KBs", uploadLimitKBPS);
COConfigurationManager.setParameter(TransferSpeedValidator.UPLOAD_CONFIGKEY, uploadLimitKBPS);
COConfigurationManager.setParameter(TransferSpeedValidator.UPLOAD_SEEDING_CONFIGKEY, uploadLimitKBPS);
if (downloadTestRan) {
int dIndex = downConfLevelCombo.getSelectionIndex();
float downEstType = helper.textToType(confValue[dIndex]);
speedManager.setEstimatedUploadCapacityBytesPerSec(downlaodLimitKBPS, downEstType);
}
if (uploadTestRan) {
int uIndex = upConfLevelCombo.getSelectionIndex();
float upEstType = helper.textToType(confValue[uIndex]);
speedManager.setEstimatedUploadCapacityBytesPerSec(uploadLimitKBPS, upEstType);
}
wizard.setFinishEnabled(true);
wizard.setPreviousEnabled(false);
}
});
// spacer col
Label c3 = new Label(panel, SWT.NULL);
gridData = new GridData();
gridData.horizontalSpan = 1;
c3.setLayoutData(gridData);
// spacer line
Label spacer2 = new Label(panel, SWT.NULL);
gridData = new GridData();
gridData.horizontalSpan = 3;
spacer2.setLayoutData(gridData);
// switch column width to 5 columns.
Composite resultsPanel = new Composite(rootPanel, SWT.NULL);
gridData = new GridData(GridData.VERTICAL_ALIGN_END | GridData.FILL_HORIZONTAL);
Utils.setLayoutData(resultsPanel, gridData);
layout = new GridLayout();
layout.numColumns = 5;
layout.makeColumnsEqualWidth = true;
resultsPanel.setLayout(layout);
// display last test result
NetworkAdminSpeedTesterResult result = SpeedTestData.getInstance().getLastResult();
if (result.hadError()) {
// error
String error = result.getLastError();
createResultLabels(resultsPanel, true);
createErrorDesc(resultsPanel, error);
createTestDesc(resultsPanel);
} else {
// no error
// print out the last result format.
int upload = result.getUploadSpeed();
int download = result.getDownloadSpeed();
createResultLabels(resultsPanel, false);
createResultData(resultsPanel, MessageText.getString("GeneralView.label.uploadspeed"), upload);
createResultData(resultsPanel, MessageText.getString("GeneralView.label.downloadspeed"), download);
createTestDesc(resultsPanel);
}
}
Aggregations