Author: nextgens
Date: 2008-08-12 15:53:16 +0000 (Tue, 12 Aug 2008)
New Revision: 21765
Modified:
trunk/freenet/src/freenet/clients/http/FirstTimeWizardToadlet.java
Log:
Use the reported downstreamBWLimit too if possible
Modified: trunk/freenet/src/freenet/clients/http/FirstTimeWizardToadlet.java
===================================================================
--- trunk/freenet/src/freenet/clients/http/FirstTimeWizardToadlet.java
2008-08-12 15:44:58 UTC (rev 21764)
+++ trunk/freenet/src/freenet/clients/http/FirstTimeWizardToadlet.java
2008-08-12 15:53:16 UTC (rev 21765)
@@ -314,12 +314,18 @@
FredPluginBandwidthIndicator bwIndicator =
core.node.ipDetector.getBandwidthIndicator();
int upstreamBWLimit = (bwIndicator != null ?
bwIndicator.getUpstramMaxBitRate() : -1);
if((bwIndicator != null) && (upstreamBWLimit > 0)) {
- Logger.normal(this, "The node has a
bandwidthIndicator: it has reported "+upstreamBWLimit+ "... we will use that
value and skip the bandwidth selection step of the wizard.");
- int bytes = upstreamBWLimit / 8;
- if(bytes < 16384)
- _setUpstreamBandwidthLimit("8K");
- else
-
_setUpstreamBandwidthLimit(Integer.toString(bytes/2));
+ int bytes = (upstreamBWLimit / 8) - 1;
+ String upstreamBWLimitString = (bytes < 16384 ?
"8K" : SizeUtil.formatSize(bytes / 2));
+
_setUpstreamBandwidthLimit(upstreamBWLimitString);
+ Logger.normal(this, "The node has a
bandwidthIndicator: it has reported upstream="+upstreamBWLimit+ "bits/sec... we
will use "+ upstreamBWLimitString +" and skip the bandwidth selection step of
the wizard.");
+
+ int downstreamBWLimit =
bwIndicator.getDownstreamMaxBitRate();
+ if(downstreamBWLimit > 0) {
+ bytes = (downstreamBWLimit / 8) - 1;
+ String downstreamBWLimitString =
SizeUtil.formatSize(bytes * 2/3);
+
_setDownstreamBandwidthLimit(downstreamBWLimitString);
+ Logger.normal(this, "The node has a
bandwidthIndicator: it has reported downstream="+downstreamBWLimit+
"bits/sec... we will use "+ downstreamBWLimitString +" and skip the bandwidth
selection step of the wizard.");
+ }
super.writeTemporaryRedirect(ctx, "step4",
TOADLET_URL+"?step="+WIZARD_STEP.DATASTORE_SIZE);
} else
super.writeTemporaryRedirect(ctx, "step3",
TOADLET_URL+"?step="+WIZARD_STEP.BANDWIDTH);
@@ -370,4 +376,13 @@
Logger.error(this, "Should not happen, please report!"
+ e, e);
}
}
+
+ private void _setDownstreamBandwidthLimit(String selectedDownloadSpeed)
{
+ try {
+ config.get("node").set("inputBandwidthLimit",
selectedDownloadSpeed);
+ Logger.normal(this, "The inputBandwidthLimit has been
set to " + selectedDownloadSpeed);
+ } catch(InvalidConfigValueException e) {
+ Logger.error(this, "Should not happen, please report!"
+ e, e);
+ }
+ }
}