costin 2003/01/16 14:13:37 Modified: jk/java/org/apache/jk/common HandlerRequest.java ChannelSocket.java Log: Add JMX info. The thread pool will be registered, as well as RequestProcessor. For each request we'll save in the thread pool attributes the stage and URI. If the JkHandlers are not registered - the domain is not set and nothing will happen. Revision Changes Path 1.21 +23 -2 jakarta-tomcat-connectors/jk/java/org/apache/jk/common/HandlerRequest.java Index: HandlerRequest.java =================================================================== RCS file: /home/cvs/jakarta-tomcat-connectors/jk/java/org/apache/jk/common/HandlerRequest.java,v retrieving revision 1.20 retrieving revision 1.21 diff -u -r1.20 -r1.21 --- HandlerRequest.java 18 Dec 2002 09:26:48 -0000 1.20 +++ HandlerRequest.java 16 Jan 2003 22:13:37 -0000 1.21 @@ -68,9 +68,11 @@ import org.apache.tomcat.util.http.*; import org.apache.tomcat.util.buf.*; import org.apache.tomcat.util.net.SSLSupport; +import org.apache.tomcat.util.threads.ThreadWithAttributes; import org.apache.coyote.Request; import org.apache.coyote.*; +import org.apache.commons.modeler.Registry; /** * Handle messages related with basic request information. @@ -328,6 +330,8 @@ throws IOException { int type=msg.getByte(); + ThreadWithAttributes twa=(ThreadWithAttributes)Thread.currentThread(); + Object control=ep.getControl(); MessageBytes tmpMB=(MessageBytes)ep.getNote( tmpBufNote ); if( tmpMB==null ) { @@ -339,8 +343,12 @@ switch( type ) { case JK_AJP13_FORWARD_REQUEST: - try { + try { + twa.setCurrentStage(control, "JkDecode"); decodeRequest( msg, ep, tmpMB ); + twa.setCurrentStage(control, "JkService"); + twa.setParam(control, + ((Request)ep.getRequest()).unparsedURI().toString()); } catch( Exception ex ) { log.error( "Error decoding request ", ex ); msg.dump( "Incomming message"); @@ -356,8 +364,10 @@ if(log.isDebugEnabled() ) log.debug("Calling next " + next.getName() + " " + next.getClass().getName()); - + int err= next.invoke( msg, ep ); + twa.setCurrentStage(control, "JkDone"); + if( log.isDebugEnabled() ) log.debug( "Invoke returned " + err ); return err; @@ -400,6 +410,8 @@ return OK; } + static int count=0; + private int decodeRequest( Msg msg, MsgContext ep, MessageBytes tmpMB ) throws IOException { @@ -410,6 +422,15 @@ Response res=new Response(); req.setResponse(res); ep.setRequest( req ); + RequestProcessor rp=new RequestProcessor(req); + if( this.getDomain() != null ) { + try { + Registry.getRegistry().registerComponent( rp, + getDomain(), "RequestProcessor", "name=Request" + count++ ); + } catch( Exception ex ) { + log.warn("Error registering request"); + } + } } JkInputStream jkBody=(JkInputStream)ep.getNote( bodyNote ); 1.31 +24 -6 jakarta-tomcat-connectors/jk/java/org/apache/jk/common/ChannelSocket.java Index: ChannelSocket.java =================================================================== RCS file: /home/cvs/jakarta-tomcat-connectors/jk/java/org/apache/jk/common/ChannelSocket.java,v retrieving revision 1.30 retrieving revision 1.31 diff -u -r1.30 -r1.31 --- ChannelSocket.java 19 Dec 2002 15:36:32 -0000 1.30 +++ ChannelSocket.java 16 Jan 2003 22:13:37 -0000 1.31 @@ -70,6 +70,8 @@ import org.apache.tomcat.util.threads.*; import org.apache.jk.core.*; +import org.apache.jk.server.JkMain; +import org.apache.commons.modeler.Registry; /* XXX Make the 'message type' pluggable @@ -95,6 +97,10 @@ * @author Costin Manolache * @jmx:mbean name="jk2:service=ChannelSocket" * description="Accept socket connections" + * @jmx:notification name="org.apache.coyote.INVOKE + * @jmx:notification-handler name="org.apache.jk.JK_SEND_PACKET + * @jmx:notification-handler name="org.apache.jk.JK_RECEIVE_PACKET + * @jmx:notification-handler name="org.apache.jk.JK_FLUSH */ public class ChannelSocket extends JkHandler { private static org.apache.commons.logging.Log log= @@ -118,7 +124,7 @@ */ static final boolean BUFFER_WRITE=false; - ThreadPool tp=new ThreadPool(); + ThreadPool tp=ThreadPool.createThreadPool(true); /* ==================== Tcp socket options ==================== */ @@ -126,6 +132,7 @@ * @jmx:managed-constructor description="default constructor" */ public ChannelSocket() { + // This should be integrated with the domain setup } public ThreadPool getThreadPool() { @@ -286,6 +293,7 @@ os = s.getOutputStream(); ep.setNote( isNote, is ); ep.setNote( osNote, os ); + ep.setControl( tp ); } public void resetCounters() { @@ -309,9 +317,9 @@ port = 0; log.info("JK2: ajp13 disabling channelSocket"); running = true; - return; + return; } - if (maxPort < startPort) + if (maxPort < startPort) maxPort = startPort; if (getAddress() == null) setAddress("0.0.0.0"); @@ -325,13 +333,13 @@ continue; } } - + if( sSocket==null ) { log.error("Can't find free port " + startPort + " " + maxPort ); return; } log.info("JK2: ajp13 listening on " + getAddress() + ":" + port ); - + // If this is not the base port and we are the 'main' channleSocket and // SHM didn't already set the localId - we'll set the instance id if( "channelSocket".equals( name ) && @@ -343,7 +351,7 @@ sSocket.setSoTimeout( serverTimeout ); if( next==null ) { - if( nextName!=null ) + if( nextName!=null ) setNext( wEnv.getHandler( nextName ) ); if( next==null ) next=wEnv.getHandler( "dispatch" ); @@ -354,6 +362,16 @@ running = true; // Run a thread that will accept connections. + // XXX Try to find a thread first - not sure how... + if( this.domain != null ) { + try { + Registry.getRegistry().registerComponent(tp, domain,"ThreadPool", + "type=ThreadPool,worker=jk,name=" + getAddress() + "%" + port); + } catch (Exception e) { + log.error("Can't register threadpool" ); + } + } + tp.start(); SocketAcceptor acceptAjp=new SocketAcceptor( this ); tp.runIt( acceptAjp);
-- To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]> For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>