From b1bb418fea9bf0a16de2a1e80ec4d871ba96f249 Mon Sep 17 00:00:00 2001 From: Simone Bordet Date: Fri, 3 Aug 2012 19:16:57 +0200 Subject: [PATCH] Jetty9 - SPDY cleanups. --- ...yAsyncEndPoint.java => EmptyEndPoint.java} | 2 +- ...ava => NextProtoNegoClientConnection.java} | 6 ++--- .../org/eclipse/jetty/spdy/SPDYClient.java | 8 +++---- ...yncConnection.java => SPDYConnection.java} | 10 ++++---- .../jetty/spdy/SPDYServerConnector.java | 24 ++++--------------- .../ServerSPDYAsyncConnectionFactory.java | 6 ++--- 6 files changed, 20 insertions(+), 36 deletions(-) rename jetty-spdy/spdy-jetty/src/main/java/org/eclipse/jetty/spdy/{EmptyAsyncEndPoint.java => EmptyEndPoint.java} (98%) rename jetty-spdy/spdy-jetty/src/main/java/org/eclipse/jetty/spdy/{NextProtoNegoClientAsyncConnection.java => NextProtoNegoClientConnection.java} (92%) rename jetty-spdy/spdy-jetty/src/main/java/org/eclipse/jetty/spdy/{SPDYAsyncConnection.java => SPDYConnection.java} (92%) diff --git a/jetty-spdy/spdy-jetty/src/main/java/org/eclipse/jetty/spdy/EmptyAsyncEndPoint.java b/jetty-spdy/spdy-jetty/src/main/java/org/eclipse/jetty/spdy/EmptyEndPoint.java similarity index 98% rename from jetty-spdy/spdy-jetty/src/main/java/org/eclipse/jetty/spdy/EmptyAsyncEndPoint.java rename to jetty-spdy/spdy-jetty/src/main/java/org/eclipse/jetty/spdy/EmptyEndPoint.java index 8dc81ca8c67..2b7189c1ad9 100644 --- a/jetty-spdy/spdy-jetty/src/main/java/org/eclipse/jetty/spdy/EmptyAsyncEndPoint.java +++ b/jetty-spdy/spdy-jetty/src/main/java/org/eclipse/jetty/spdy/EmptyEndPoint.java @@ -23,7 +23,7 @@ import org.eclipse.jetty.io.Connection; import org.eclipse.jetty.io.EndPoint; import org.eclipse.jetty.util.Callback; -public class EmptyAsyncEndPoint implements EndPoint +public class EmptyEndPoint implements EndPoint { private boolean checkForIdle; private Connection connection; diff --git a/jetty-spdy/spdy-jetty/src/main/java/org/eclipse/jetty/spdy/NextProtoNegoClientAsyncConnection.java b/jetty-spdy/spdy-jetty/src/main/java/org/eclipse/jetty/spdy/NextProtoNegoClientConnection.java similarity index 92% rename from jetty-spdy/spdy-jetty/src/main/java/org/eclipse/jetty/spdy/NextProtoNegoClientAsyncConnection.java rename to jetty-spdy/spdy-jetty/src/main/java/org/eclipse/jetty/spdy/NextProtoNegoClientConnection.java index cb9e6019391..e1cab1e7825 100644 --- a/jetty-spdy/spdy-jetty/src/main/java/org/eclipse/jetty/spdy/NextProtoNegoClientAsyncConnection.java +++ b/jetty-spdy/spdy-jetty/src/main/java/org/eclipse/jetty/spdy/NextProtoNegoClientConnection.java @@ -26,7 +26,7 @@ import org.eclipse.jetty.util.BufferUtil; import org.eclipse.jetty.util.log.Log; import org.eclipse.jetty.util.log.Logger; -public class NextProtoNegoClientAsyncConnection extends AbstractConnection implements NextProtoNego.ClientProvider +public class NextProtoNegoClientConnection extends AbstractConnection implements NextProtoNego.ClientProvider { private final Logger logger = Log.getLogger(getClass()); private final SocketChannel channel; @@ -34,7 +34,7 @@ public class NextProtoNegoClientAsyncConnection extends AbstractConnection imple private final SPDYClient client; private volatile boolean completed; - public NextProtoNegoClientAsyncConnection(SocketChannel channel, EndPoint endPoint, Object attachment, Executor executor, SPDYClient client) + public NextProtoNegoClientConnection(SocketChannel channel, EndPoint endPoint, Object attachment, Executor executor, SPDYClient client) { super(endPoint, executor); this.channel = channel; @@ -48,7 +48,7 @@ public class NextProtoNegoClientAsyncConnection extends AbstractConnection imple super.onOpen(); fillInterested(); } - + @Override public void onFillable() { diff --git a/jetty-spdy/spdy-jetty/src/main/java/org/eclipse/jetty/spdy/SPDYClient.java b/jetty-spdy/spdy-jetty/src/main/java/org/eclipse/jetty/spdy/SPDYClient.java index 81865d5b2f7..0f1eba588ae 100644 --- a/jetty-spdy/spdy-jetty/src/main/java/org/eclipse/jetty/spdy/SPDYClient.java +++ b/jetty-spdy/spdy-jetty/src/main/java/org/eclipse/jetty/spdy/SPDYClient.java @@ -347,7 +347,7 @@ public class SPDYClient }; EndPoint sslEndPoint = sslConnection.getDecryptedEndPoint(); - NextProtoNegoClientAsyncConnection connection = new NextProtoNegoClientAsyncConnection(channel, sslEndPoint, attachment, client.factory.threadPool, client); + NextProtoNegoClientConnection connection = new NextProtoNegoClientConnection(channel, sslEndPoint, attachment, client.factory.threadPool, client); sslEndPoint.setConnection(connection); connectionOpened(connection); @@ -414,7 +414,7 @@ public class SPDYClient Parser parser = new Parser(compressionFactory.newDecompressor()); Generator generator = new Generator(factory.bufferPool, compressionFactory.newCompressor()); - SPDYAsyncConnection connection = new ClientSPDYAsyncConnection(endPoint, factory.bufferPool, parser, factory); + SPDYConnection connection = new ClientSPDYConnection(endPoint, factory.bufferPool, parser, factory); endPoint.setConnection(connection); FlowControlStrategy flowControlStrategy = client.newFlowControlStrategy(); @@ -430,11 +430,11 @@ public class SPDYClient return connection; } - private class ClientSPDYAsyncConnection extends SPDYAsyncConnection + private class ClientSPDYConnection extends SPDYConnection { private final Factory factory; - public ClientSPDYAsyncConnection(EndPoint endPoint, ByteBufferPool bufferPool, Parser parser, Factory factory) + public ClientSPDYConnection(EndPoint endPoint, ByteBufferPool bufferPool, Parser parser, Factory factory) { super(endPoint, bufferPool, parser, factory.threadPool); this.factory = factory; diff --git a/jetty-spdy/spdy-jetty/src/main/java/org/eclipse/jetty/spdy/SPDYAsyncConnection.java b/jetty-spdy/spdy-jetty/src/main/java/org/eclipse/jetty/spdy/SPDYConnection.java similarity index 92% rename from jetty-spdy/spdy-jetty/src/main/java/org/eclipse/jetty/spdy/SPDYAsyncConnection.java rename to jetty-spdy/spdy-jetty/src/main/java/org/eclipse/jetty/spdy/SPDYConnection.java index 810ad41020b..c92b72ee5f0 100644 --- a/jetty-spdy/spdy-jetty/src/main/java/org/eclipse/jetty/spdy/SPDYAsyncConnection.java +++ b/jetty-spdy/spdy-jetty/src/main/java/org/eclipse/jetty/spdy/SPDYConnection.java @@ -18,23 +18,23 @@ import java.nio.ByteBuffer; import java.util.concurrent.Executor; import org.eclipse.jetty.io.AbstractConnection; -import org.eclipse.jetty.io.EndPoint; import org.eclipse.jetty.io.ByteBufferPool; +import org.eclipse.jetty.io.EndPoint; import org.eclipse.jetty.io.RuntimeIOException; import org.eclipse.jetty.spdy.parser.Parser; import org.eclipse.jetty.util.Callback; import org.eclipse.jetty.util.log.Log; import org.eclipse.jetty.util.log.Logger; -public class SPDYAsyncConnection extends AbstractConnection implements Controller, IdleListener +public class SPDYConnection extends AbstractConnection implements Controller, IdleListener { - private static final Logger logger = Log.getLogger(SPDYAsyncConnection.class); + private static final Logger logger = Log.getLogger(SPDYConnection.class); private final ByteBufferPool bufferPool; private final Parser parser; private volatile ISession session; private volatile boolean idle = false; - public SPDYAsyncConnection(EndPoint endPoint, ByteBufferPool bufferPool, Parser parser, Executor executor) + public SPDYConnection(EndPoint endPoint, ByteBufferPool bufferPool, Parser parser, Executor executor) { super(endPoint, executor); this.bufferPool = bufferPool; @@ -48,7 +48,7 @@ public class SPDYAsyncConnection extends AbstractConnection implements Controlle super.onOpen(); fillInterested(); } - + @Override public void onFillable() { diff --git a/jetty-spdy/spdy-jetty/src/main/java/org/eclipse/jetty/spdy/SPDYServerConnector.java b/jetty-spdy/spdy-jetty/src/main/java/org/eclipse/jetty/spdy/SPDYServerConnector.java index 006330f1766..115808e9ea5 100644 --- a/jetty-spdy/spdy-jetty/src/main/java/org/eclipse/jetty/spdy/SPDYServerConnector.java +++ b/jetty-spdy/spdy-jetty/src/main/java/org/eclipse/jetty/spdy/SPDYServerConnector.java @@ -21,8 +21,6 @@ import java.util.Collections; import java.util.List; import java.util.Queue; import java.util.concurrent.ConcurrentLinkedQueue; -import java.util.concurrent.Executor; -import java.util.concurrent.RejectedExecutionException; import javax.net.ssl.SSLEngine; import org.eclipse.jetty.io.Connection; @@ -42,7 +40,7 @@ public class SPDYServerConnector extends SelectChannelConnector { private final Queue sessions = new ConcurrentLinkedQueue<>(); private final ServerSessionFrameListener listener; - private volatile int initialWindowSize = 65536; + private volatile int initialWindowSize; public SPDYServerConnector(Server server, ServerSessionFrameListener listener) { @@ -53,6 +51,7 @@ public class SPDYServerConnector extends SelectChannelConnector { super(server, sslContextFactory); this.listener = listener; + setInitialWindowSize(65536); putConnectionFactory("spdy/3", new ServerSPDYAsyncConnectionFactory(SPDY.V3, getByteBufferPool(), getExecutor(), getScheduler(), listener)); putConnectionFactory("spdy/2", new ServerSPDYAsyncConnectionFactory(SPDY.V2, getByteBufferPool(), getExecutor(), getScheduler(), listener)); setDefaultConnectionFactory(getConnectionFactory("spdy/2")); @@ -173,25 +172,10 @@ public class SPDYServerConnector extends SelectChannelConnector getSelectorManager().connectionUpgraded(endPoint, oldConnection); } - private class LazyExecutor implements Executor - { - @Override - public void execute(Runnable command) - { - Executor threadPool = getExecutor(); - if (threadPool == null) - throw new RejectedExecutionException(); - threadPool.execute(command); - } - } - - @Override public void dump(Appendable out, String indent) throws IOException { - super.dump(out,indent); - AggregateLifeCycle.dump(out, indent, new ArrayList(sessions)); + super.dump(out, indent); + AggregateLifeCycle.dump(out, indent, new ArrayList<>(sessions)); } - - } diff --git a/jetty-spdy/spdy-jetty/src/main/java/org/eclipse/jetty/spdy/ServerSPDYAsyncConnectionFactory.java b/jetty-spdy/spdy-jetty/src/main/java/org/eclipse/jetty/spdy/ServerSPDYAsyncConnectionFactory.java index 6f857199776..12624d8bd01 100644 --- a/jetty-spdy/spdy-jetty/src/main/java/org/eclipse/jetty/spdy/ServerSPDYAsyncConnectionFactory.java +++ b/jetty-spdy/spdy-jetty/src/main/java/org/eclipse/jetty/spdy/ServerSPDYAsyncConnectionFactory.java @@ -62,7 +62,7 @@ public class ServerSPDYAsyncConnectionFactory implements ConnectionFactory SPDYServerConnector connector = (SPDYServerConnector)attachment; ServerSessionFrameListener listener = provideServerSessionFrameListener(endPoint, attachment); - SPDYAsyncConnection connection = new ServerSPDYAsyncConnection(endPoint, bufferPool, parser, listener, connector); + SPDYConnection connection = new ServerSPDYConnection(endPoint, bufferPool, parser, listener, connector); endPoint.setConnection(connection); FlowControlStrategy flowControlStrategy = connector.newFlowControlStrategy(version); @@ -83,13 +83,13 @@ public class ServerSPDYAsyncConnectionFactory implements ConnectionFactory return listener; } - private static class ServerSPDYAsyncConnection extends SPDYAsyncConnection + private static class ServerSPDYConnection extends SPDYConnection { private final ServerSessionFrameListener listener; private final SPDYServerConnector connector; private volatile boolean connected; - private ServerSPDYAsyncConnection(EndPoint endPoint, ByteBufferPool bufferPool, Parser parser, ServerSessionFrameListener listener, SPDYServerConnector connector) + private ServerSPDYConnection(EndPoint endPoint, ByteBufferPool bufferPool, Parser parser, ServerSessionFrameListener listener, SPDYServerConnector connector) { super(endPoint, bufferPool, parser, connector.getExecutor()); this.listener = listener;