Introduced overridable configure(SocketChannel) method.
This allows subclasses to configure the socket with rarely used options such as the traffic class and or SocketOptions.
This commit is contained in:
parent
8bfb50176b
commit
df63400dbe
|
@ -18,6 +18,20 @@
|
||||||
|
|
||||||
package org.eclipse.jetty.http2.client;
|
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.io.IOException;
|
||||||
import java.net.InetSocketAddress;
|
import java.net.InetSocketAddress;
|
||||||
import java.nio.channels.SelectionKey;
|
import java.nio.channels.SelectionKey;
|
||||||
|
@ -28,27 +42,6 @@ import java.util.Queue;
|
||||||
import java.util.concurrent.ConcurrentLinkedQueue;
|
import java.util.concurrent.ConcurrentLinkedQueue;
|
||||||
import java.util.concurrent.Executor;
|
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
|
public class HTTP2Client extends ContainerLifeCycle
|
||||||
{
|
{
|
||||||
private Executor executor;
|
private Executor executor;
|
||||||
|
@ -196,7 +189,7 @@ public class HTTP2Client extends ContainerLifeCycle
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
SocketChannel channel = SocketChannel.open();
|
SocketChannel channel = SocketChannel.open();
|
||||||
channel.socket().setTcpNoDelay(true);
|
configure(channel);
|
||||||
channel.configureBlocking(false);
|
channel.configureBlocking(false);
|
||||||
|
|
||||||
context.put(HTTP2ClientConnectionFactory.CLIENT_CONTEXT_KEY, this);
|
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()
|
private void closeConnections()
|
||||||
{
|
{
|
||||||
for (ISession session : sessions)
|
for (ISession session : sessions)
|
||||||
|
|
Loading…
Reference in New Issue