jetty-9 - HTTP client: implemented dumping.

This commit is contained in:
Simone Bordet 2012-09-14 18:15:31 +02:00
parent ae9b32ba57
commit 8330586c4e
2 changed files with 34 additions and 2 deletions

View File

@ -125,7 +125,6 @@ public class HttpClient extends AggregateLifeCycle
public HttpClient(SslContextFactory sslContextFactory)
{
this.sslContextFactory = sslContextFactory;
addBean(sslContextFactory);
}
public SslContextFactory getSslContextFactory()
@ -136,6 +135,9 @@ public class HttpClient extends AggregateLifeCycle
@Override
protected void doStart() throws Exception
{
if (sslContextFactory != null)
addBean(sslContextFactory);
if (executor == null)
executor = new QueuedThreadPool();
addBean(executor);
@ -483,6 +485,13 @@ public class HttpClient extends AggregateLifeCycle
this.maxRedirects = maxRedirects;
}
@Override
public void dump(Appendable out, String indent) throws IOException
{
dumpThis(out);
dump(out, indent, getBeans(), destinations.values());
}
protected class ClientSelectorManager extends SelectorManager
{
public ClientSelectorManager()

View File

@ -18,7 +18,10 @@
package org.eclipse.jetty.client;
import java.io.IOException;
import java.nio.channels.AsynchronousCloseException;
import java.util.ArrayList;
import java.util.List;
import java.util.Queue;
import java.util.concurrent.ArrayBlockingQueue;
import java.util.concurrent.BlockingQueue;
@ -33,10 +36,12 @@ import org.eclipse.jetty.client.api.Response;
import org.eclipse.jetty.client.api.Result;
import org.eclipse.jetty.util.Callback;
import org.eclipse.jetty.util.FutureCallback;
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.log.Logger;
public class HttpDestination implements Destination, AutoCloseable
public class HttpDestination implements Destination, AutoCloseable, Dumpable
{
private static final Logger LOG = Log.getLogger(HttpDestination.class);
@ -301,6 +306,24 @@ public class HttpDestination implements Destination, AutoCloseable
LOG.debug("Closed {}", this);
}
@Override
public String dump()
{
return AggregateLifeCycle.dump(this);
}
@Override
public void dump(Appendable out, String indent) throws IOException
{
AggregateLifeCycle.dumpObject(out, this + " - requests queued: " + requests.size());
List<String> connections = new ArrayList<>();
for (Connection connection : idleConnections)
connections.add(connection + " - IDLE");
for (Connection connection : activeConnections)
connections.add(connection + " - ACTIVE");
AggregateLifeCycle.dump(out, indent, connections);
}
@Override
public String toString()
{