JETTY-1074 JMX thread manipulation

git-svn-id: svn+ssh://dev.eclipse.org/svnroot/rt/org.eclipse.jetty/jetty/trunk@627 7e9141cc-0065-0410-87d8-b60c137991c4
This commit is contained in:
Greg Wilkins 2009-08-04 07:36:49 +00:00
parent 6deb6a6446
commit 62c605f802
14 changed files with 284 additions and 108 deletions

View File

@ -15,6 +15,7 @@ jetty-7.0.0.RC2 29 June 2009
+ Improved handling of overlays and resourceCollections
+ 285006 fix AbstractConnector NPE during shutdown.
+ Improved deferred authentication handling
+ JETTY-1074 JMX thread manipulation
jetty-7.0.0.RC1 15 June 2009
+ JETTY-1066 283357 400 response for bad URIs

View File

@ -223,28 +223,31 @@ public class WebAppDeployer extends AbstractLifeCycle
Handler[] installed=_contexts.getChildHandlersByClass(ContextHandler.class);
for (int i=0; i<installed.length; i++)
{
ContextHandler c=(ContextHandler)installed[i];
ContextHandler c = (ContextHandler)installed[i];
if (context.equals(c.getContextPath()))
continue files;
try
{
String path=null;
if (c instanceof WebAppContext)
path = Resource.newResource(((WebAppContext)c).getWar()).getFile().getAbsolutePath();
else if (c.getBaseResource()!=null)
path = c.getBaseResource().getFile().getAbsolutePath();
if (path!=null && path.equals(app.getFile().getAbsolutePath()))
continue files;
}
catch (Exception e)
{
Log.ignore(e);
}
try
{
String path = null;
if (c instanceof WebAppContext)
path = Resource.newResource(((WebAppContext)c).getWar()).getFile().getCanonicalPath();
else if (c.getBaseResource() != null)
path = c.getBaseResource().getFile().getCanonicalPath();
if (path != null && path.equals(app.getFile().getCanonicalPath()))
{
Log.debug("Already deployed:"+path);
continue files;
}
}
catch (Exception e)
{
Log.ignore(e);
}
}
}

View File

