diff --git a/jetty-http2/http2-common/src/main/java/org/eclipse/jetty/http2/HTTP2Flusher.java b/jetty-http2/http2-common/src/main/java/org/eclipse/jetty/http2/HTTP2Flusher.java index b18dd2d85b9..c9ae1b9919c 100644 --- a/jetty-http2/http2-common/src/main/java/org/eclipse/jetty/http2/HTTP2Flusher.java +++ b/jetty-http2/http2-common/src/main/java/org/eclipse/jetty/http2/HTTP2Flusher.java @@ -18,6 +18,7 @@ package org.eclipse.jetty.http2; +import java.io.IOException; import java.nio.ByteBuffer; import java.util.ArrayDeque; import java.util.ArrayList; @@ -31,10 +32,12 @@ import org.eclipse.jetty.io.ByteBufferPool; import org.eclipse.jetty.io.EofException; import org.eclipse.jetty.util.Callback; import org.eclipse.jetty.util.IteratingCallback; +import org.eclipse.jetty.util.component.ContainerLifeCycle; +import org.eclipse.jetty.util.component.Dumpable; import org.eclipse.jetty.util.log.Log; import org.eclipse.jetty.util.log.Logger; -public class HTTP2Flusher extends IteratingCallback +public class HTTP2Flusher extends IteratingCallback implements Dumpable { private static final Logger LOG = Log.getLogger(HTTP2Flusher.class); @@ -105,7 +108,15 @@ public class HTTP2Flusher extends IteratingCallback return false; } - public int getQueueSize() + private int getWindowQueueSize() + { + synchronized (this) + { + return windows.size(); + } + } + + private int getFrameQueueSize() { synchronized (this) { @@ -291,6 +302,28 @@ public class HTTP2Flusher extends IteratingCallback entry.failed(failure); } + @Override + public String dump() + { + return ContainerLifeCycle.dump(this); + } + + @Override + public void dump(Appendable out, String indent) throws IOException + { + out.append(toString()).append(System.lineSeparator()); + } + + @Override + public String toString() + { + return String.format("%s[window_queue=%d,frame_queue=%d,actives=%d]", + super.toString(), + getWindowQueueSize(), + getFrameQueueSize(), + actives.size()); + } + public static abstract class Entry extends Callback.Nested { protected final Frame frame; diff --git a/jetty-http2/http2-common/src/main/java/org/eclipse/jetty/http2/HTTP2Session.java b/jetty-http2/http2-common/src/main/java/org/eclipse/jetty/http2/HTTP2Session.java index e9516a487ed..b1eeec41337 100644 --- a/jetty-http2/http2-common/src/main/java/org/eclipse/jetty/http2/HTTP2Session.java +++ b/jetty-http2/http2-common/src/main/java/org/eclipse/jetty/http2/HTTP2Session.java @@ -59,6 +59,7 @@ import org.eclipse.jetty.util.Promise; import org.eclipse.jetty.util.annotation.ManagedAttribute; import org.eclipse.jetty.util.annotation.ManagedObject; import org.eclipse.jetty.util.component.ContainerLifeCycle; +import org.eclipse.jetty.util.component.DumpableCollection; import org.eclipse.jetty.util.log.Log; import org.eclipse.jetty.util.log.Logger; import org.eclipse.jetty.util.thread.Scheduler; @@ -106,13 +107,8 @@ public abstract class HTTP2Session extends ContainerLifeCycle implements ISessio this.recvWindow.set(FlowControlStrategy.DEFAULT_WINDOW_SIZE); this.pushEnabled = true; // SPEC: by default, push is enabled. this.idleTime = System.nanoTime(); - } - - @Override - protected void doStart() throws Exception - { addBean(flowControl); - super.doStart(); + addBean(flusher); } @Override @@ -547,7 +543,6 @@ public abstract class HTTP2Session extends ContainerLifeCycle implements ISessio flusher.iterate(); } - @Override public void settings(SettingsFrame frame, Callback callback) { @@ -1115,15 +1110,21 @@ public abstract class HTTP2Session extends ContainerLifeCycle implements ISessio } } + @Override + public void dump(Appendable out, String indent) throws IOException + { + super.dump(out, indent); + dump(out, indent, Collections.singleton(new DumpableCollection("streams", streams.values()))); + } + @Override public String toString() { - return String.format("%s@%x{l:%s <-> r:%s,queueSize=%d,sendWindow=%s,recvWindow=%s,streams=%d,%s}", + return String.format("%s@%x{l:%s <-> r:%s,sendWindow=%s,recvWindow=%s,streams=%d,%s}", getClass().getSimpleName(), hashCode(), getEndPoint().getLocalAddress(), getEndPoint().getRemoteAddress(), - flusher.getQueueSize(), sendWindow, recvWindow, streams.size(), diff --git a/jetty-http2/http2-common/src/main/java/org/eclipse/jetty/http2/HTTP2Stream.java b/jetty-http2/http2-common/src/main/java/org/eclipse/jetty/http2/HTTP2Stream.java index 7ffdc476d39..bd4b8a0f425 100644 --- a/jetty-http2/http2-common/src/main/java/org/eclipse/jetty/http2/HTTP2Stream.java +++ b/jetty-http2/http2-common/src/main/java/org/eclipse/jetty/http2/HTTP2Stream.java @@ -37,11 +37,13 @@ import org.eclipse.jetty.http2.frames.WindowUpdateFrame; import org.eclipse.jetty.io.IdleTimeout; import org.eclipse.jetty.util.Callback; import org.eclipse.jetty.util.Promise; +import org.eclipse.jetty.util.component.ContainerLifeCycle; +import org.eclipse.jetty.util.component.Dumpable; import org.eclipse.jetty.util.log.Log; import org.eclipse.jetty.util.log.Logger; import org.eclipse.jetty.util.thread.Scheduler; -public class HTTP2Stream extends IdleTimeout implements IStream, Callback +public class HTTP2Stream extends IdleTimeout implements IStream, Callback, Dumpable { private static final Logger LOG = Log.getLogger(HTTP2Stream.class); @@ -446,6 +448,18 @@ public class HTTP2Stream extends IdleTimeout implements IStream, Callback } } + @Override + public String dump() + { + return ContainerLifeCycle.dump(this); + } + + @Override + public void dump(Appendable out, String indent) throws IOException + { + out.append(toString()).append(System.lineSeparator()); + } + @Override public String toString() {