Author: mcardle
Date: Mon Aug 21 07:50:57 2006
New Revision: 312
URL: https://svndev.jahia.net/websvn/listing.php?sc=1&rev=312&repname=esi_server
Log:
* periodically removes unused http connections during high loads
Modified:
trunk/src/org/jahia/esi/cache/CacheJanitor.java
Modified: trunk/src/org/jahia/esi/cache/CacheJanitor.java
URL:
https://svndev.jahia.net/websvn/diff.php?path=/trunk/src/org/jahia/esi/cache/CacheJanitor.java&rev=312&repname=esi_server
==============================================================================
--- trunk/src/org/jahia/esi/cache/CacheJanitor.java (original)
+++ trunk/src/org/jahia/esi/cache/CacheJanitor.java Mon Aug 21 07:50:57 2006
@@ -50,6 +50,8 @@
import java.util.Date;
+import net.sf.j2ep.ProxyFilter;
+
/**
* User: jahia
* Date: 08-Feb-2006
@@ -215,6 +217,20 @@
this.firstRun = false;
this.inUse = memoryInUse();
}
+
+ //TODO: move this to a seperate checker thread since this is a
Cache-related thread, not a Connection-related thread
+ //occassionally check if there are too many idle connections, and
if so remove them.
+ if (Math.random()>0.95 &&
+
ProxyFilter.getMultiThreadedHttpConnectionManager().getConnectionsInPool()
+ >
+
0.9*SettingsBean.getInstance().getMaxHttpConnectionsPerHost() ) {
+
+ int beforeConnTotal =
ProxyFilter.getMultiThreadedHttpConnectionManager().getConnectionsInPool();
+
ProxyFilter.getMultiThreadedHttpConnectionManager().closeIdleConnections(SettingsBean.getInstance().getConnectionTimeout());
+
ProxyFilter.getMultiThreadedHttpConnectionManager().deleteClosedConnections();
+ log.info("Cleared out Idle connections. Total number of
connections reduced from "+beforeConnTotal+ " to
"+ProxyFilter.getMultiThreadedHttpConnectionManager().getConnectionsInPool());
+ }
+
}
}