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
This commit is contained in:
Michael Gorovoy 2010-06-04 23:40:29 +00:00
parent 2dee039305
commit 41884b613c
3 changed files with 37 additions and 7 deletions

View File

@ -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

View File

@ -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);
}
}

View File

@ -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);
}
}
/* ------------------------------------------------------------ */