diff options
author | Michael Gorovoy | 2010-06-04 23:40:29 +0000 |
---|---|---|
committer | Michael Gorovoy | 2010-06-04 23:40:29 +0000 |
commit | 41884b613cdc7d3b02f2377a6f2ac0fa152edc10 (patch) | |
tree | 65f6191c35b9ef81766056790c0937b526199227 | |
parent | 2dee039305a6d1a867f069e73c42e8cbbdcfeb16 (diff) | |
download | org.eclipse.jetty.project-41884b613cdc7d3b02f2377a6f2ac0fa152edc10.tar.gz org.eclipse.jetty.project-41884b613cdc7d3b02f2377a6f2ac0fa152edc10.tar.xz org.eclipse.jetty.project-41884b613cdc7d3b02f2377a6f2ac0fa152edc10.zip |
292814 Make QoSFilter and DoSFilter JMX manageable
git-svn-id: svn+ssh://dev.eclipse.org/svnroot/rt/org.eclipse.jetty/jetty/trunk@1927 7e9141cc-0065-0410-87d8-b60c137991c4
-rw-r--r-- | VERSION.txt | 1 | ||||
-rw-r--r-- | jetty-servlets/src/main/java/org/eclipse/jetty/servlets/DoSFilter.java | 13 | ||||
-rw-r--r-- | jetty-servlets/src/main/java/org/eclipse/jetty/servlets/QoSFilter.java | 30 |
3 files changed, 37 insertions, 7 deletions
diff --git a/VERSION.txt b/VERSION.txt index a91ff7b4a7..fb86a38c90 100644 --- a/VERSION.txt +++ b/VERSION.txt @@ -1,5 +1,6 @@ jetty-7.1.4-SNAPSHOT + 292326 Stop continuations if server is stopped. + + 292814 Make QoSFilter and DoSFilter JMX manageable + 293222 Improve request log to handle/show asynchronous latency + 294212 Can not customize session cookie path + 302350 org.eclipse.jetty.server.NCSARequestLog is missing JavaDoc diff --git a/jetty-servlets/src/main/java/org/eclipse/jetty/servlets/DoSFilter.java b/jetty-servlets/src/main/java/org/eclipse/jetty/servlets/DoSFilter.java index 24ef842311..577c075ca3 100644 --- a/jetty-servlets/src/main/java/org/eclipse/jetty/servlets/DoSFilter.java +++ b/jetty-servlets/src/main/java/org/eclipse/jetty/servlets/DoSFilter.java @@ -96,6 +96,7 @@ public class DoSFilter implements Filter final static String __TRACKER = "DoSFilter.Tracker"; final static String __THROTTLED = "DoSFilter.Throttled"; + final static String __DEFAULT_ATTR_PREFIX = "DoSFilter"; final static int __DEFAULT_MAX_REQUESTS_PER_SEC = 25; final static int __DEFAULT_DELAY_MS = 100; final static int __DEFAULT_THROTTLE = 5; @@ -104,6 +105,7 @@ public class DoSFilter implements Filter final static long __DEFAULT_MAX_REQUEST_MS_INIT_PARAM=30000L; final static long __DEFAULT_MAX_IDLE_TRACKER_MS_INIT_PARAM=30000L; + final static String ATTR_PREFIX_INIT_PARAM = "attrPrefix"; final static String MAX_REQUESTS_PER_S_INIT_PARAM = "maxRequestsPerSec"; final static String DELAY_MS_INIT_PARAM = "delayMs"; final static String THROTTLED_REQUESTS_INIT_PARAM = "throttledRequests"; @@ -123,6 +125,7 @@ public class DoSFilter implements Filter ServletContext _context; + protected String _name; protected long _delayMs; protected long _throttleMs; protected long _maxWaitMs; @@ -151,6 +154,11 @@ public class DoSFilter implements Filter { _context = filterConfig.getServletContext(); + String attrPrefix = __DEFAULT_ATTR_PREFIX; + if (filterConfig.getInitParameter(ATTR_PREFIX_INIT_PARAM)!=null) + attrPrefix=filterConfig.getInitParameter(ATTR_PREFIX_INIT_PARAM); + _name = attrPrefix; + _queue = new Queue[getMaxPriority() + 1]; _listener = new ContinuationListener[getMaxPriority() + 1]; for (int p = 0; p < _queue.length; p++) @@ -266,6 +274,11 @@ public class DoSFilter implements Filter } }); _timerThread.start(); + + if (_context!=null) + { + _context.setAttribute("org.eclipse.jetty.servlets."+_name,this); + } } diff --git a/jetty-servlets/src/main/java/org/eclipse/jetty/servlets/QoSFilter.java b/jetty-servlets/src/main/java/org/eclipse/jetty/servlets/QoSFilter.java index 16b1de3c07..afe4b4e2e8 100644 --- a/jetty-servlets/src/main/java/org/eclipse/jetty/servlets/QoSFilter.java +++ b/jetty-servlets/src/main/java/org/eclipse/jetty/servlets/QoSFilter.java @@ -33,6 +33,7 @@ import javax.servlet.http.HttpSession; import org.eclipse.jetty.continuation.Continuation; import org.eclipse.jetty.continuation.ContinuationListener; import org.eclipse.jetty.continuation.ContinuationSupport; +import org.eclipse.jetty.util.log.Log; /** * Quality of Service Filter. @@ -67,24 +68,29 @@ import org.eclipse.jetty.continuation.ContinuationSupport; */ public class QoSFilter implements Filter { + final static String __DEFAULT_ATTR_PREFIX="QoSFilter"; final static int __DEFAULT_MAX_PRIORITY=10; final static int __DEFAULT_PASSES=10; final static int __DEFAULT_WAIT_MS=50; final static long __DEFAULT_TIMEOUT_MS = -1; + final static String ATTR_PREFIX_INIT_PARAM="attrPrefix"; final static String MAX_REQUESTS_INIT_PARAM="maxRequests"; final static String MAX_PRIORITY_INIT_PARAM="maxPriority"; final static String MAX_WAIT_INIT_PARAM="waitMs"; final static String SUSPEND_INIT_PARAM="suspendMs"; ServletContext _context; - long _waitMs; - long _suspendMs; - int _maxRequests; - Semaphore _passes; - Queue<Continuation>[] _queue; - ContinuationListener[] _listener; - String _suspended="QoSFilter@"+this.hashCode(); + + protected String _name; + protected long _waitMs; + protected long _suspendMs; + protected int _maxRequests; + + private Semaphore _passes; + private Queue<Continuation>[] _queue; + private ContinuationListener[] _listener; + private String _suspended=__DEFAULT_ATTR_PREFIX+"@"+this.hashCode(); /* ------------------------------------------------------------ */ /** @@ -94,6 +100,11 @@ public class QoSFilter implements Filter { _context=filterConfig.getServletContext(); + String attrPrefix = __DEFAULT_ATTR_PREFIX; + if (filterConfig.getInitParameter(ATTR_PREFIX_INIT_PARAM)!=null) + attrPrefix = filterConfig.getInitParameter(ATTR_PREFIX_INIT_PARAM); + _name = attrPrefix; + int max_priority=__DEFAULT_MAX_PRIORITY; if (filterConfig.getInitParameter(MAX_PRIORITY_INIT_PARAM)!=null) max_priority=Integer.parseInt(filterConfig.getInitParameter(MAX_PRIORITY_INIT_PARAM)); @@ -131,6 +142,11 @@ public class QoSFilter implements Filter if (filterConfig.getInitParameter(SUSPEND_INIT_PARAM)!=null) suspend=Integer.parseInt(filterConfig.getInitParameter(SUSPEND_INIT_PARAM)); _suspendMs=suspend; + + if (_context!=null) + { + _context.setAttribute("org.eclipse.jetty.servlets."+_name,this); + } } /* ------------------------------------------------------------ */ |