@ -264,11 +264,12 @@ public class ObjectMBean implements DynamicMBean
if (!defined.contains(key))
{
defined.add(key);
attributes=LazyList.add(attributes,defineAttribute(key, value));
MBeanAttributeInfo info=defineAttribute(key, value);
if (info!=null)
attributes=LazyList.add(attributes,info);
}
}
}
}
catch(MissingResourceException e)
{
@ -555,10 +556,16 @@ public class ObjectMBean implements DynamicMBean
if (methods[m].getName().equals("get" + uName) && methods[m].getParameterTypes().length == 0)
{
if (getter != null)
throw new IllegalArgumentException("Multiple getters for attr " + name+ " in "+oClass);
{
Log.warn("Multiple mbean getters for attr " + name+ " in "+oClass);
continue;
}
getter = methods[m];
if (type != null && !type.equals(methods[m].getReturnType()))
throw new IllegalArgumentException("Type conflict for attr " + name+ " in "+oClass);
{
Log.warn("Type conflict for mbean attr " + name+ " in "+oClass);
continue;
}
type = methods[m].getReturnType();
}
@ -566,10 +573,16 @@ public class ObjectMBean implements DynamicMBean
if (methods[m].getName().equals("is" + uName) && methods[m].getParameterTypes().length == 0)
{
if (getter != null)
throw new IllegalArgumentException("Multiple getters for attr " + name+ " in "+oClass);
{
Log.warn("Multiple mbean getters for attr " + name+ " in "+oClass);
continue;
}
getter = methods[m];
if (type != null && !type.equals(methods[m].getReturnType()))
throw new IllegalArgumentException("Type conflict for attr " + name+ " in "+oClass);
{
Log.warn("Type conflict for mbean attr " + name+ " in "+oClass);
continue;
}
type = methods[m].getReturnType();
}
@ -577,10 +590,16 @@ public class ObjectMBean implements DynamicMBean
if (writable && methods[m].getName().equals("set" + uName) && methods[m].getParameterTypes().length == 1)
{
if (setter != null)
throw new IllegalArgumentException("Multiple setters for attr " + name+ " in "+oClass);
{
Log.warn("Multiple setters for mbean attr " + name+ " in "+oClass);
continue;
}
setter = methods[m];
if (type != null && !type.equals(methods[m].getParameterTypes()[0]))
throw new IllegalArgumentException("Type conflict for attr " + name+ " in "+oClass);
{
Log.warn("Type conflict for mbean attr " + name+ " in "+oClass);
continue;
}
type = methods[m].getParameterTypes()[0];
}
}
@ -588,14 +607,23 @@ public class ObjectMBean implements DynamicMBean
if (convert)
{
if (type==null)
throw new IllegalArgumentException("No type for " + name+" on "+_managed.getClass());
{
Log.warn("No mbean type for " + name+" on "+_managed.getClass());
return null;
}
if (type.isPrimitive() && !type.isArray())
throw new IllegalArgumentException("Cannot convert primative " + name);
{
Log.warn("Cannot convert mbean primative " + name);
return null;
}
}
if (getter == null && setter == null)
throw new IllegalArgumentException("No getter or setters found for " + name+ " in "+oClass);
{
Log.warn("No mbean getter or setters found for " + name+ " in "+oClass);
return null;
}
try
{
@ -603,8 +631,6 @@ public class ObjectMBean implements DynamicMBean
_getters.put(name, getter);
_setters.put(name, setter);
MBeanAttributeInfo info=null;
if (convert)
{

View File

@ -1,2 +1,3 @@
Logger: Jetty Logging implementaton
debugEnabled: True if debug enabled
name: Logger name

View File

@ -5,3 +5,10 @@ name: Name of the thread pool
daemon: Is pool thread using daemon thread
threadsPriority: The priority of threads in the pool
maxIdleTimeMs: Maximum time a thread may be idle in ms
dump(): Dump thread state
stopThread(long): Stop a pool thread
stopThread(long)[0]: id:Thread ID
interruptThread(long): Interrupt a pool thread
interruptThread(long)[0]: id:Thread ID
dumpThread(long): Dump a pool thread stack
dumpThread(long)[0]: id:Thread ID

View File

@ -71,7 +71,7 @@ import org.eclipse.jetty.util.resource.Resource;
* servlet path, plus setting the context classloader.
*
* <p>
* If the context init parameter "org.eclipse.jetty.servlet.ManagedAttributes"
* If the context init parameter "org.eclipse.jetty.server.context.ManagedAttributes"
* is set to a coma separated list of names, then they are treated as context
* attribute names, which if set as attributes are passed to the servers Container
* so that they may be managed with JMX.
@ -84,7 +84,7 @@ import org.eclipse.jetty.util.resource.Resource;
public class ContextHandler extends ScopedHandler implements Attributes, Server.Graceful, CompleteHandler
{
private static final ThreadLocal<Context> __context=new ThreadLocal<Context>();
public static final String MANAGED_ATTRIBUTES = "org.eclipse.jetty.server.servlet.ManagedAttributes";
public static final String MANAGED_ATTRIBUTES = "org.eclipse.jetty.server.context.ManagedAttributes";
/* ------------------------------------------------------------ */
/** Get the current ServletContext implementation.
@ -124,7 +124,7 @@ public class ContextHandler extends ScopedHandler implements Attributes, Server.
private Object _contextAttributeListeners;
private Object _requestListeners;
private Object _requestAttributeListeners;
private Set<String> _managedAttributes;
private Map<String,Object> _managedAttributes;
private boolean _shutdown=false;
private boolean _available=true;
@ -612,6 +612,23 @@ public class ContextHandler extends ScopedHandler implements Attributes, Server.
protected void startContext()
throws Exception
{
String managedAttributes = _initParams.get(MANAGED_ATTRIBUTES);
if (managedAttributes!=null)
{
_managedAttributes=new HashMap<String,Object>();
String[] attributes = managedAttributes.split(",");
for (String attribute : attributes)
_managedAttributes.put(attribute,null);
Enumeration e = _scontext.getAttributeNames();
while(e.hasMoreElements())
{
String name = (String)e.nextElement();
Object value = _scontext.getAttribute(name);
setManagedAttribute(name,value);
}
}
super.doStart();
if (_errorHandler!=null)
@ -627,21 +644,6 @@ public class ContextHandler extends ScopedHandler implements Attributes, Server.
}
}
String managedAttributes = _initParams.get(MANAGED_ATTRIBUTES);
if (managedAttributes!=null)
{
_managedAttributes=new HashSet<String>();
String[] attributes = managedAttributes.split(",");
_managedAttributes.addAll(Arrays.asList(attributes));
Enumeration e = _scontext.getAttributeNames();
while(e.hasMoreElements())
{
String name = (String)e.nextElement();
Object value = _scontext.getAttribute(name);
setManagedAttribute(name,value);
}
}
}
/* ------------------------------------------------------------ */
@ -1064,13 +1066,16 @@ public class ContextHandler extends ScopedHandler implements Attributes, Server.
/* ------------------------------------------------------------ */
private void setManagedAttribute(String name, Object value)
{
if (_managedAttributes!=null && _managedAttributes.contains(name))
if (_managedAttributes!=null && _managedAttributes.containsKey(name))
{
Object o =_scontext.getAttribute(name);
if (o!=null)
getServer().getContainer().removeBean(o);
Object old =_managedAttributes.put(name,value);
if (old!=null)
getServer().getContainer().removeBean(old);
if (value!=null)
{
_logger.info("Managing "+name);
getServer().getContainer().addBean(value);
}
}
}

View File

@ -47,6 +47,7 @@ import org.eclipse.jetty.util.IO;
import org.eclipse.jetty.util.TypeUtil;
import org.eclipse.jetty.util.log.Log;
import org.eclipse.jetty.util.log.Logger;
import org.eclipse.jetty.util.thread.QueuedThreadPool;
/**
@ -54,15 +55,24 @@ import org.eclipse.jetty.util.log.Logger;
*
* Forward requests to another server either as a standard web proxy (as defined by
* RFC2616) or as a transparent proxy.
*
* <p>
* This servlet needs the jetty-util and jetty-client classes to be available to
* the web application.
*
* This servlet has a a logger called "org.eclipse.jetty.servlets.ProxyServlet".
* <p>
* To facilitate JMX monitoring, the "HttpClient", it's "ThreadPool" and the "Logger"
* are set as context attributes prefixed with "org.eclipse.jetty.servlets."+name
* (unless otherwise set with attrPrefix). This attribute prefix is also used for the
* logger name.
* <p>
* The following init parameters may be used to configure the servlet: <ul>
* <li>name - Name of Proxy servlet (default: "ProxyServlet"
* <li>maxThreads - maximum threads
* <li>maxConnections - maximum connections per destination
* </ul>
*/
public class ProxyServlet implements Servlet
{
private static Logger __log = Log.getLogger("org.eclipse.jetty.servlets.ProxyServlet");
protected Logger _log;
HttpClient _client;
@ -79,23 +89,44 @@ public class ProxyServlet implements Servlet
_DontProxyHeaders.add("upgrade");
}
private ServletConfig config;
private ServletContext context;
protected ServletConfig _config;
protected ServletContext _context;
protected String _name="ProxyServlet";
/* (non-Javadoc)
* @see javax.servlet.Servlet#init(javax.servlet.ServletConfig)
*/
public void init(ServletConfig config) throws ServletException
{
this.config=config;
this.context=config.getServletContext();
_config=config;
_context=config.getServletContext();
_client=new HttpClient();
//_client.setConnectorType(HttpClient.CONNECTOR_SOCKET);
_client.setConnectorType(HttpClient.CONNECTOR_SELECT_CHANNEL);
try
{
String t = config.getInitParameter("attrPrefix");
if (t!=null)
_name=t;
_log= Log.getLogger("org.eclipse.jetty.servlets."+_name);
t = config.getInitParameter("maxThreads");
if (t!=null)
_client.setThreadPool(new QueuedThreadPool(Integer.parseInt(t)));
else
_client.setThreadPool(new QueuedThreadPool());
((QueuedThreadPool)_client.getThreadPool()).setName(_name.substring(_name.lastIndexOf('.')+1));
t = config.getInitParameter("maxConnections");
if (t!=null)
_client.setMaxConnectionsPerAddress(Integer.parseInt(t));
_client.start();
_context.setAttribute("org.eclipse.jetty.servlets."+_name+".Logger",_log);
_context.setAttribute("org.eclipse.jetty.servlets."+_name+".ThreadPool",_client.getThreadPool());
_context.setAttribute("org.eclipse.jetty.servlets."+_name+".HttpClient",_client);
}
catch (Exception e)
{
@ -108,7 +139,7 @@ public class ProxyServlet implements Servlet
*/
public ServletConfig getServletConfig()
{
return config;
return _config;
}
/* (non-Javadoc)
@ -117,7 +148,7 @@ public class ProxyServlet implements Servlet
public void service(ServletRequest req, ServletResponse res) throws ServletException,
IOException
{
final int debug=__log.isDebugEnabled()?req.hashCode():0;
final int debug=_log.isDebugEnabled()?req.hashCode():0;
final HttpServletRequest request = (HttpServletRequest)req;
final HttpServletResponse response = (HttpServletResponse)res;
@ -146,7 +177,7 @@ public class ProxyServlet implements Servlet
uri);
if (debug!=0)
__log.debug(debug+" proxy "+uri+"-->"+url);
_log.debug(debug+" proxy "+uri+"-->"+url);
if (url==null)
{
@ -167,14 +198,14 @@ public class ProxyServlet implements Servlet
protected void onResponseComplete() throws IOException
{
if (debug!=0)
__log.debug(debug+" complete");
_log.debug(debug+" complete");
continuation.complete();
}
protected void onResponseContent(Buffer content) throws IOException
{
if (debug!=0)
__log.debug(debug+" content"+content.length());
_log.debug(debug+" content"+content.length());
content.writeTo(out);
}
@ -185,7 +216,7 @@ public class ProxyServlet implements Servlet
protected void onResponseStatus(Buffer version, int status, Buffer reason) throws IOException
{
if (debug!=0)
__log.debug(debug+" "+version+" "+status+" "+reason);
_log.debug(debug+" "+version+" "+status+" "+reason);
if (reason!=null && reason.length()>0)
response.setStatus(status,reason.toString());
@ -201,12 +232,12 @@ public class ProxyServlet implements Servlet
HttpHeaderValues.CLOSE_BUFFER.equals(value)))
{
if (debug!=0)
__log.debug(debug+" "+name+": "+value);
_log.debug(debug+" "+name+": "+value);
response.addHeader(name.toString(),value.toString());
}
else if (debug!=0)
__log.debug(debug+" "+name+"! "+value);
_log.debug(debug+" "+name+"! "+value);
}
protected void onConnectionFailed(Throwable ex)
@ -243,7 +274,7 @@ public class ProxyServlet implements Servlet
exchange.setVersion(request.getProtocol());
if (debug!=0)
__log.debug(debug+" "+request.getMethod()+" "+url+" "+request.getProtocol());
_log.debug(debug+" "+request.getMethod()+" "+url+" "+request.getProtocol());
// check connection header
String connectionHdr = request.getHeader("Connection");
@ -290,7 +321,7 @@ public class ProxyServlet implements Servlet
if (val!=null)
{
if (debug!=0)
__log.debug(debug+" "+hdr+": "+val);
_log.debug(debug+" "+hdr+": "+val);
exchange.setRequestHeader(hdr,val);
}
@ -386,7 +417,7 @@ public class ProxyServlet implements Servlet
/**
* Transparent Proxy.
*
* This convenience extension to AsyncProxyServlet configures the servlet
* This convenience extension to ProxyServlet configures the servlet
* as a transparent proxy. The servlet is configured with init parameter:<ul>
* <li> ProxyTo - a URI like http://host:80/context to which the request is proxied.
* <li> Prefix - a URI prefix that is striped from the start of the forwarded URI.
@ -410,6 +441,7 @@ public class ProxyServlet implements Servlet
_proxyTo="http://"+server+":"+port;
}
@Override
public void init(ServletConfig config) throws ServletException
{
if (config.getInitParameter("ProxyTo")!=null)
@ -419,9 +451,10 @@ public class ProxyServlet implements Servlet
if (_proxyTo==null)
throw new UnavailableException("No ProxyTo");
super.init(config);
config.getServletContext().log("Transparent AsyncProxyServlet @ "+(_prefix==null?"-":_prefix)+ " to "+_proxyTo);
_log.info(_name+" @ "+(_prefix==null?"-":_prefix)+ " to "+_proxyTo);
}
@Override
protected HttpURI proxyHttpURI(final String scheme, final String serverName, int serverPort, final String uri) throws MalformedURLException
{
if (_prefix!=null && !uri.startsWith(_prefix))

View File

@ -35,7 +35,7 @@ import java.util.logging.Level;
*/
public class JavaUtilLog implements Logger
{
private java.util.logging.Logger logger;
private java.util.logging.Logger _logger;
public JavaUtilLog()
{
@ -44,26 +44,31 @@ public class JavaUtilLog implements Logger
public JavaUtilLog(String name)
{
logger = java.util.logging.Logger.getLogger(name);
_logger = java.util.logging.Logger.getLogger(name);
if (Boolean.getBoolean("org.eclipse.jetty.util.log.DEBUG"))
{
logger.setLevel(Level.FINE);
_logger.setLevel(Level.FINE);
}
}
public String getName()
{
return _logger.getName();
}
public void debug(String msg)
{
logger.log(Level.FINE,msg);
_logger.log(Level.FINE,msg);
}
public void debug(String msg, Throwable th)
{
logger.log(Level.FINE,msg,th);
_logger.log(Level.FINE,msg,th);
}
public void debug(String msg, Object arg0, Object arg1)
{
logger.log(Level.FINE,format(msg,arg0,arg1));
_logger.log(Level.FINE,format(msg,arg0,arg1));
}
public Logger getLogger(String name)
@ -73,37 +78,37 @@ public class JavaUtilLog implements Logger
public void info(String msg)
{
logger.log(Level.INFO,msg);
_logger.log(Level.INFO,msg);
}
public void info(String msg, Object arg0, Object arg1)
{
logger.log(Level.INFO,format(msg,arg0,arg1));
_logger.log(Level.INFO,format(msg,arg0,arg1));
}
public boolean isDebugEnabled()
{
return logger.isLoggable(Level.FINE);
return _logger.isLoggable(Level.FINE);
}
public void setDebugEnabled(boolean enabled)
{
logger.setLevel(Level.FINE);
_logger.setLevel(Level.FINE);
}
public void warn(String msg)
{
logger.log(Level.WARNING,msg);
_logger.log(Level.WARNING,msg);
}
public void warn(String msg, Object arg0, Object arg1)
{
logger.log(Level.WARNING,format(msg,arg0,arg1));
_logger.log(Level.WARNING,format(msg,arg0,arg1));
}
public void warn(String msg, Throwable th)
{
logger.log(Level.WARNING,msg,th);
_logger.log(Level.WARNING,msg,th);
}
private String format(String msg, Object arg0, Object arg1)

View File

@ -37,4 +37,6 @@ public interface Logger
public void warn(String msg,Object arg0, Object arg1);
public void warn(String msg, Throwable th);
public Logger getLogger(String name);
public String getName();
}

View File

@ -51,6 +51,12 @@ public class LoggerLog implements Logger
throw new IllegalStateException(e);
}
}
public String getName()
{
return _logger.toString();
}
public void debug(String msg, Throwable th)
{

View File

@ -20,7 +20,7 @@ package org.eclipse.jetty.util.log;
*/
public class Slf4jLog implements Logger
{
private org.slf4j.Logger logger;
private org.slf4j.Logger _logger;
public Slf4jLog() throws Exception
@ -30,16 +30,20 @@ public class Slf4jLog implements Logger
public Slf4jLog(String name)
{
logger = org.slf4j.LoggerFactory.getLogger( name );
_logger = org.slf4j.LoggerFactory.getLogger( name );
}
public String getName()
{
return _logger.getName();
}
/* ------------------------------------------------------------ */
/*
* @see org.eclipse.log.Log#doDebug(java.lang.String)
*/
public void debug(String msg)
{
logger.debug(msg);
_logger.debug(msg);
}
/* ------------------------------------------------------------ */
@ -48,7 +52,7 @@ public class Slf4jLog implements Logger
*/
public void debug(String msg, Object arg0, Object arg1)
{
logger.debug(msg, arg0, arg1);
_logger.debug(msg, arg0, arg1);
}
/* ------------------------------------------------------------ */
@ -57,7 +61,7 @@ public class Slf4jLog implements Logger
*/
public void debug(String msg, Throwable th)
{
logger.debug(msg, th);
_logger.debug(msg, th);
}
/* ------------------------------------------------------------ */
@ -66,7 +70,7 @@ public class Slf4jLog implements Logger
*/
public boolean isDebugEnabled()
{
return logger.isDebugEnabled();
return _logger.isDebugEnabled();
}
@ -76,7 +80,7 @@ public class Slf4jLog implements Logger
*/
public void info(String msg)
{
logger.info(msg);
_logger.info(msg);
}
/* ------------------------------------------------------------ */
@ -85,7 +89,7 @@ public class Slf4jLog implements Logger
*/
public void info(String msg, Object arg0, Object arg1)
{
logger.info(msg, arg0, arg1);
_logger.info(msg, arg0, arg1);
}
@ -95,7 +99,7 @@ public class Slf4jLog implements Logger
*/
public void warn(String msg)
{
logger.warn(msg);
_logger.warn(msg);
}
/* ------------------------------------------------------------ */
@ -104,7 +108,7 @@ public class Slf4jLog implements Logger
*/
public void warn(String msg, Object arg0, Object arg1)
{
logger.warn(msg, arg0, arg1);
_logger.warn(msg, arg0, arg1);
}
/* ------------------------------------------------------------ */
@ -115,9 +119,9 @@ public class Slf4jLog implements Logger
{
if (th instanceof RuntimeException || th instanceof Error)
logger.error(msg, th);
_logger.error(msg, th);
else
logger.warn(msg,th);
_logger.warn(msg,th);
}
@ -131,7 +135,7 @@ public class Slf4jLog implements Logger
/* ------------------------------------------------------------ */
public String toString()
{
return logger.toString();
return _logger.toString();
}
/* ------------------------------------------------------------ */

View File

@ -59,6 +59,11 @@ public class StdErrLog implements Logger
_debug=Boolean.parseBoolean(System.getProperty(name+".DEBUG",Boolean.toString(__debug)));
}
public String getName()
{
return _name;
}
public boolean isDebugEnabled()
{
return _debug;
@ -83,14 +88,14 @@ public class StdErrLog implements Logger
{
String d=_dateCache.now();
int ms=_dateCache.lastMs();
System.err.println(d+(ms>99?".":(ms>0?".0":".00"))+ms+":"+_name+":INFO: "+msg);
System.err.println(d+(ms>99?".":(ms>0?".0":".00"))+ms+":INFO:"+_name+":"+msg);
}
public void info(String msg,Object arg0, Object arg1)
{
String d=_dateCache.now();
int ms=_dateCache.lastMs();
System.err.println(d+(ms>99?".":(ms>0?".0":".00"))+ms+":"+_name+":INFO: "+format(msg,arg0,arg1));
System.err.println(d+(ms>99?".":(ms>0?".0":".00"))+ms+":INFO:"+_name+":"+format(msg,arg0,arg1));
}
public void debug(String msg,Throwable th)
@ -99,7 +104,7 @@ public class StdErrLog implements Logger
{
String d=_dateCache.now();
int ms=_dateCache.lastMs();
System.err.println(d+(ms>99?".":(ms>0?".0":".00"))+ms+":"+_name+":DEBUG: "+msg);
System.err.println(d+(ms>99?".":(ms>0?".0":".00"))+ms+":DBUG:"+_name+":"+msg);
if (th!=null)
{
if (_hideStacks)
@ -116,7 +121,7 @@ public class StdErrLog implements Logger
{
String d=_dateCache.now();
int ms=_dateCache.lastMs();
System.err.println(d+(ms>99?".":(ms>0?".0":".00"))+ms+":"+_name+":DEBUG: "+msg);
System.err.println(d+(ms>99?".":(ms>0?".0":".00"))+ms+":DBUG:"+_name+":"+msg);
}
}
@ -126,7 +131,7 @@ public class StdErrLog implements Logger
{
String d=_dateCache.now();
int ms=_dateCache.lastMs();
System.err.println(d+(ms>99?".":(ms>0?".0":".00"))+ms+":"+_name+":DEBUG: "+format(msg,arg0,arg1));
System.err.println(d+(ms>99?".":(ms>0?".0":".00"))+ms+":DBUG:"+_name+":"+format(msg,arg0,arg1));
}
}
@ -134,21 +139,21 @@ public class StdErrLog implements Logger
{
String d=_dateCache.now();
int ms=_dateCache.lastMs();
System.err.println(d+(ms>99?".":(ms>0?".0":".00"))+ms+":"+_name+":WARN: "+msg);
System.err.println(d+(ms>99?".":(ms>0?".0":".00"))+ms+":WARN:"+_name+":"+msg);
}
public void warn(String msg,Object arg0, Object arg1)
{
String d=_dateCache.now();
int ms=_dateCache.lastMs();
System.err.println(d+(ms>99?".":(ms>0?".0":".00"))+ms+":"+_name+":WARN: "+format(msg,arg0,arg1));
System.err.println(d+(ms>99?".":(ms>0?".0":".00"))+ms+":WARN:"+_name+":"+format(msg,arg0,arg1));
}
public void warn(String msg, Throwable th)
{
String d=_dateCache.now();
int ms=_dateCache.lastMs();
System.err.println(d+(ms>99?".":(ms>0?".0":".00"))+ms+":"+_name+":WARN: "+msg);
System.err.println(d+(ms>99?".":(ms>0?".0":".00"))+ms+":WARN:"+_name+":"+msg);
if (th!=null)
{
if (_hideStacks)

View File

@ -491,4 +491,77 @@ public class QueuedThreadPool extends AbstractLifeCycle implements ThreadPool, E
}
}
};
public String dump()
{
StringBuilder buf = new StringBuilder();
for (Thread thread: _threads)
{
buf.append(thread.getId()).append(" ").append(thread.getName()).append(" ").append(thread.getState()).append(":\n");
for (StackTraceElement element : thread.getStackTrace())
buf.append(" at ").append(element.toString()).append('\n');
}
return buf.toString();
}
/* ------------------------------------------------------------ */
/**
* @param id The thread ID to stop.
* @return true if the thread was found and stopped.
* @Deprecated Use {@link #interruptThread(long)} in preference
*/
@SuppressWarnings("deprecation")
public boolean stopThread(long id)
{
for (Thread thread: _threads)
{
if (thread.getId()==id)
{
thread.stop();
return true;
}
}
return false;
}
/* ------------------------------------------------------------ */
/**
* @param id The thread ID to interrupt.
* @return true if the thread was found and interrupted.
*/
public boolean interruptThread(long id)
{
for (Thread thread: _threads)
{
if (thread.getId()==id)
{
thread.interrupt();
return true;
}
}
return false;
}
/* ------------------------------------------------------------ */
/**
* @param id The thread ID to interrupt.
* @return true if the thread was found and interrupted.
*/
public String dumpThread(long id)
{
for (Thread thread: _threads)
{
if (thread.getId()==id)
{
StringBuilder buf = new StringBuilder();
buf.append(thread.getId()).append(" ").append(thread.getName()).append(" ").append(thread.getState()).append(":\n");
for (StackTraceElement element : thread.getStackTrace())
buf.append(" at ").append(element.toString()).append('\n');
return buf.toString();
}
}
return null;
}
}

View File

@ -7,6 +7,11 @@
<display-name>Test WebApp</display-name>
<context-param>
<param-name>org.eclipse.jetty.server.context.ManagedAttributes</param-name>
<param-value>org.eclipse.jetty.servlets.ProxyServlet.Logger,org.eclipse.jetty.servlets.ProxyServlet.ThreadPool,org.eclipse.jetty.servlets.ProxyServlet.HttpClient</param-value>
</context-param>
<!-- Declare TestListener, which declares TestFilter -->
<listener>
<listener-class>com.acme.TestListener</listener-class>