Author: costin Date: Wed Nov 23 21:36:28 2005 New Revision: 348667 URL: http://svn.apache.org/viewcvs?rev=348667&view=rev Log: Updates to match the changes in endpoint ( and deprecation /removal of ThreadPool )
Modified: tomcat/sandbox/java/org/apache/coyote/http11/Http11BaseProtocol.java tomcat/sandbox/java/org/apache/coyote/http11/Http11Processor.java tomcat/sandbox/java/org/apache/coyote/http11/Http11Protocol.java Modified: tomcat/sandbox/java/org/apache/coyote/http11/Http11BaseProtocol.java URL: http://svn.apache.org/viewcvs/tomcat/sandbox/java/org/apache/coyote/http11/Http11BaseProtocol.java?rev=348667&r1=348666&r2=348667&view=diff ============================================================================== --- tomcat/sandbox/java/org/apache/coyote/http11/Http11BaseProtocol.java (original) +++ tomcat/sandbox/java/org/apache/coyote/http11/Http11BaseProtocol.java Wed Nov 23 21:36:28 2005 @@ -31,7 +31,6 @@ import org.apache.coyote.Adapter; import org.apache.coyote.ProtocolHandler; import org.apache.coyote.RequestGroupInfo; -import org.apache.coyote.RequestInfo; import org.apache.tomcat.util.net.PoolTcpEndpoint; import org.apache.tomcat.util.net.SSLImplementation; import org.apache.tomcat.util.net.SSLSupport; @@ -39,8 +38,6 @@ import org.apache.tomcat.util.net.TcpConnection; import org.apache.tomcat.util.net.TcpConnectionHandler; import org.apache.tomcat.util.res.StringManager; -import org.apache.tomcat.util.threads.ThreadPool; -import org.apache.tomcat.util.threads.ThreadWithAttributes; /** @@ -188,8 +185,9 @@ } // -------------------- Properties-------------------- - protected ThreadPool tp=ThreadPool.createThreadPool(true); - protected PoolTcpEndpoint ep=new PoolTcpEndpoint(tp); + // + protected PoolTcpEndpoint ep= PoolTcpEndpoint.getEndpoint("acc"); + protected boolean secure; protected ServerSocketFactory socketFactory; @@ -267,13 +265,9 @@ public String getStrategy() { return ep.getStrategy(); } - - /** Access to the thread pool. - * - * @return tp the internal thread pool used by the protocol - */ - public ThreadPool getThreadPool() { - return tp; + + public PoolTcpEndpoint getEndpoint() { + return ep; } // -------------------- Tcp setup -------------------- @@ -577,15 +571,6 @@ return server; } - - private static ServerSocketFactory string2SocketFactory( String val) - throws ClassNotFoundException, IllegalAccessException, - InstantiationException - { - Class chC=Class.forName( val ); - return (ServerSocketFactory)chC.newInstance(); - } - public int getTimeout() { return timeout; } @@ -607,12 +592,12 @@ public static final int THREAD_DATA_PROCESSOR=1; public static final int THREAD_DATA_OBJECT_NAME=2; - static class Http11ConnectionHandler implements TcpConnectionHandler { + public static class Http11ConnectionHandler implements TcpConnectionHandler { Http11BaseProtocol proto; static int count=0; - RequestGroupInfo global=new RequestGroupInfo(); + public RequestGroupInfo global=new RequestGroupInfo(); - Http11ConnectionHandler( Http11BaseProtocol proto ) { + public Http11ConnectionHandler( Http11BaseProtocol proto ) { this.proto=proto; } @@ -628,7 +613,6 @@ Http11Processor processor = new Http11Processor(proto.maxHttpHeaderSize); processor.setAdapter( proto.adapter ); - processor.setThreadPool( proto.tp ); processor.setEndpoint( proto.ep ); processor.setMaxKeepAliveRequests( proto.maxKeepAliveRequests ); processor.setTimeout( proto.timeout ); @@ -733,24 +717,9 @@ */ private void checkSocketFactory() throws Exception { if (secure) { - try { - // The SSL setup code has been moved into - // SSLImplementation since SocketFactory doesn't - // provide a wide enough interface - sslImplementation = - SSLImplementation.getInstance(sslImplementationName); - socketFactory = sslImplementation.getServerSocketFactory(); - ep.setServerSocketFactory(socketFactory); - } catch (ClassNotFoundException e){ - throw e; - } - } else if (socketFactoryName != null) { - try { - socketFactory = string2SocketFactory(socketFactoryName); - ep.setServerSocketFactory(socketFactory); - } catch(Exception sfex) { - throw sfex; - } + ep.setSSLSupport( secure, sslImplementationName ); + } else { + ep.setSSLSupport( secure, socketFactoryName ); } } Modified: tomcat/sandbox/java/org/apache/coyote/http11/Http11Processor.java URL: http://svn.apache.org/viewcvs/tomcat/sandbox/java/org/apache/coyote/http11/Http11Processor.java?rev=348667&r1=348666&r2=348667&view=diff ============================================================================== --- tomcat/sandbox/java/org/apache/coyote/http11/Http11Processor.java (original) +++ tomcat/sandbox/java/org/apache/coyote/http11/Http11Processor.java Wed Nov 23 21:36:28 2005 @@ -22,11 +22,11 @@ import java.io.OutputStream; import java.net.InetAddress; import java.net.Socket; +import java.security.AccessController; +import java.security.PrivilegedAction; import java.util.StringTokenizer; import java.util.regex.Pattern; import java.util.regex.PatternSyntaxException; -import java.security.AccessController; -import java.security.PrivilegedAction; import org.apache.coyote.ActionCode; import org.apache.coyote.ActionHook; @@ -35,6 +35,7 @@ import org.apache.coyote.Request; import org.apache.coyote.RequestInfo; import org.apache.coyote.Response; +import org.apache.coyote.http11.filters.BufferedInputFilter; import org.apache.coyote.http11.filters.ChunkedInputFilter; import org.apache.coyote.http11.filters.ChunkedOutputFilter; import org.apache.coyote.http11.filters.GzipOutputFilter; @@ -43,7 +44,6 @@ import org.apache.coyote.http11.filters.SavedRequestInputFilter; import org.apache.coyote.http11.filters.VoidInputFilter; import org.apache.coyote.http11.filters.VoidOutputFilter; -import org.apache.coyote.http11.filters.BufferedInputFilter; import org.apache.tomcat.util.buf.Ascii; import org.apache.tomcat.util.buf.ByteChunk; import org.apache.tomcat.util.buf.HexUtils; @@ -53,7 +53,6 @@ import org.apache.tomcat.util.net.PoolTcpEndpoint; import org.apache.tomcat.util.net.SSLSupport; import org.apache.tomcat.util.res.StringManager; -import org.apache.tomcat.util.threads.ThreadPool; import org.apache.tomcat.util.threads.ThreadWithAttributes; @@ -303,7 +302,7 @@ /** * Associated thread pool. */ - protected ThreadPool threadPool; + //protected ThreadPool threadPool; /** @@ -367,10 +366,6 @@ } - public void setThreadPool(ThreadPool threadPool) { - this.threadPool = threadPool; - } - public void setEndpoint(PoolTcpEndpoint endpoint) { this.endpoint = endpoint; @@ -765,7 +760,7 @@ ThreadWithAttributes thrA= (ThreadWithAttributes)Thread.currentThread(); RequestInfo rp = request.getRequestProcessor(); - thrA.setCurrentStage(threadPool, "parsing http request"); + thrA.setCurrentStage(endpoint, "parsing http request"); rp.setStage(org.apache.coyote.Constants.STAGE_PARSE); // Set the remote address @@ -788,9 +783,9 @@ int oldSoTimeout = soTimeout; int threadRatio = 0; - if (threadPool.getCurrentThreadsBusy() > 0) { - threadRatio = (threadPool.getCurrentThreadsBusy() * 100) - / threadPool.getMaxThreads(); + if (endpoint.getCurrentThreadsBusy() > 0) { + threadRatio = (endpoint.getCurrentThreadsBusy() * 100) + / endpoint.getMaxThreads(); } else { threadRatio = (endpoint.getCurrentThreadsBusy() * 100) / endpoint.getMaxThreads(); @@ -825,7 +820,7 @@ } inputBuffer.parseRequestLine(false); request.setStartTime(System.currentTimeMillis()); - thrA.setParam( threadPool, request.requestURI() ); + thrA.setParam( endpoint, request.requestURI() ); keptAlive = true; if (!disableUploadTimeout) { socket.setSoTimeout(timeout); @@ -844,7 +839,7 @@ } // Setting up filters, and parse some request headers - thrA.setCurrentStage(threadPool, "prepareRequest"); + thrA.setCurrentStage(endpoint, "prepareRequest"); rp.setStage(org.apache.coyote.Constants.STAGE_PREPARE); try { prepareRequest(); @@ -863,7 +858,7 @@ // Process the request in the adapter if (!error) { try { - thrA.setCurrentStage(threadPool, "service"); + thrA.setCurrentStage(endpoint, "service"); rp.setStage(org.apache.coyote.Constants.STAGE_SERVICE); adapter.service(request, response); // Handle when the response was committed before a serious @@ -888,7 +883,7 @@ // Finish the handling of the request try { - thrA.setCurrentStage(threadPool, "endRequestIB"); + thrA.setCurrentStage(endpoint, "endRequestIB"); rp.setStage(org.apache.coyote.Constants.STAGE_ENDINPUT); inputBuffer.endRequest(); } catch (IOException e) { @@ -900,7 +895,7 @@ error = true; } try { - thrA.setCurrentStage(threadPool, "endRequestOB"); + thrA.setCurrentStage(endpoint, "endRequestOB"); rp.setStage(org.apache.coyote.Constants.STAGE_ENDOUTPUT); outputBuffer.endRequest(); } catch (IOException e) { @@ -917,7 +912,7 @@ } request.updateCounters(); - thrA.setCurrentStage(threadPool, "ended"); + thrA.setCurrentStage(endpoint, "ended"); rp.setStage(org.apache.coyote.Constants.STAGE_KEEPALIVE); // Don't reset the param - we'll see it as ended. Next request Modified: tomcat/sandbox/java/org/apache/coyote/http11/Http11Protocol.java URL: http://svn.apache.org/viewcvs/tomcat/sandbox/java/org/apache/coyote/http11/Http11Protocol.java?rev=348667&r1=348666&r2=348667&view=diff ============================================================================== --- tomcat/sandbox/java/org/apache/coyote/http11/Http11Protocol.java (original) +++ tomcat/sandbox/java/org/apache/coyote/http11/Http11Protocol.java Wed Nov 23 21:36:28 2005 @@ -80,16 +80,10 @@ // XXX It should be possible to use a single TP tpOname=new ObjectName (domain + ":" + "type=ThreadPool,name=" + getName()); - if ("ms".equals(getStrategy())) { - Registry.getRegistry(null, null) - .registerComponent(ep, tpOname, null ); - } else { - Registry.getRegistry(null, null) - .registerComponent(tp, tpOname, null ); - } - tp.setName(getName()); - tp.setDaemon(false); - tp.addThreadPoolListener(new MXPoolListener(this, tp)); + Registry.getRegistry(null, null).registerComponent(ep, tpOname, null ); + ep.setName(getName()); + ep.setDaemon(false); + ep.addEndpointListener(new MXPoolListener(this, ep)); } catch (Exception e) { log.error("Can't register threadpool" ); } @@ -112,15 +106,15 @@ // -------------------- Connection handler -------------------- - static class MXPoolListener implements ThreadPool.ThreadPoolListener { - MXPoolListener( Http11Protocol proto, ThreadPool control ) { + static class MXPoolListener implements PoolTcpEndpoint.EndpointListener { + MXPoolListener( Http11Protocol proto, PoolTcpEndpoint control ) { } - public void threadStart(ThreadPool tp, Thread t) { + public void threadStart(PoolTcpEndpoint tp, Thread t) { } - public void threadEnd(ThreadPool tp, Thread t) { + public void threadEnd(PoolTcpEndpoint tp, Thread t) { // Register our associated processor // TP uses only TWA ThreadWithAttributes ta=(ThreadWithAttributes)t; --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]