From 8330586c4e59aa8249884cbded2477979748d9aa Mon Sep 17 00:00:00 2001 From: Simone Bordet Date: Fri, 14 Sep 2012 18:15:31 +0200 Subject: [PATCH] jetty-9 - HTTP client: implemented dumping. --- .../org/eclipse/jetty/client/HttpClient.java | 11 +++++++- .../eclipse/jetty/client/HttpDestination.java | 25 ++++++++++++++++++- 2 files changed, 34 insertions(+), 2 deletions(-) diff --git a/jetty-client/src/main/java/org/eclipse/jetty/client/HttpClient.java b/jetty-client/src/main/java/org/eclipse/jetty/client/HttpClient.java index f3fcdb0a85b..2dea4dbf9c2 100644 --- a/jetty-client/src/main/java/org/eclipse/jetty/client/HttpClient.java +++ b/jetty-client/src/main/java/org/eclipse/jetty/client/HttpClient.java @@ -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() diff --git a/jetty-client/src/main/java/org/eclipse/jetty/client/HttpDestination.java b/jetty-client/src/main/java/org/eclipse/jetty/client/HttpDestination.java index 7d965ec580c..c6925fe2a9e 100644 --- a/jetty-client/src/main/java/org/eclipse/jetty/client/HttpDestination.java +++ b/jetty-client/src/main/java/org/eclipse/jetty/client/HttpDestination.java @@ -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 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() {