diff --git a/router/java/src/net/i2p/router/networkdb/kademlia/PersistentDataStore.java b/router/java/src/net/i2p/router/networkdb/kademlia/PersistentDataStore.java index 5df6972d54dd736ed10ce18494a107da00e02eb1..16aa7dfb656cab5872f515a2d4f4deb2a4f24b34 100644 --- a/router/java/src/net/i2p/router/networkdb/kademlia/PersistentDataStore.java +++ b/router/java/src/net/i2p/router/networkdb/kademlia/PersistentDataStore.java @@ -346,8 +346,12 @@ class PersistentDataStore extends TransientDataStore { _alreadyWarned = false; for (int i = 0; i < routerInfoFiles.length; i++) { Hash key = getRouterInfoHash(routerInfoFiles[i].getName()); - if ( (key != null) && (!isKnown(key)) ) - PersistentDataStore.this._context.jobQueue().addJob(new ReadRouterJob(routerInfoFiles[i], key)); + if ( (key != null) && (!isKnown(key)) ) { + // Run it inline so we don't clog up the job queue, esp. at startup + // Also this allows us to wait until it is really done to call checkReseed() and set _initialized + //PersistentDataStore.this._context.jobQueue().addJob(new ReadRouterJob(routerInfoFiles[i], key)); + (new ReadRouterJob(routerInfoFiles[i], key)).runJob(); + } } } } catch (IOException ioe) { diff --git a/router/java/src/net/i2p/router/startup/BootCommSystemJob.java b/router/java/src/net/i2p/router/startup/BootCommSystemJob.java index 6d31a6021b3d5acc2022fb7397460bd625a204ec..6e3e31efd12b5d800cc1edb251e6e9153345dbef 100644 --- a/router/java/src/net/i2p/router/startup/BootCommSystemJob.java +++ b/router/java/src/net/i2p/router/startup/BootCommSystemJob.java @@ -13,6 +13,7 @@ import net.i2p.router.JobImpl; import net.i2p.router.RouterContext; import net.i2p.util.Log; +/** This actually boots almost everything */ public class BootCommSystemJob extends JobImpl { private Log _log; @@ -26,18 +27,29 @@ public class BootCommSystemJob extends JobImpl { public String getName() { return "Boot Communication System"; } public void runJob() { + // The netDb and the peer manager both take a long time to start up, + // as they may have to read in ~1000 files or more each + // So turn on the multiple job queues and start these two first. + // These two (plus the current job) will consume 3 of the 4 runners, + // leaving one for everything else, which allows us to start without + // a huge job lag displayed on the console. + getContext().jobQueue().allowParallelOperation(); + startupDb(); + getContext().jobQueue().addJob(new BootPeerManagerJob(getContext())); + // start up the network comm system - getContext().commSystem().startup(); getContext().tunnelManager().startup(); - getContext().peerManager().startup(); + + // start I2CP + getContext().jobQueue().addJob(new StartAcceptingClientsJob(getContext())); + + getContext().jobQueue().addJob(new ReadConfigJob(getContext())); + } + private void startupDb() { Job bootDb = new BootNetworkDbJob(getContext()); - boolean useTrusted = false; - String useTrustedStr = getContext().router().getConfigSetting(PROP_USE_TRUSTED_LINKS); - if (useTrustedStr != null) { - useTrusted = Boolean.TRUE.toString().equalsIgnoreCase(useTrustedStr); - } + boolean useTrusted = Boolean.valueOf(getContext().getProperty(PROP_USE_TRUSTED_LINKS)).booleanValue(); if (useTrusted) { _log.debug("Using trusted links..."); getContext().jobQueue().addJob(new BuildTrustedLinksJob(getContext(), bootDb)); diff --git a/router/java/src/net/i2p/router/startup/BootNetworkDbJob.java b/router/java/src/net/i2p/router/startup/BootNetworkDbJob.java index 4ddc4ecc94f01123f858a82b3c1fec1a0d0666be..bf8d36a7729b4c8c16d2319325207115da1fa25c 100644 --- a/router/java/src/net/i2p/router/startup/BootNetworkDbJob.java +++ b/router/java/src/net/i2p/router/startup/BootNetworkDbJob.java @@ -10,10 +10,9 @@ package net.i2p.router.startup; import net.i2p.router.JobImpl; import net.i2p.router.RouterContext; -import net.i2p.util.Log; +/** start up the network database */ public class BootNetworkDbJob extends JobImpl { - private static Log _log = new Log(BootNetworkDbJob.class); public BootNetworkDbJob(RouterContext ctx) { super(ctx); @@ -22,10 +21,6 @@ public class BootNetworkDbJob extends JobImpl { public String getName() { return "Boot Network Database"; } public void runJob() { - // start up the network database - getContext().netDb().startup(); - - getContext().jobQueue().addJob(new StartAcceptingClientsJob(getContext())); } } diff --git a/router/java/src/net/i2p/router/startup/BootPeerManagerJob.java b/router/java/src/net/i2p/router/startup/BootPeerManagerJob.java new file mode 100644 index 0000000000000000000000000000000000000000..7ac5254f0e936484681751c3503ab67ebc38865f --- /dev/null +++ b/router/java/src/net/i2p/router/startup/BootPeerManagerJob.java @@ -0,0 +1,26 @@ +package net.i2p.router.startup; +/* + * free (adj.): unencumbered; not under the control of others + * Written by jrandom in 2003 and released into the public domain + * with no warranty of any kind, either expressed or implied. + * It probably won't make your computer catch on fire, or eat + * your children, but it might. Use at your own risk. + * + */ + +import net.i2p.router.JobImpl; +import net.i2p.router.RouterContext; + +/** start up the peer manager */ +public class BootPeerManagerJob extends JobImpl { + + public BootPeerManagerJob(RouterContext ctx) { + super(ctx); + } + + public String getName() { return "Boot Peer Manager"; } + + public void runJob() { + getContext().peerManager().startup(); + } +} diff --git a/router/java/src/net/i2p/router/startup/StartAcceptingClientsJob.java b/router/java/src/net/i2p/router/startup/StartAcceptingClientsJob.java index 727d06ac6c1cd3a4c05815bcdc553ba7ca4f20e2..eb01bd1521b5745d76edac360ffe6c8c0ed0eb5e 100644 --- a/router/java/src/net/i2p/router/startup/StartAcceptingClientsJob.java +++ b/router/java/src/net/i2p/router/startup/StartAcceptingClientsJob.java @@ -12,6 +12,7 @@ import net.i2p.router.JobImpl; import net.i2p.router.RouterContext; import net.i2p.util.Log; +/** start I2CP interface */ public class StartAcceptingClientsJob extends JobImpl { private Log _log; @@ -23,13 +24,10 @@ public class StartAcceptingClientsJob extends JobImpl { public String getName() { return "Start Accepting Clients"; } public void runJob() { - // start up the network database getContext().clientManager().startup(); - getContext().jobQueue().addJob(new ReadConfigJob(getContext())); // pointless //getContext().jobQueue().addJob(new RebuildRouterInfoJob(getContext())); - getContext().jobQueue().allowParallelOperation(); } }