propagate from branch 'i2p.i2p.zzz.test' (head c295ab421dd719cfe0e273268b5b4e48505e4f61)

to branch 'i2p.i2p' (head 995914d8e049d9bb695fd25e4cf5be860cd4e487)
This commit is contained in:
zzz
2010-03-18 15:49:03 +00:00
69 changed files with 1457 additions and 1213 deletions

View File

@ -298,6 +298,9 @@ public class ConfigNetHandler extends FormHandler {
_context.router().shutdownGracefully(Router.EXIT_GRACEFUL_RESTART);
}
private static final int DEF_BURST_PCT = 10;
private static final int DEF_BURST_TIME = 20;
private void updateRates() {
boolean updated = false;
@ -310,14 +313,27 @@ public class ConfigNetHandler extends FormHandler {
}
}
// Since burst is now hidden in the gui, set burst to +10% for 20 seconds
if ( (_inboundRate != null) && (_inboundRate.length() > 0) &&
!_inboundRate.equals(_context.getProperty(FIFOBandwidthRefiller.PROP_INBOUND_BANDWIDTH, "" + FIFOBandwidthRefiller.DEFAULT_INBOUND_BANDWIDTH))) {
_context.router().setConfigSetting(FIFOBandwidthRefiller.PROP_INBOUND_BANDWIDTH, _inboundRate);
try {
int rate = Integer.parseInt(_inboundRate) * (100 + DEF_BURST_PCT) / 100;
int kb = DEF_BURST_TIME * rate;
_context.router().setConfigSetting(FIFOBandwidthRefiller.PROP_INBOUND_BURST_BANDWIDTH, "" + rate);
_context.router().setConfigSetting(FIFOBandwidthRefiller.PROP_INBOUND_BANDWIDTH_PEAK, "" + kb);
} catch (NumberFormatException nfe) {}
updated = true;
}
if ( (_outboundRate != null) && (_outboundRate.length() > 0) &&
!_outboundRate.equals(_context.getProperty(FIFOBandwidthRefiller.PROP_OUTBOUND_BANDWIDTH, "" + FIFOBandwidthRefiller.DEFAULT_OUTBOUND_BANDWIDTH))) {
_context.router().setConfigSetting(FIFOBandwidthRefiller.PROP_OUTBOUND_BANDWIDTH, _outboundRate);
try {
int rate = Integer.parseInt(_outboundRate) * (100 + DEF_BURST_PCT) / 100;
int kb = DEF_BURST_TIME * rate;
_context.router().setConfigSetting(FIFOBandwidthRefiller.PROP_OUTBOUND_BURST_BANDWIDTH, "" + rate);
_context.router().setConfigSetting(FIFOBandwidthRefiller.PROP_OUTBOUND_BANDWIDTH_PEAK, "" + kb);
} catch (NumberFormatException nfe) {}
updated = true;
}

View File

