From df63400dbe845a4670e2f24ab0f7c489a530502d Mon Sep 17 00:00:00 2001 From: Simone Bordet Date: Wed, 29 Apr 2015 09:46:26 +0200 Subject: [PATCH] Introduced overridable configure(SocketChannel) method. This allows subclasses to configure the socket with rarely used options such as the traffic class and or SocketOptions. --- .../jetty/http2/client/HTTP2Client.java | 42 +++++++++---------- 1 file changed, 20 insertions(+), 22 deletions(-) diff --git a/jetty-http2/http2-client/src/main/java/org/eclipse/jetty/http2/client/HTTP2Client.java b/jetty-http2/http2-client/src/main/java/org/eclipse/jetty/http2/client/HTTP2Client.java index 71db3be956c..be23c1f24db 100644 --- a/jetty-http2/http2-client/src/main/java/org/eclipse/jetty/http2/client/HTTP2Client.java +++ b/jetty-http2/http2-client/src/main/java/org/eclipse/jetty/http2/client/HTTP2Client.java @@ -18,6 +18,20 @@ package org.eclipse.jetty.http2.client; +import org.eclipse.jetty.alpn.client.ALPNClientConnectionFactory; +import org.eclipse.jetty.http2.ErrorCode; +import org.eclipse.jetty.http2.ISession; +import org.eclipse.jetty.http2.api.Session; +import org.eclipse.jetty.io.*; +import org.eclipse.jetty.io.ssl.SslClientConnectionFactory; +import org.eclipse.jetty.util.Callback; +import org.eclipse.jetty.util.Promise; +import org.eclipse.jetty.util.component.ContainerLifeCycle; +import org.eclipse.jetty.util.ssl.SslContextFactory; +import org.eclipse.jetty.util.thread.QueuedThreadPool; +import org.eclipse.jetty.util.thread.ScheduledExecutorScheduler; +import org.eclipse.jetty.util.thread.Scheduler; + import java.io.IOException; import java.net.InetSocketAddress; import java.nio.channels.SelectionKey; @@ -28,27 +42,6 @@ import java.util.Queue; import java.util.concurrent.ConcurrentLinkedQueue; import java.util.concurrent.Executor; -import org.eclipse.jetty.alpn.client.ALPNClientConnectionFactory; -import org.eclipse.jetty.http2.ErrorCode; -import org.eclipse.jetty.http2.ISession; -import org.eclipse.jetty.http2.api.Session; -import org.eclipse.jetty.io.ByteBufferPool; -import org.eclipse.jetty.io.ClientConnectionFactory; -import org.eclipse.jetty.io.Connection; -import org.eclipse.jetty.io.EndPoint; -import org.eclipse.jetty.io.ManagedSelector; -import org.eclipse.jetty.io.MappedByteBufferPool; -import org.eclipse.jetty.io.SelectChannelEndPoint; -import org.eclipse.jetty.io.SelectorManager; -import org.eclipse.jetty.io.ssl.SslClientConnectionFactory; -import org.eclipse.jetty.util.Callback; -import org.eclipse.jetty.util.Promise; -import org.eclipse.jetty.util.component.ContainerLifeCycle; -import org.eclipse.jetty.util.ssl.SslContextFactory; -import org.eclipse.jetty.util.thread.QueuedThreadPool; -import org.eclipse.jetty.util.thread.ScheduledExecutorScheduler; -import org.eclipse.jetty.util.thread.Scheduler; - public class HTTP2Client extends ContainerLifeCycle { private Executor executor; @@ -196,7 +189,7 @@ public class HTTP2Client extends ContainerLifeCycle try { SocketChannel channel = SocketChannel.open(); - channel.socket().setTcpNoDelay(true); + configure(channel); channel.configureBlocking(false); context.put(HTTP2ClientConnectionFactory.CLIENT_CONTEXT_KEY, this); @@ -218,6 +211,11 @@ public class HTTP2Client extends ContainerLifeCycle } } + protected void configure(SocketChannel channel) throws IOException + { + channel.socket().setTcpNoDelay(true); + } + private void closeConnections() { for (ISession session : sessions)