made HttpClient dumpable

git-svn-id: svn+ssh://dev.eclipse.org/svnroot/rt/org.eclipse.jetty/jetty/trunk@3236 7e9141cc-0065-0410-87d8-b60c137991c4
This commit is contained in:
Greg Wilkins 2011-05-23 01:21:52 +00:00
parent 8425cf6b5d
commit b2f5416fcd
5 changed files with 78 additions and 52 deletions

View File

@ -33,6 +33,9 @@ import org.eclipse.jetty.http.ssl.SslContextFactory;
import org.eclipse.jetty.io.Buffers.Type;
import org.eclipse.jetty.util.Attributes;
import org.eclipse.jetty.util.AttributesMap;
import org.eclipse.jetty.util.TypeUtil;
import org.eclipse.jetty.util.component.AggregateLifeCycle;
import org.eclipse.jetty.util.component.Dumpable;
import org.eclipse.jetty.util.component.LifeCycle;
import org.eclipse.jetty.util.log.Log;
import org.eclipse.jetty.util.thread.QueuedThreadPool;
@ -64,7 +67,7 @@ import org.eclipse.jetty.util.thread.Timeout;
* @see HttpExchange
* @see HttpDestination
*/
public class HttpClient extends HttpBuffers implements Attributes
public class HttpClient extends HttpBuffers implements Attributes, Dumpable
{
public static final int CONNECTOR_SOCKET = 0;
public static final int CONNECTOR_SELECT_CHANNEL = 2;
@ -147,21 +150,23 @@ public class HttpClient extends HttpBuffers implements Attributes
_connectBlocking = connectBlocking;
}
/* ------------------------------------------------------------------------------- */
public void dump()
/* ------------------------------------------------------------ */
/**
* @see org.eclipse.jetty.util.component.Dumpable#dump()
*/
public String dump()
{
try
{
for (Map.Entry<Address, HttpDestination> entry : _destinations.entrySet())
{
Log.info("\n" + entry.getKey() + ":");
entry.getValue().dump();
}
}
catch(Exception e)
{
Log.warn(e);
}
return AggregateLifeCycle.dump(this);
}
/* ------------------------------------------------------------ */
/**
* @see org.eclipse.jetty.util.component.Dumpable#dump(java.lang.Appendable, java.lang.String)
*/
public void dump(Appendable out, String indent) throws IOException
{
out.append(String.valueOf(this)).append("\n");
AggregateLifeCycle.dump(out,indent,_destinations.values());
}
/* ------------------------------------------------------------------------------- */

View File