@ -7,7 +7,7 @@ import java.util.concurrent.ConcurrentHashMap;
import net.i2p.I2PAppContext;
public class NavHelper {
private static Map<String, String> _apps = new ConcurrentHashMap();
private static Map<String, String> _apps = new ConcurrentHashMap(4);
/**
* To register a new client application so that it shows up on the router
@ -28,7 +28,9 @@ public class NavHelper {
* Translated string is loaded by PluginStarter
*/
public static String getClientAppLinks(I2PAppContext ctx) {
StringBuilder buf = new StringBuilder(1024);
if (_apps.isEmpty())
return "";
StringBuilder buf = new StringBuilder(256);
for (Iterator<String> iter = _apps.keySet().iterator(); iter.hasNext(); ) {
String name = iter.next();
String path = _apps.get(name);

View File

@ -282,7 +282,11 @@ public class NetDbRenderer {
}
for (Iterator iter = info.getAddresses().iterator(); iter.hasNext(); ) {
RouterAddress addr = (RouterAddress)iter.next();
buf.append("<b>").append(DataHelper.stripHTML(addr.getTransportStyle())).append(":</b> ");
String style = addr.getTransportStyle();
buf.append("<b>").append(DataHelper.stripHTML(style)).append(":</b> ");
int cost = addr.getCost();
if (!((style.equals("SSU") && cost == 5) || (style.equals("NTCP") && cost == 10)))
buf.append('[').append("cost").append('=').append("" + cost).append("] ");
for (Iterator optIter = addr.getOptions().keySet().iterator(); optIter.hasNext(); ) {
String name = (String)optIter.next();
String val = addr.getOptions().getProperty(name);

View File

@ -180,7 +180,7 @@ public class PluginStarter implements Runnable {
* @return true on success
* @throws just about anything, caller would be wise to catch Throwable
*/
static boolean stopPlugin(RouterContext ctx, String appName) throws IOException {
static boolean stopPlugin(RouterContext ctx, String appName) throws Exception {
Log log = ctx.logManager().getLog(PluginStarter.class);
File pluginDir = new File(ctx.getAppDir(), PluginUpdateHandler.PLUGIN_DIR + '/' + appName);
if ((!pluginDir.exists()) || (!pluginDir.isDirectory())) {
@ -228,7 +228,7 @@ public class PluginStarter implements Runnable {
}
/** @return true on success - caller should call stopPlugin() first */
static boolean deletePlugin(RouterContext ctx, String appName) throws IOException {
static boolean deletePlugin(RouterContext ctx, String appName) throws Exception {
Log log = ctx.logManager().getLog(PluginStarter.class);
File pluginDir = new File(ctx.getAppDir(), PluginUpdateHandler.PLUGIN_DIR + '/' + appName);
if ((!pluginDir.exists()) || (!pluginDir.isDirectory())) {
@ -348,8 +348,12 @@ public class PluginStarter implements Runnable {
} catch (IOException ioe) {}
}
/** @param action "start" or "stop" or "uninstall" */
private static void runClientApps(RouterContext ctx, File pluginDir, List<ClientAppConfig> apps, String action) {
/**
* @param action "start" or "stop" or "uninstall"
* @throws just about anything if an app has a delay less than zero, caller would be wise to catch Throwable
* If no apps have a delay less than zero, it shouldn't throw anything
*/
private static void runClientApps(RouterContext ctx, File pluginDir, List<ClientAppConfig> apps, String action) throws Exception {
Log log = ctx.logManager().getLog(PluginStarter.class);
for(ClientAppConfig app : apps) {
if (action.equals("start") && app.disabled)
@ -388,10 +392,18 @@ public class PluginStarter implements Runnable {
}
addToClasspath(cp, app.clientName, log);
}
if (app.delay == 0 || !action.equals("start")) {
if (app.delay < 0 && action.equals("start")) {
// this will throw exceptions
LoadClientAppsJob.runClientInline(app.className, app.clientName, argVal, log);
} else if (app.delay == 0 || !action.equals("start")) {
// quick check, will throw ClassNotFoundException on error
LoadClientAppsJob.testClient(app.className);
// run this guy now
LoadClientAppsJob.runClient(app.className, app.clientName, argVal, log);
} else {
// quick check, will throw ClassNotFoundException on error
LoadClientAppsJob.testClient(app.className);
// wait before firing it up
ctx.jobQueue().addJob(new LoadClientAppsJob.DelayedRunClient(ctx, app.className, app.clientName, argVal, app.delay));
}

View File

@ -205,13 +205,14 @@ public class UpdateHandler {
} else {
_log.log(Log.CRIT, "Update was VERIFIED, will be installed at next restart");
StringBuilder buf = new StringBuilder(64);
buf.append("<b>").append(_("Update downloaded")).append("</b><br>");
buf.append("<b>").append(_("Update downloaded")).append("<br>");
if (System.getProperty("wrapper.version") != null)
buf.append(_("Click Restart to install"));
else
buf.append(_("Click Shutdown and restart to install"));
if (up.newVersion() != null)
buf.append(' ').append(_("Version {0}", up.newVersion()));
buf.append("</b>");
updateStatus(buf.toString());
}
} else {