improved SPDY dump

This commit is contained in:
Greg Wilkins 2012-07-03 15:31:56 +02:00
parent b243d7e419
commit a519ecc1fb
4 changed files with 46 additions and 3 deletions

View File

@ -16,9 +16,11 @@
package org.eclipse.jetty.spdy;
import java.io.IOException;
import java.nio.ByteBuffer;
import java.nio.channels.InterruptedByTimeoutException;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashSet;
import java.util.LinkedList;
import java.util.List;
@ -66,10 +68,13 @@ import org.eclipse.jetty.spdy.frames.WindowUpdateFrame;
import org.eclipse.jetty.spdy.generator.Generator;
import org.eclipse.jetty.spdy.parser.Parser;
import org.eclipse.jetty.util.Atomics;
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.log.Log;
import org.eclipse.jetty.util.log.Logger;
public class StandardSession implements ISession, Parser.Listener, Handler<StandardSession.FrameBytes>
public class StandardSession implements ISession, Parser.Listener, Handler<StandardSession.FrameBytes>, Dumpable
{
private static final Logger logger = Log.getLogger(Session.class);
private static final ThreadLocal<Integer> handlerInvocations = new ThreadLocal<Integer>()
@ -1092,6 +1097,27 @@ public class StandardSession implements ISession, Parser.Listener, Handler<Stand
flowControlStrategy.setWindowSize(this, initialWindowSize);
}
public String toString()
{
return String.format("%s@%x{v=%d,q=%d}",getClass().getSimpleName(),hashCode(),version,queue.size());
}
@Override
public String dump()
{
return AggregateLifeCycle.dump(this);
}
@Override
public void dump(Appendable out, String indent) throws IOException
{
AggregateLifeCycle.dumpObject(out,this);
AggregateLifeCycle.dump(out,indent,Collections.singletonList(controller),streams.values());
}
public interface FrameBytes extends Comparable<FrameBytes>
{
public IStream getStream();

View File

@ -236,4 +236,9 @@ public class SPDYAsyncConnection extends AbstractConnection implements AsyncConn
{
this.session = session;
}
public String toString()
{
return String.format("%s@%x{endp=%s@%x}",getClass().getSimpleName(),hashCode(),getEndPoint().getClass().getSimpleName(),getEndPoint().hashCode());
}
}

View File

@ -16,6 +16,7 @@
package org.eclipse.jetty.spdy;
import java.io.IOException;
import java.nio.channels.SocketChannel;
import java.util.ArrayList;
import java.util.Collection;
@ -41,6 +42,7 @@ import org.eclipse.jetty.server.nio.SelectChannelConnector;
import org.eclipse.jetty.spdy.api.SPDY;
import org.eclipse.jetty.spdy.api.Session;
import org.eclipse.jetty.spdy.api.server.ServerSessionFrameListener;
import org.eclipse.jetty.util.component.AggregateLifeCycle;
import org.eclipse.jetty.util.log.Log;
import org.eclipse.jetty.util.log.Logger;
import org.eclipse.jetty.util.ssl.SslContextFactory;
@ -312,4 +314,14 @@ public class SPDYServerConnector extends SelectChannelConnector
threadPool.dispatch(command);
}
}
@Override
public void dump(Appendable out, String indent) throws IOException
{
super.dump(out,indent);
AggregateLifeCycle.dump(out, indent, new ArrayList<Session>(sessions));
}
}

View File

@ -374,10 +374,10 @@ public class AggregateLifeCycle extends AbstractLifeCycle implements Destroyable
for (Bean b : _beans)
{
i++;
out.append(indent).append(" +- ");
if (b._managed)
{
out.append(indent).append(" +- ");
if (b._bean instanceof Dumpable)
((Dumpable)b._bean).dump(out,indent+(i==size?" ":" | "));
else