You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ode.apache.org by mi...@apache.org on 2009/11/03 00:08:23 UTC

svn commit: r832179 - /ode/trunk/axis2/src/main/java/org/apache/ode/axis2/ODEServer.java

Author: midon
Date: Mon Nov  2 23:08:23 2009
New Revision: 832179

URL: http://svn.apache.org/viewvc?rev=832179&view=rev
Log:
ODE-691: check periodically for idle http connections

Modified:
    ode/trunk/axis2/src/main/java/org/apache/ode/axis2/ODEServer.java

Modified: ode/trunk/axis2/src/main/java/org/apache/ode/axis2/ODEServer.java
URL: http://svn.apache.org/viewvc/ode/trunk/axis2/src/main/java/org/apache/ode/axis2/ODEServer.java?rev=832179&r1=832178&r2=832179&view=diff
==============================================================================
--- ode/trunk/axis2/src/main/java/org/apache/ode/axis2/ODEServer.java (original)
+++ ode/trunk/axis2/src/main/java/org/apache/ode/axis2/ODEServer.java Mon Nov  2 23:08:23 2009
@@ -53,6 +53,7 @@
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 import org.apache.commons.httpclient.MultiThreadedHttpConnectionManager;
+import org.apache.commons.httpclient.util.IdleConnectionTimeoutThread;
 import org.apache.commons.httpclient.params.HttpConnectionManagerParams;
 import org.apache.ode.axis2.deploy.DeploymentPoller;
 import org.apache.ode.axis2.hooks.ODEAxisService;
@@ -121,6 +122,7 @@
     private BpelServerConnector _connector;
     private ManagementService _mgtService;
     protected MultiThreadedHttpConnectionManager httpConnectionManager;
+    protected IdleConnectionTimeoutThread idleConnectionTimeoutThread;
 
     public void init(ServletConfig config, AxisConfiguration axisConf) throws ServletException {
         init(config.getServletContext().getRealPath("/WEB-INF"), axisConf);
@@ -335,6 +337,14 @@
                     __log.error("Unable to shut down HTTP connection manager.", t);
                 }
             }
+            if(idleConnectionTimeoutThread!=null){
+                __log.debug("shutting down Idle Connection Timeout Thread.");
+                try {
+                    idleConnectionTimeoutThread.shutdown();
+                } catch(Throwable t) {
+                    __log.error("Unable to shut down Idle Connection Timeout Thread.", t);
+                }
+            }
             try {
                 __log.debug("cleaning up temporary files.");
                 TempFileManager.cleanup();
@@ -562,6 +572,22 @@
         }
         httpConnectionManager.getParams().setDefaultMaxConnectionsPerHost(max_per_host);
         httpConnectionManager.getParams().setMaxTotalConnections(max_total);
+
+        // Register the connection manager to a idle check thread
+        idleConnectionTimeoutThread = new IdleConnectionTimeoutThread();
+        idleConnectionTimeoutThread.setName("Http_Idle_Connection_Timeout_Thread");
+        long idleConnectionTimeout = Long.parseLong(_odeConfig.getProperty("http.idle.connection.timeout", "30000"));
+        long idleConnectionCheckInterval = Long.parseLong(_odeConfig.getProperty("http.idle.connection.check.interval", "30000"));
+
+        if(__log.isDebugEnabled()){
+            __log.debug("http.idle.connection.timeout="+idleConnectionTimeout);
+            __log.debug("http.idle.connection.check.interval="+idleConnectionCheckInterval);
+        }
+        idleConnectionTimeoutThread.setConnectionTimeout(idleConnectionTimeout);
+        idleConnectionTimeoutThread.setTimeoutInterval(idleConnectionCheckInterval);
+
+        idleConnectionTimeoutThread.addConnectionManager(httpConnectionManager);
+        idleConnectionTimeoutThread.start();
     }
 
     public ProcessStoreImpl getProcessStore() {