@ -17,6 +17,7 @@ import java.io.EOFException;
import java.io.IOException;
import java.io.InputStream;
import java.io.InterruptedIOException;
import java.util.Collections;
import java.util.concurrent.atomic.AtomicBoolean;
import org.eclipse.jetty.client.security.Authentication;
@ -38,6 +39,8 @@ import org.eclipse.jetty.io.Connection;
import org.eclipse.jetty.io.EndPoint;
import org.eclipse.jetty.io.View;
import org.eclipse.jetty.io.nio.SslSelectChannelEndPoint;
import org.eclipse.jetty.util.component.AggregateLifeCycle;
import org.eclipse.jetty.util.component.Dumpable;
import org.eclipse.jetty.util.log.Log;
import org.eclipse.jetty.util.thread.Timeout;
@ -45,7 +48,7 @@ import org.eclipse.jetty.util.thread.Timeout;
*
* @version $Revision: 879 $ $Date: 2009-09-11 16:13:28 +0200 (Fri, 11 Sep 2009) $
*/
public class HttpConnection extends AbstractConnection
public class HttpConnection extends AbstractConnection implements Dumpable
{
private HttpDestination _destination;
private HttpGenerator _generator;
@ -63,16 +66,6 @@ public class HttpConnection extends AbstractConnection
private final Timeout.Task _idleTimeout = new ConnectionIdleTask();
private AtomicBoolean _idle = new AtomicBoolean(false);
public void dump() throws IOException
{
// TODO update to dumpable
Log.info("endp=" + _endp + " " + _endp.isBufferingInput() + " " + _endp.isBufferingOutput());
Log.info("generator=" + _generator);
Log.info("parser=" + _parser.getState() + " " + _parser.isMoreInBuffer());
Log.info("exchange=" + _exchange);
if (_endp instanceof SslSelectChannelEndPoint)
((SslSelectChannelEndPoint)_endp).dump();
}
HttpConnection(Buffers requestBuffers, Buffers responseBuffers, EndPoint endp)
{
@ -706,7 +699,29 @@ public class HttpConnection extends AbstractConnection
}
}
}
/* ------------------------------------------------------------ */
/**
* @see org.eclipse.jetty.util.component.Dumpable#dump()
*/
public String dump()
{
return AggregateLifeCycle.dump(this);
}
/* ------------------------------------------------------------ */
/**
* @see org.eclipse.jetty.util.component.Dumpable#dump(java.lang.Appendable, java.lang.String)
*/
public void dump(Appendable out, String indent) throws IOException
{
synchronized (this)
{
out.append(String.valueOf(this)).append("\n");
AggregateLifeCycle.dump(out,indent,Collections.singletonList(_endp));
}
}
private class ConnectionIdleTask extends Timeout.Task
{
@Override

View File

@ -35,12 +35,14 @@ import org.eclipse.jetty.io.Buffer;
import org.eclipse.jetty.io.ByteArrayBuffer;
import org.eclipse.jetty.io.Connection;
import org.eclipse.jetty.io.EndPoint;
import org.eclipse.jetty.util.component.AggregateLifeCycle;
import org.eclipse.jetty.util.component.Dumpable;
import org.eclipse.jetty.util.log.Log;
/**
* @version $Revision: 879 $ $Date: 2009-09-11 16:13:28 +0200 (Fri, 11 Sep 2009) $
*/
public class HttpDestination
public class HttpDestination implements Dumpable
{
private final List<HttpExchange> _queue = new LinkedList<HttpExchange>();
private final List<HttpConnection> _connections = new LinkedList<HttpConnection>();
@ -59,22 +61,8 @@ public class HttpDestination
private PathMap _authorizations;
private List<HttpCookie> _cookies;
public void dump() throws IOException
{
synchronized (this)
{
Log.info(this.toString());
Log.info("connections=" + _connections.size());
Log.info("idle=" + _idle.size());
Log.info("pending=" + _pendingConnections);
for (HttpConnection c : _connections)
{
if (!c.isIdle())
c.dump();
}
}
}
HttpDestination(HttpClient client, Address address, boolean ssl)
{
_client = client;
@ -653,6 +641,28 @@ public class HttpDestination
}
}
/* ------------------------------------------------------------ */
/**
* @see org.eclipse.jetty.util.component.Dumpable#dump()
*/
public String dump()
{
return AggregateLifeCycle.dump(this);
}
/* ------------------------------------------------------------ */
/**
* @see org.eclipse.jetty.util.component.Dumpable#dump(java.lang.Appendable, java.lang.String)
*/
public void dump(Appendable out, String indent) throws IOException
{
synchronized (this)
{
out.append(String.valueOf(this)+"idle="+_idle.size()+" pending="+_pendingConnections).append("\n");
AggregateLifeCycle.dump(out,indent,_connections);
}
}
private class ConnectExchange extends ContentExchange
{
private final SelectConnector.ProxySelectChannelEndPoint proxyEndPoint;

View File

@ -165,13 +165,6 @@ public class SslSelectChannelEndPoint extends SelectChannelEndPoint
_allowRenegotiate = allowRenegotiate;
}
/* ------------------------------------------------------------ */
// TODO get rid of these dumps
public void dump()
{
Log.info(""+_result);
}
/* ------------------------------------------------------------ */
@Override
@ -195,6 +188,7 @@ public class SslSelectChannelEndPoint extends SelectChannelEndPoint
super.shutdownOutput();
}
/* ------------------------------------------------------------ */
protected void sslClose() throws IOException
{
if (_closing)

View File

@ -259,7 +259,7 @@ public class ServletHandler extends ScopedHandler
*/
public RequestDispatcher getRequestDispatcher(String uriInContext)
{
if (uriInContext == null)
if (uriInContext == null || _contextHandler==null)
return null;
if (!uriInContext.startsWith("/"))
@ -1464,13 +1464,15 @@ public class ServletHandler extends ScopedHandler
/* ------------------------------------------------------------ */
void destroyServlet(Servlet servlet)
{
_contextHandler.destroyServlet(servlet);
if (_contextHandler!=null)
_contextHandler.destroyServlet(servlet);
}
/* ------------------------------------------------------------ */
void destroyFilter(Filter filter)
{
_contextHandler.destroyFilter(filter);
if (_contextHandler!=null)
_contextHandler.destroyFilter(filter);
}
/* ------------------------------------------------------------ */