Return-Path: Mailing-List: contact tomcat-dev-help@jakarta.apache.org; run by ezmlm Delivered-To: mailing list tomcat-dev@jakarta.apache.org Received: (qmail 33363 invoked from network); 27 Aug 2003 05:01:25 -0000 Received: from unknown (HELO ms-smtp-03.southeast.rr.com) (24.93.67.84) by daedalus.apache.org with SMTP; 27 Aug 2003 05:01:25 -0000 Received: from mutt.rcfile.org (rdu26-39-019.nc.rr.com [66.26.39.19]) by ms-smtp-03.southeast.rr.com (8.12.5/8.12.2) with ESMTP id h7R3sgxk010195 for ; Tue, 26 Aug 2003 23:54:43 -0400 (EDT) Received: from mutt.rcfile.org (localhost [127.0.0.1]) by mutt.rcfile.org (8.12.9/8.12.9) with ESMTP id h7R3usfU014644 for ; Tue, 26 Aug 2003 23:56:54 -0400 (EDT) (envelope-from brent@mutt.rcfile.org) Received: (from brent@localhost) by mutt.rcfile.org (8.12.9/8.12.9/Submit) id h7R3usM9014643 for tomcat-dev@jakarta.apache.org; Tue, 26 Aug 2003 23:56:54 -0400 (EDT) Date: Tue, 26 Aug 2003 23:56:53 -0400 From: Brent Verner To: tomcat-dev@jakarta.apache.org Subject: problem with start/stop of CoyoteConnector Message-ID: <20030827035653.GA14289@rcfile.org> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="yrj/dFKFPuw6o+aM" Content-Disposition: inline X-muttrc: $Id: .muttrc,v 1.10 2003/02/08 08:35:24 brent Exp $ X-uname: FreeBSD 4.8-STABLE #5: Sun Aug 24 07:08:48 EDT 2003 root@mutt.rcfile.org:/usr/obj/usr/src/sys/MUTTS User-Agent: Mutt/1.5.4i X-Spam-Rating: daedalus.apache.org 1.6.2 0/1000/N --yrj/dFKFPuw6o+aM Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Overview: CoytoteConnector.start()/stop() are misbehaving on tomcat-4.1.27 a) the org.apache.coyote.http11.Http11Protocol handler will _not_ start() successfully after I've stop()ped it. b) the org.apache.jk.server.JkCoyoteHandler handler will start() after a stop() but after a number of stop()/start() cycles, it fails to start successfully. In both cases, the connector thinks the handler isAvailable(), but there is simply no service being offered on the specified port. nada. Is this a known issue with the connector/handler interaction? A quick perusal of the source did not lead me to a quick answer, and I won't have any real time to dig into the problem until after the project is complete (a couple of months away), so I'm asking y'all. Details: I've got apache/mod_jk setup to loadbalance with a pool of tomcats as shown below. (Round Robin DNS) _______________________ A1 A2 A3 /--\-------/--\------/--\ <-- mod_jk lb worker balancing/session affinity T1P | T2P | T3P | <-- primary Tomcat Services | | | T1S T2S T3S <-- secondary tomcat Services On each of the T.P (primary) tomcats, I have a Valve that verifies a connection to an external data source (proprietary CMS thingie), and when it fails, it does a CoyoteConnector.stop() for the Jk handler, sends a redirect back thru the DNS layer, so it will get another tomcat that has a valid connection to the external data source. All of this appeared to work as intended, so I wrote a quickie JSP to let the client to "restart" the downed connectors which were stop()ped due to the external data source becoming unavailable. At this point I noticed that issuing a stop()/start() sequence to the http11 connector caused the http11 connector to not _really_ restart (and listen for connections). Having seen this "issue" is only allowed the Jk connector to be "managed" via this JSP. After a handful of stop()/start() cycles on the Jk handler, I noticed that the Jk connector wasn't really listening for connections while the CoyoteConnector thought is was "available". In addition to this, the misbehaving handlers are not properly reinitialized (to listen for conns) even when reloading the context via the /manager/ interface. Can anyone offer any possible solution to this? It is _not_ critical, as the client can easily restart the tomcats one at a time if this situation arises in production. I'm mostly wanting to see this bug squashed :-) FWIW, I've attached the JSP that handles the restarting of downed services. cheers. b -- "Develop your talent, man, and leave the world something. Records are really gifts from people. To think that an artist would love you enough to share his music with anyone is a beautiful thing." -- Duane Allman --yrj/dFKFPuw6o+aM Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename="connectors.jsp" <%@ page import=" org.apache.catalina.*, org.apache.catalina.core.*, org.apache.coyote.tomcat4.CoyoteConnector "%> <% StandardServer server = (StandardServer)ServerFactory.getServer(); Service[] services = server.findServices(); %> <% for( int i = 0; i < services.length; ++i ){ StandardService service = (StandardService)services[i]; //try { // service.stop(); // service.start(); //} //catch( Exception ex ){ // //} Connector[] connectors = service.findConnectors(); for( int j = 0; j < connectors.length; ++j ){ try { Connector connector_c = connectors[j]; CoyoteConnector connector = (CoyoteConnector)connector_c; if( "org.apache.jk.server.JkCoyoteHandler".equals(connector.getProtocolHandlerClassName()) ){ if( request.getParameter("cmd") != null ){ if( service.toString().equals(request.getParameter("service")) && connector.toString().equals(request.getParameter("connector")) ){ if( "start".equals(request.getParameter("cmd")) ){ if( ! connector.isAvailable() ){ try{ connector.start(); } catch( Exception ex ){ ex.printStackTrace(); } } } else if( "stop".equals(request.getParameter("cmd")) ){ if( connector.isAvailable() ){ connector.stop(); } } else if( "restart".equals(request.getParameter("cmd")) ){ if( connector.isAvailable() ){ try { connector.stop(); } catch( Exception ex ){ ex.printStackTrace(); } } Thread.currentThread().sleep(100); try{ connector.start(); } catch( Exception ex ){ ex.printStackTrace(); } } response.sendRedirect(request.getRequestURI()); } } boolean started = connector.isAvailable(); %> <% } } catch( Exception ex ){ } } } %>
Service Handler Port Start Stop Restart
<%= service %> <%= connector.getProtocolHandlerClassName() %> <%= connector.getPort() %> <% try{ java.net.Socket sock = new java.net.Socket("localhost",connector.getPort()); sock.close(); %> up <% } catch( Exception ex ){ %> down <% } %> <% if( started ){ %> started <% } else{ %> start <% } %> <% if( ! started ){ %> stopped <% } else{ %> stop <% } %> restart
--yrj/dFKFPuw6o+aM--