Changeset ec7ec56


Ignore:
Timestamp:
Dec 24, 2011 5:09:01 PM (8 years ago)
Author:
zzz <zzz@…>
Branches:
master
Children:
07162b5
Parents:
0fb9096
Message:
  • Fix Console concurrent ThreadPool?
  • Uncomment eepsite concurrent ThreadPool? and fix arguments
  • Reduce eepsite acceptors to 1
  • Add jetty-ssl.xml example
  • jetty.xml cleanup
Files:
1 added
4 edited

Legend:

Unmodified
Added
Removed
  • apps/routerconsole/java/src/net/i2p/router/web/RouterConsoleRunner.java

    r0fb9096 rec7ec56  
    1010import java.util.Properties;
    1111import java.util.StringTokenizer;
     12import java.util.concurrent.Executors;
     13import java.util.concurrent.SynchronousQueue;
    1214import java.util.concurrent.TimeUnit;
     15import java.util.concurrent.ThreadFactory;
     16import java.util.concurrent.ThreadPoolExecutor;
    1317
    1418import net.i2p.I2PAppContext;
     
    7882    private static final int MAX_THREADS = 24;
    7983    private static final int MAX_IDLE_TIME = 90*1000;
     84    private static final String THREAD_NAME = "RouterConsole Jetty";
    8085   
    8186    static {
     
    218223        System.setProperty("jetty.class.path", I2PAppContext.getGlobalContext().getBaseDir() + "/lib/routerconsole.jar");
    219224        _server = new Server();
    220 
    221     /**** this doesn't work with NIO maybe?
     225        _server.setGracefulShutdown(1000);
     226
    222227        try {
    223             _server.setThreadPool(new ThreadPool(MIN_THREADS, MAX_THREADS, MAX_IDLE_TIME, TimeUnit.MILLISECONDS));
     228            ThreadPool ctp = new CustomThreadPoolExecutor();
     229            ctp.prestartAllCoreThreads();
     230            _server.setThreadPool(ctp);
    224231        } catch (Throwable t) {
    225232            // class not found...
     
    230237            _server.setThreadPool(qtp);
    231238        }
    232      ****/
     239
    233240        HandlerCollection hColl = new HandlerCollection();
    234241        ContextHandlerCollection chColl = new ContextHandlerCollection();
     
    674681    }
    675682
     683   
     684    /**
     685     * Just to set the name and set Daemon
     686     * @since Jetty 6
     687     */
     688    private static class CustomThreadPoolExecutor extends ThreadPool {
     689        public CustomThreadPoolExecutor() {
     690             super(MIN_THREADS, MAX_THREADS, MAX_IDLE_TIME, TimeUnit.MILLISECONDS,
     691                   new SynchronousQueue(), new CustomThreadFactory(),
     692                   new ThreadPoolExecutor.CallerRunsPolicy());
     693        }
     694    }
     695
     696    /**
     697     * Just to set the name and set Daemon
     698     * @since Jetty 6
     699     */
     700    private static class CustomThreadFactory implements ThreadFactory {
     701
     702        public Thread newThread(Runnable r) {
     703            Thread rv = Executors.defaultThreadFactory().newThread(r);
     704            rv.setName(THREAD_NAME);
     705            rv.setDaemon(true);
     706            return rv;
     707        }
     708    }
     709
    676710}
  • build.xml

    r0fb9096 rec7ec56  
    939939        </copy>
    940940        <copy todir="pkg-temp/eepsite" >
    941             <fileset dir="installer/resources/eepsite" includes="jetty.xml contexts/* etc/*" />
     941            <fileset dir="installer/resources/eepsite" includes="jetty.xml jetty-ssl.xml contexts/* etc/*" />
    942942        </copy>
    943943    </target>
  • installer/resources/eepsite/jetty.xml

    r0fb9096 rec7ec56  
    5555    <Set name="ThreadPool">
    5656
    57       <!-- If you don't have threadpool
     57      <!-- PICK ONE -->
     58
     59      <!-- If you don't have or want threadpool
     60           Requests above the max will be queued
     61       -->
     62     <!--
    5863      <New class="org.mortbay.thread.QueuedThreadPool">
    5964        <Set name="minThreads">1</Set>
     
    6166        <Set name="lowThreads">2</Set>
    6267      </New>
    63       -->
     68     -->
    6469
    6570      <!-- Optional Java 5 bounded threadpool with job queue
     71           Requests above the max will be rejected
     72           TODO: would be nice to use the 5-arg constructor but
     73                 how do you use an Enum as the TimeUnit argument?
     74           Alternatively, make a custom class where we can
     75           set the thread name, set daemon, etc.
     76           See RouterConsoleRunner.
     77       -->
    6678      <New class="org.mortbay.thread.concurrent.ThreadPool">
     79        <Arg type="int">0</Arg>
    6780        <Set name="corePoolSize">1</Set>
    6881        <Set name="maximumPoolSize">16</Set>
    6982      </New>
    70       -->
    7183    </Set>
    7284
     
    88100            <Set name="port">7658</Set>
    89101            <Set name="maxIdleTime">60000</Set>
    90             <Set name="Acceptors">2</Set>
     102            <Set name="Acceptors">1</Set>
    91103            <Set name="statsOn">false</Set>
    92104            <Set name="confidentialPort">8443</Set>
     
    97109    </Call>
    98110
    99     <!-- Use this connector if NIO is not available.
    100     <Call name="addConnector">
    101       <Arg>
    102           <New class="org.mortbay.jetty.bio.SocketConnector">
    103             <Set name="port">7658</Set>
    104             <Set name="maxIdleTime">50000</Set>
    105             <Set name="lowResourceMaxIdleTime">1500</Set>
    106           </New>
    107       </Arg>
    108     </Call>
    109     -->
    110 
    111111    <!-- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -->
    112112    <!-- To add a HTTPS SSL listener                                     -->
    113113    <!-- see jetty-ssl.xml to add an ssl connector. use                  -->
    114     <!-- java -jar start.jar etc/jetty.xml etc/jetty-ssl.xml             -->
     114    <!-- To enable this change clients.config args to be:                -->
     115    <!--                                                                 -->
     116    <!--   clientApp3.args=etc/jetty.xml etc/jetty-ssl.xml               -->
    115117    <!-- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -->
    116118  <!-- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -->
     
    121123  <!-- in ~/.i2p/eepsite/keystore.ks, for example with the command line:   -->
    122124  <!--
    123        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
     125       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
    124126   -->
    125127  <!-- Change the CN and key password in the example, of course.           -->
     
    128130  <!-- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -->
    129131
    130     <!-- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -->
    131     <!-- To allow Jetty to be started from xinetd                        -->
    132     <!-- mixin jetty-xinetd.xml:                                         -->
    133     <!--   java -jar start.jar etc/jetty.xml etc/jetty-xinetd.xml        -->
    134     <!--                                                                 -->
    135     <!-- See jetty-xinetd.xml for further instructions.                  -->
    136     <!-- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -->
    137    
    138132    <!-- =========================================================== -->
    139133    <!-- Set up global session ID manager                            -->
  • router/java/src/net/i2p/router/startup/WorkingDir.java

    r0fb9096 rec7ec56  
    152152        String newPath = newEep.getAbsolutePath() + File.separatorChar;
    153153        success &= migrateJettyXml(oldEep, newEep, "jetty.xml", "./eepsite/", newPath);
     154        success &= migrateJettyXml(oldEep, newEep, "jetty-ssl.xml", "./eepsite/", newPath);
    154155        success &= migrateJettyXml(oldEep, newEep, "contexts/base-context.xml", "./eepsite/", newPath);
    155156        success &= migrateJettyXml(oldEep, newEep, "contexts/cgi-context.xml", "./eepsite/", newPath);
Note: See TracChangeset for help on using the changeset viewer.