forked from I2P_Developers/i2p.i2p
- Fix Console concurrent ThreadPool
- Uncomment eepsite concurrent ThreadPool and fix arguments - Reduce eepsite acceptors to 1 - Add jetty-ssl.xml example - jetty.xml cleanup
This commit is contained in:
@ -9,7 +9,11 @@ import java.security.KeyStore;
|
||||
import java.util.List;
|
||||
import java.util.Properties;
|
||||
import java.util.StringTokenizer;
|
||||
import java.util.concurrent.Executors;
|
||||
import java.util.concurrent.SynchronousQueue;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import java.util.concurrent.ThreadFactory;
|
||||
import java.util.concurrent.ThreadPoolExecutor;
|
||||
|
||||
import net.i2p.I2PAppContext;
|
||||
import net.i2p.apps.systray.SysTray;
|
||||
@ -77,6 +81,7 @@ public class RouterConsoleRunner {
|
||||
private static final int MIN_THREADS = 1;
|
||||
private static final int MAX_THREADS = 24;
|
||||
private static final int MAX_IDLE_TIME = 90*1000;
|
||||
private static final String THREAD_NAME = "RouterConsole Jetty";
|
||||
|
||||
static {
|
||||
System.setProperty("org.mortbay.http.Version.paranoid", "true");
|
||||
@ -217,10 +222,12 @@ public class RouterConsoleRunner {
|
||||
// so Jetty can find WebAppConfiguration
|
||||
System.setProperty("jetty.class.path", I2PAppContext.getGlobalContext().getBaseDir() + "/lib/routerconsole.jar");
|
||||
_server = new Server();
|
||||
_server.setGracefulShutdown(1000);
|
||||
|
||||
/**** this doesn't work with NIO maybe?
|
||||
try {
|
||||
_server.setThreadPool(new ThreadPool(MIN_THREADS, MAX_THREADS, MAX_IDLE_TIME, TimeUnit.MILLISECONDS));
|
||||
ThreadPool ctp = new CustomThreadPoolExecutor();
|
||||
ctp.prestartAllCoreThreads();
|
||||
_server.setThreadPool(ctp);
|
||||
} catch (Throwable t) {
|
||||
// class not found...
|
||||
System.out.println("INFO: Jetty concurrent ThreadPool unavailable, using QueuedThreadPool");
|
||||
@ -229,7 +236,7 @@ public class RouterConsoleRunner {
|
||||
qtp.setMaxIdleTimeMs(MAX_IDLE_TIME);
|
||||
_server.setThreadPool(qtp);
|
||||
}
|
||||
****/
|
||||
|
||||
HandlerCollection hColl = new HandlerCollection();
|
||||
ContextHandlerCollection chColl = new ContextHandlerCollection();
|
||||
_server.addHandler(hColl);
|
||||
@ -673,4 +680,31 @@ public class RouterConsoleRunner {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Just to set the name and set Daemon
|
||||
* @since Jetty 6
|
||||
*/
|
||||
private static class CustomThreadPoolExecutor extends ThreadPool {
|
||||
public CustomThreadPoolExecutor() {
|
||||
super(MIN_THREADS, MAX_THREADS, MAX_IDLE_TIME, TimeUnit.MILLISECONDS,
|
||||
new SynchronousQueue(), new CustomThreadFactory(),
|
||||
new ThreadPoolExecutor.CallerRunsPolicy());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Just to set the name and set Daemon
|
||||
* @since Jetty 6
|
||||
*/
|
||||
private static class CustomThreadFactory implements ThreadFactory {
|
||||
|
||||
public Thread newThread(Runnable r) {
|
||||
Thread rv = Executors.defaultThreadFactory().newThread(r);
|
||||
rv.setName(THREAD_NAME);
|
||||
rv.setDaemon(true);
|
||||
return rv;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -938,7 +938,7 @@
|
||||
<fileset dir="build" includes="jasper*.jar javax*.jar jetty*.jar jsp*.jar org.mortbay.jetty.jar" />
|
||||
</copy>
|
||||
<copy todir="pkg-temp/eepsite" >
|
||||
<fileset dir="installer/resources/eepsite" includes="jetty.xml contexts/* etc/*" />
|
||||
<fileset dir="installer/resources/eepsite" includes="jetty.xml jetty-ssl.xml contexts/* etc/*" />
|
||||
</copy>
|
||||
</target>
|
||||
|
||||
|
35
installer/resources/eepsite/jetty-ssl.xml
Normal file
35
installer/resources/eepsite/jetty-ssl.xml
Normal file
@ -0,0 +1,35 @@
|
||||
<?xml version="1.0"?>
|
||||
<!DOCTYPE Configure PUBLIC "-//Mort Bay Consulting//DTD Configure//EN" "http://jetty.mortbay.org/configure.dtd">
|
||||
|
||||
<!-- =============================================================== -->
|
||||
<!-- Configure SSL for the Jetty Server -->
|
||||
<!-- this configuration file should be used in combination with -->
|
||||
<!-- other configuration files. e.g. -->
|
||||
<!-- java -jar start.jar etc/jetty.xml etc/jetty-ssl.xml -->
|
||||
<!-- =============================================================== -->
|
||||
<Configure id="Server" class="org.mortbay.jetty.Server">
|
||||
|
||||
|
||||
|
||||
<Call name="addConnector">
|
||||
<Arg>
|
||||
<New class="org.mortbay.jetty.security.SslSocketConnector">
|
||||
<Set name="Port">8443</Set>
|
||||
<Set name="maxIdleTime">30000</Set>
|
||||
<Set name="handshakeTimeout">2000</Set>
|
||||
<Set name="keystore">./eepsite/etc/keystore.ks</Set>
|
||||
<Set name="password">OBF:1vny1zlo1x8e1vnw1vn61x8g1zlu1vn4</Set>
|
||||
<Set name="keyPassword">OBF:1u2u1wml1z7s1z7a1wnl1u2g</Set>
|
||||
<Set name="truststore">./eepsite/etc/keystore.ks</Set>
|
||||
<Set name="trustPassword">OBF:1vny1zlo1x8e1vnw1vn61x8g1zlu1vn4</Set>
|
||||
<Set name="handshakeTimeout">2000</Set>
|
||||
<!-- Set name="ThreadPool">
|
||||
<New class="org.mortbay.thread.QueuedThreadPool">
|
||||
<Set name="minThreads">0</Set>
|
||||
<Set name="maxThreads">16</Set>
|
||||
</New>
|
||||
</Set -->
|
||||
</New>
|
||||
</Arg>
|
||||
</Call>
|
||||
</Configure>
|
@ -54,20 +54,32 @@
|
||||
<!-- =========================================================== -->
|
||||
<Set name="ThreadPool">
|
||||
|
||||
<!-- If you don't have threadpool
|
||||
<!-- PICK ONE -->
|
||||
|
||||
<!-- If you don't have or want threadpool
|
||||
Requests above the max will be queued
|
||||
-->
|
||||
<!--
|
||||
<New class="org.mortbay.thread.QueuedThreadPool">
|
||||
<Set name="minThreads">1</Set>
|
||||
<Set name="maxThreads">16</Set>
|
||||
<Set name="lowThreads">2</Set>
|
||||
</New>
|
||||
-->
|
||||
-->
|
||||
|
||||
<!-- Optional Java 5 bounded threadpool with job queue
|
||||
Requests above the max will be rejected
|
||||
TODO: would be nice to use the 5-arg constructor but
|
||||
how do you use an Enum as the TimeUnit argument?
|
||||
Alternatively, make a custom class where we can
|
||||
set the thread name, set daemon, etc.
|
||||
See RouterConsoleRunner.
|
||||
-->
|
||||
<New class="org.mortbay.thread.concurrent.ThreadPool">
|
||||
<Arg type="int">0</Arg>
|
||||
<Set name="corePoolSize">1</Set>
|
||||
<Set name="maximumPoolSize">16</Set>
|
||||
</New>
|
||||
-->
|
||||
</Set>
|
||||
|
||||
|
||||
@ -87,7 +99,7 @@
|
||||
<Set name="host">127.0.0.1</Set>
|
||||
<Set name="port">7658</Set>
|
||||
<Set name="maxIdleTime">60000</Set>
|
||||
<Set name="Acceptors">2</Set>
|
||||
<Set name="Acceptors">1</Set>
|
||||
<Set name="statsOn">false</Set>
|
||||
<Set name="confidentialPort">8443</Set>
|
||||
<Set name="lowResourcesConnections">5000</Set>
|
||||
@ -96,22 +108,12 @@
|
||||
</Arg>
|
||||
</Call>
|
||||
|
||||
<!-- Use this connector if NIO is not available.
|
||||
<Call name="addConnector">
|
||||
<Arg>
|
||||
<New class="org.mortbay.jetty.bio.SocketConnector">
|
||||
<Set name="port">7658</Set>
|
||||
<Set name="maxIdleTime">50000</Set>
|
||||
<Set name="lowResourceMaxIdleTime">1500</Set>
|
||||
</New>
|
||||
</Arg>
|
||||
</Call>
|
||||
-->
|
||||
|
||||
<!-- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -->
|
||||
<!-- To add a HTTPS SSL listener -->
|
||||
<!-- see jetty-ssl.xml to add an ssl connector. use -->
|
||||
<!-- java -jar start.jar etc/jetty.xml etc/jetty-ssl.xml -->
|
||||
<!-- To enable this change clients.config args to be: -->
|
||||
<!-- -->
|
||||
<!-- clientApp3.args=etc/jetty.xml etc/jetty-ssl.xml -->
|
||||
<!-- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -->
|
||||
<!-- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -->
|
||||
<!-- Add a HTTPS SSL listener on port 8443 -->
|
||||
@ -120,21 +122,13 @@
|
||||
<!-- You would need to generate a selfsigned certificate in a keystore -->
|
||||
<!-- in ~/.i2p/eepsite/keystore.ks, for example with the command line: -->
|
||||
<!--
|
||||
keytool -genkey -storetype JKS -keystore ~/.i2p/eepsite/keystore.ks -storepass changeit -alias console -dname CN=xyz123.eepsite.i2p.net,OU=Eepsite,O=I2P Anonymous Network,L=XX,ST=XX,C=XX -validity 3650 -keyalg DSA -keysize 1024 -keypass myKeyPassword
|
||||
keytool -genkey -storetype JKS -keystore ~/.i2p/eepsite/etc/keystore.ks -storepass changeit -alias console -dname CN=xyz123.eepsite.i2p.net,OU=Eepsite,O=I2P Anonymous Network,L=XX,ST=XX,C=XX -validity 3650 -keyalg DSA -keysize 1024 -keypass myKeyPassword
|
||||
-->
|
||||
<!-- Change the CN and key password in the example, of course. -->
|
||||
<!-- You wouldn't want to open this up to the regular internet, -->
|
||||
<!-- would you?? Untested and not recommended. -->
|
||||
<!-- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -->
|
||||
|
||||
<!-- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -->
|
||||
<!-- To allow Jetty to be started from xinetd -->
|
||||
<!-- mixin jetty-xinetd.xml: -->
|
||||
<!-- java -jar start.jar etc/jetty.xml etc/jetty-xinetd.xml -->
|
||||
<!-- -->
|
||||
<!-- See jetty-xinetd.xml for further instructions. -->
|
||||
<!-- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -->
|
||||
|
||||
<!-- =========================================================== -->
|
||||
<!-- Set up global session ID manager -->
|
||||
<!-- =========================================================== -->
|
||||
|
@ -151,6 +151,7 @@ public class WorkingDir {
|
||||
File newEep = new File(oldDirf, "eepsite");
|
||||
String newPath = newEep.getAbsolutePath() + File.separatorChar;
|
||||
success &= migrateJettyXml(oldEep, newEep, "jetty.xml", "./eepsite/", newPath);
|
||||
success &= migrateJettyXml(oldEep, newEep, "jetty-ssl.xml", "./eepsite/", newPath);
|
||||
success &= migrateJettyXml(oldEep, newEep, "contexts/base-context.xml", "./eepsite/", newPath);
|
||||
success &= migrateJettyXml(oldEep, newEep, "contexts/cgi-context.xml", "./eepsite/", newPath);
|
||||
success &= migrateClientsConfig(oldDirf, dirf);
|
||||
|
Reference in New Issue
Block a user